What do I want to achieve?
We are currently working on a PHP project that uses Drupal.
I desperately want to learn how to create a One-step build for the whole project.
Preferably by using something new (for me) that seems very powerful: Maven
Basically I want to automate the following process:
Checkout Drupal from the official CVS repository.
Checkout official 3rd party modules from their respective CVS repositories.
Checkout our custom modules from our mercurial repository.
Copy/move all the modules to the appropriate directory within Drupal.
Checkout and install our custom theme.
Add a custom drupal installation profile.
Create a new MySQL database schema.
If possible, automate the drupal db connection setup.
In the future I would like to run this build on a Hudson (or any other) continues integration server.
Why Maven? (why not Ant or Phing?)
Other than the desire to learn something new (I have used Ant before) I think the dependency management of Maven might work well for the drupal modules.
Do you think this is enough reason to use Maven, even though Maven was not originally intended for PHP projects? I know Ant was not originally used for PHP either, but there are far more examples of people using Ant and PHP together.
BTW I think I will switch to Ant if I can't get Maven to work soon. The procedural style of Ant is just easier for me to understand.
What do I have so far?
I have a pom.xml file, that uses the SCM plugin, to checkout the drupal source.
When I run:
mvn scm:checkout
the source is checked out into a new directory:
target/checkout
When I try:
mvn scm:bootstrap
it complains about the install goal not being defined.
Here is the pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>drupal</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.1</version>
<configuration>
<username>anonymous</username>
<password>anonymous</password>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<connection>scm:cvs:pserver:cvs.drupal.org:/cvs/drupal:drupal</connection>
<developerConnection>scm:cvs:pserver:cvs.drupal.org:/cvs/drupal:drupal</developerConnection>
<tag>DRUPAL-6-12</tag>
<url>http://cvs.drupal.org/viewvc.py/drupal/drupal/?pathrev=DRUPAL-6</url>
</scm>
</project>
Finally, what are my questions?
Is Maven the wrong tool for this?
If no,
How would you do this?
Is it the scm:bootstrap goal that I should be using?
What is the Maven way of moving directories around on the file system?
Should the install goal be used to move the modules into the drupal directory?
Currently all our custom modules are in one mercurial repository. Is it possible to create a pom.xml and checkout each module individually?
Any general advice would be appreciated.
Thanks for your time!
I'm 98% certain that what you really need is Drush Make, which can recursively build Drupal projects, provided they provide their own .make file listing their dependencies. It can download from multiple SCMs, web, patch files, and you can control where they get downloaded. It also support external libs, such as wysiwyg, PHP files, or JS libraries.
See the Open Atrium make file for a sample of what it can do.
Definitely you're not using Maven, here some thoughts:
Maven is a Java build tool and dependency management software with a well-defined lifecycle which goes like this: validate, compile, test, package, integration-test, verify, install, deploy. What you are using is the scm plugin which can stick to any of the phases defined here and perform some actions but unless you make complicated changes in the POM (I haven't heard of anyone doing this) the lifecycle will continue being executed.
Maven also is designed to package JARs, WARs and with the use of some plugins EARs, SARs, RARs (not that RARs) and some other files; you might have to program a new plugin to get the type of packages you expect or use the assembly plugin which will make things more complicated.
Because of the previous points, there is no command for Maven to move the files into an specific directory (not a native one) and you shouldn't invoke install phase to copy the files to any other location than the local repository. What you're doing is like taking a laundry machine and converting it into a blender.
After reading what you want to do with your project I'd suggest you to create a script (shell script or batch script depending on your OS) for doing the job. SVN and CVS has command line tools which can be invoked from inside your build scripts. I guess you opted for Maven, among other reasons, because Hudson and many other Continuous Integration software are well integrated with it but you can use them with scripts too.
If you are comfortable using Ant and you consider using it will ease the building time of your app I think is not as bad ;) (I haven't used Ant for other purposes than Java projects)
The Drush 'module' is a great tool for scripting out things in Drupal. But, beyond that, I think your approach of doing CVS checkouts for each 'build' is a little off base - unless you have -really- good reasons to have every chunk of the project in a separate repository, your best bet is to have fixed checkouts of Drupal core & contributed modules committed to your project's repository. Not only does this take out a dependency on a network connection and the stability of an external server but it allows you to have local modifications of the contributed modules (unfortunately, you're probably going to end up doing this somewhere down the line).
Once you take out the requirement to do checkouts from multiple repositories, you'll probably notice that your task becomes -much- easier, leaving you with some simple MySQL manipulation and writing out a settings.php.
The project http://www.php-maven.org know comes with a build plugin enabling the php world to maven (or the maven world for php projects). Version 2 snapshot can be found in our google groups (news thread available at https://groups.google.com/group/maven-for-php/t/e055e49c89ccb8c5?hl=de).
However this gives you a full control over the project and respects the default maven lifecycle so that the maven commands:
mvn clean
mvn package
mvn deploy
mvn site
will work correctly.
Drupal support may be enabled in version 2.1 where we are focused on frameworks (zend, flow3...) and project types (web, cli, libs...). It would be to much to clearify wha maven is and how it can help you during php development. As Vistor Hugo stated on his early comment Mavens benefits are not only to execute a specific command manually but to embed the whole project structure and the whole project lifecycle via maven.
Since the most php guys did not yet have contact to java and especially maven we are creating tutorials so that everyone has a fairly simple entry in the maven world.
I love maven, although I think it is very java specific as mentioned above.
I had success to handle repeable task with phing. I used in a Zend project to prepare a build or just fasten the normal repetable tasks (eg. clean up db, load db dump).
Phing won't provide you complete lifecycle management as maven, but you can write yourself by hand. You can embed shell script commands to build.xml so you can use everything that you would use in a normal shell script.
I prefer phing over normal shell script because it can handle dependent targets, so if your build.xml contains well designed targets that depend each other, you'll get very useful chains to achive specified goals.
It works for me.
Another great tool for drupal is drush which makes drupal administration scriptable. You can do lots of drupal specific things from console. I think you can call drush commands from phing scripts.
Related
I start learning grunt for javascript project management. Grunt requires a series of templates in order to run the tasks. All the guide or examples are saying to install the template manually by running git clone *** on ~/.grunt-init directory. I wander whether there is any automatic way to install all the required templates from current project. Just like what maven or gradle are doing.
It's not a direct answer but check out yeoman for scaffolding front end Web apps. It has a whole lot of cool integrations with grunt.js that will automatically run a bunch of grunt tasks on your project for you. You should definitely check it out.
I and my team have built up an android library project. it is built up on eclipse but we are using ant to build it. Presently we aren't using gradle. I have a roboelectric with dependencies jar file instead. But when I use this, while running the unit tests, the following error comes up
WARNING: multiple versions of ant detected in path for junit
[junit] jar:file:/Users/prateekarora/Desktop/eclipse/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant.jar!/org/apache/tools/ant/Project.class
[junit] and jar:file:/Users/prateekarora/trunk/client/android/MCCMobileClient/test2/libs/robolectric-2.3-with-dependencies.jar!/org/apache/tools/ant/Project.class
When I remove the apache ant from eclipse's plugin folder, this stops working.
Can Anybody explain why this is happening?
Also, is it necessary to use roboelectric with gradle? If no, where can I find the roboelectric's jar files with/without dependencies?
It is not necessary to use gradle with robolectric. It is just about running specified java class (from junit) with proper classpath (including you source, test code and dependencies). Fixing your case is not something that is easy to make over stackoverflow (it will be some challenge even if you sit behind same computer).
Here are possible solutions:
Migrate your project build to the gradle
Keep using ant but move from dependency management from manuals jars to ivy
Keep using ant and manual jars dependency, but try to get robolectric.jar with all dependencies except ant one
The first one option is the easiest option as for me. It will require to change mindset a bit but this is officially only one supported build tool by Google as well there are a lot of examples and people that could help.
The second one also require you to learn how to use new tool. As well there less examples about ivy usage especially in android projects.
The third one will require to write custom script that removes ant from jar file or to rebuild robolectric-all.jar without one (ant) dependency. This will require to dive into maven build tool learning
I have almost finished the development of a project developed with Symfony2, and wish to put the project online.
However, I suppose there are a lot of things that need to be done so that everything works ok. I suppose, the dev mode needs to be disabled etc....What needs to be done and how?
What are the most important things to do on a Symfony2 project that will be available to everyone on the web?
I suggest you to use Capifony for deployment. It does a lot of stuff out of the box and you can make it run any custom commands you need. See its documentation for details.
Regarding the dev mode, unless you've removed the IP checks from app_dev.php, you don't have to worry about deploying it. Of course, if you wish, you can tell Capifony to delete it on deployment.
The best way to handle deployment is to create "build" script, which will:
Remove all folders and files with tests from your bundles and vendors.
Remove app_dev.php file
Make sure that app/cache and app/logs are fully writable/readable.
Packs your project into archive (rpm f.e.)
Then, before deployment, you should create tag in your project - so it will mean, that certain version of your application is released (I recommend to follow this git branching model).
Create tag.
Run your build script
Upload archive to host
Unpack
Enjoy your project
Im currently researching the same thing.
The first thing you have to consider is "how professional" you want to deploy. There are a lot of tools you can use:
Continous Integration Server ( e.g. Hudson, Jenkins)
Build Tools (e.g. Phing, Capistrano --> Capifony, Shell scripts)
Versioning Tools (e.g. Git, SVN)
I think the simplest setup is using only a Build tool and i guess you are already using some kind of versioning.
Depending on which tool you use, the setup is different, but I think there are some things you should consider with your application (maybe not all are applicable to your application)
Creating a Tag in your Versioning
Copying the new Code in an folder on production
--> if you are in a new folder you dont need to clear the cache and logs, since these shouldnt be in your versioning the first time.
loading composer (if youre using it)
installing vendors
updating database schema
install assets from your bundles
move symlink from current version to the folder of the new site
These are the things I currently need for my application for production deployment, if you deploy to an test environment you should load fixtures and run your testscripts as well.
One other option that is very well described here is to deploy the Symfony2 application with Apache Ant. Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other.
In working on larger Actionscript/Flash projects, I've started to really feel the need for some kind of "make" system, but I haven't found it yet. Does anyone know if it exists?
Required features:
Ability to associate SWCs with their source code and/or FLAs i.e. "this swc is compiled from this source"
Ability to mark my current project as depending on these SWCs (either as compile-time or runtime libraries)
A single, big shiny button, that when pressed does the following:
Checks to see if any of the source files have changed, and if so, recompiles their associated SWCs
Recompiles and relinks the main .swf, if necessary
Runs the main .swf
Have yet to find a way to get something like FlashDevelop to do this (but I don't know it well enough to be sure). Support for both code and FLA sources is preferred.
You are looking for http://projectsprouts.org/ which is based on Rake the Ruby version of Make. It can do all of that stuff and much more.
If you have Ruby and RubiGems installed which I think are installed by default on Macs you can install it by typing this into your command line.
sudo gem install Sprout
It will take a while because it installs many things. After this is all set you can create a project like this.
sprout -n as3 ProjectName
and then build it with this,
rake deploy
It manges things based on the runtime they are created for, this project was created for as3 but all of the other types of projects also. The build scripts are all writen in Ruby and can be modified to involve more complex multi-step compiles pretty simply. It also has a bunch of generators so that classes automaticly have unit test that are associated with them and many other features.
Might be a stupid suggestion, but if you want make, why not just use "make"? You can use it for any language by defining the right rules.
Apart from that, I've seen a lot of Flex/Actionscript projects use Apache ant, an XML based build system.
As said by wump; why not use Make?
There are some ANT scripts included in the Flex SDK, so you could explore and expand those. I've also spoken to people who use Maven and Cruise Control for automated build process.
Here is some info on Maven Flex: http://code.google.com/p/flex-mojos/
And some info on Cruise Control w/ Flex: http://www.eyefodder.com/blog/2006/05/continuous_integration_with_fl_5.shtml
Well, there are several options. One I would recommend is the Maven plugin for Flex flex-mojos, now maintained on the Sonotype site. If Maven isn't your cup of tea, they do have an Ant plugin, I don't know if NAnt can call Java Ant tasks directly or not. The third is the most complicated, but Adobe does include an OEM version of the compiler, I believe it comes by default with the SDK download. This is the one I used in the Maven plugin I developed for my company. The reason we didn't use the flex-mojos one basically boils down to a...disagreement about the "Maven way" of one project = one artifact. Their interpretation is that 1 SWF file is one artifact, so is one Maven project. My definition for my project is that all 80+ modules, each a SWF file, are no different than JSPs, all bundled in the same WAR file. So I've got one project with a LOT of modules and 1 maven pom.
You could check out Antpile which according to said link "is a collection of Ant Scripts which cover everything from building a SWF, SWC, AIR, Android and even Unit Testing."
I am new to Netbeans. I am wondering if someone can help me with project setup in netbeans. I am moving half million lines of Java code from a different IDE to Netbeans. I was able to get the code build and run in Netbeans easily. I have a project with many folders with dependencies among those folders. They have to be built in specific order. This is to enforce layering so that a module in lower layer cannot call into higher layers. I couldn't get that configured in Netbeans. Below is how my project looks like
project/
libA/
libB/
libC/
libD/
libE/
appA/
...
I have one project that builds all the libs and appA. The project build xml is stored under project/ folder. But the libs have dependencies among them. libB should be built after libA. libC after libA. libE depends on libD and libB etc.
I tried to change the order of source folders for libs in project properties. That didn't seem to make any difference. Even if I move libA after libB, it was building everything fine. I expected it to fail because libA didn't build yet.
Iam lost. Just wondering what the trick is to enforce this kind of dependencies. I created my project using "Java project using existing sources" wizard.
I appreciate your help
Thanks
Video guy.
Even though it would be a pain, you could just write your own ant build script and then just have Netbeans use that.
Basically:
write the custom ant build file
install the Ant plugin
create an Ant build file
right click the build file
run the selected target.
This would enable you to enforce whatever you need to do, but, if Netbeans is figuring out the correct order then why not just use it.
Does something break when you just compile and run in Netbeans?
Well! Lets say a team member added piece of code in lower level package that calls into higher layer code. It should fail because it breaks the layering. Because Netbeans seem to compile all the files in one javac invocation, the build compiles just fine. I want Netbeans to break the build in this case.
Writing my own ant script is another way of enforcing it. The whole point in using an IDE is to save yourself from writing your own make files (or ant scripts). This is something any IDE was able to accomplish 10 years back out of the box. I am wondering if I am missing something here.
Thanks
Video Guy