Mars Atmosphere and Volatile EvolutioN (MAVEN) is a planned space exploration mission to send a space probe to orbit Mars. [http://en.wikipedia.org/wiki/MAVEN]

Maven for PHP uses the power of Maven for building, reporting on and creating documentations of PHP projects. It adapts the Maven build lifecycle to the PHP world while fully supporting PHP 4 and PHP 5. PHP for Maven uses PHPUnit for unit testing and doxygen for creating the api documentation.
Use a PHP library project to create a library that can be used by other PHP libraries or PHP web projects. Use a PHP web project to create a standalone web project.
So I quickly describe what I did install on my root server (OpenSuse 11.X)
My Objectives: being able to build all my Joomla! component using best agile development practices
“Specific tools and techniques such as continuous integration, automated or xUnit test, pair programming, test driven development, design patterns, domain-driven design, code refactoring and other techniques are often used to improve quality and enhance project agility.”
Read more: Configuring TeamCity, Maven for PHP for Joomla continuous build
![]()
Thanks to Packt Publishing for having sent me this book to review. I will publish a review in the next coming days
You may also consider reading all my articles related to Apache Maven
I will quickly describe in this post how you can code your component/plugins/modules against a specific version of Joomla! with no effort using Maven for PHP.
The trick I made is to package the whole Joomla distribution in a jar file, and add a Maven dependency to the project. As Joomla, PHPUnit, or any other 3rd party is not a set of class packaged in a jar, the brilliant idea of Maven for PHP is to unpack all these dependencies in the target/phpinc directory automatically AND concatenating this directory to the php setting include_path during compile and test phase. You can do the same using the command line by running:
php -d include_path=
That’s also why, It is very important to not put anything from this directory under version control (add a cvs.ignore or svn properties svn:ignore) as it contains dependencies that have no reason to be put under version control in Maven paradigm (they have to reside in a Maven repository)
So I create a new zip file joomla-1.5.10.jar with a directory inside named ‘Joomla’ that contains a standard binary distribution…this jar is published in artifactory with a groupid org.joomla (arbitrary chosen by me)
Read more: When Joomla! meet Maven for PHP
The Maven Dependency Plugin among other things include a dependency:analyze-duplicate
The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.
This Apache Maven plugin is really feature rich and provide a lot of interesting goals:
Read more: List conflicting dependencies in the Maven reactor
A very little trick that allow you to quickly run any operation involving a DOS command on an Eclipse project. Go to the external launcher, and create a new configuration.
This trick may be useful for running your Maven set of command without any dependencies to M2Eclipse.
Read more: Get a command prompt on any Eclipse project
![]()
Scenarios
This is where the Maven Enforcer Plugin will assist you:
The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more standard rules and user created rules.
Add in your pom.xml the following to configure the plugin
Read more: Break Maven build when there is a dependency conflict
This issue has turn me upside down a long time. In fact in the official Google Group http://groups.google.de/group/maven-for-php/ I was not the only one to have this issue.
I did try the following, and it is always good to check first
Only my Linux box was not working. . .(http://teamcity.waltercedric.com)
After that I did materialize the eclipse project of maven-php-plugin and even built a custom version that I’ve deployed without any effort to my Artifactory (http://maven.waltercedric.com)
And what is the solution?
it my server configuration and paranoia :-)
open your php.ini, ideally the right one, don’t put your server at risks: You may have many under Linux, especially if you use plesk or cpanel
location most of the time
/etc/php5/cli/php.ini
and add the directory where your build server make a checkout...
; open_basedir, if set, limits all file operations to the defined directory
; and below. This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
open_basedir = /www/vhosts:/tmp:/xxxx/yyyy/
Next step is to put Joomla! 1.6 and all their PHPUnit tests a run along with Selenium. May also need to patch Maven for PHP to better support Tests reporting like Surefire.
Following the post about Deploy to Tomcat 6 using Maven, here is a ready to use example with the main differences explained in the table below
| Tomcat 7 | Tomcat 6 | |
| containerId | <containerId>tomcat7x</containerId> | <containerId>tomcat6x</containerId> |
| Url of Tomcat manager | <cargo.remote.uri> | <cargo.tomcat.manager.url> |
| example | http://host..com/manager/text/ | http://host..com/manager/ |
| tomcat-users.xml |
<tomcat-users> |
<tomcat-users> |
And finally a snippet of an Apache Maven pom.xml ready to use in a profile, so you can reuse this profile like a method call
<profile>
<id>deployTomcat</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<wait>true</wait>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>
${tomcat.url}
</cargo.remote.uri>
<cargo.remote.username>
${tomcat.user}
</cargo.remote.username>
<cargo.remote.password>
${tomcat.pwd}
</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>${deploy.groupid}</groupId>
<artifactId>${deploy.artifactid}</artifactId>
<type>war</type>
<properties>
<context>${deploy.context}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
<executions>
<execution>
<id>verify-deploy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deployer-undeploy</goal>
<goal>deployer-deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Place as many profiles as you have machine to deploy in settings.xml and declare some variables as properties, as shown below:
<profile>
<id>serverA</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<tomcat.url>http://host.com/manager/text</tomcat.url>
<tomcat.user>admin</tomcat.user>
<tomcat.pwd>admin</tomcat.pwd>
<!-- these properties must be defined
as system property or -D -->
<!-- - deployable.artifactid:
artifactId of web application to be deployed -->
<!-- - deployable.context: web context name -->
</properties>
</profile>
So you can run, and traget multiple host by just exchanging the name of the profile serverA to something else.
mvn integration-test –PdeployTomcat,serverA –Ddeployable.artifactid=demo -Ddeploy.groupid=com.mycompany –Ddeployable.context=showcase
The obvious things to do first in no particular order
Read more: Speeding up Apache Maven Builds
I forgot to blog about this presentation at JAZOON 2008, but I did never forget the added value of this plugin. It is not currently in Apache Maven core but will for sure find its way as an official plugin one day, since it solve elegantly a common problem: technology management
Maven does not know the concept of an artifact life cycle. Such life cycle status information would allow to extend the dependency management in a new dimension. One could declare whether certain dependencies are actually allowed/forbidden/restricted to be used in a project, enabling effective technology management.
Currently a plugin is available to achieve this goal:The AssertDepend plugin. It work by adding metadata, additional xml files in artifact group directory.
The AssertDepend plugin is a Maven extension to perform effective technology management. The plugin checks at build time against lifecycle states defined in metadata on remote repositories in order to inform the developer about inappropriate technology usage (dependency enforcement). Based on a flag the build would either fail or print a warning.
The capability to manage dependencies and technologies on a mature level is essential for software organizations of a certain size. Technology management becomes a key discipline and must be introduced in a careful way to allow for mutual benefits among its stakeholder including developer, management, and customers.
To perform effective technology management, you should keep the number of approved artifacts as small as possible. You cannot remove artifacts from the repository if you want to sustain reproducible builds. Therefore, each artifact in the repository should be marked with a corresponding lifecycle state.
The proposed main states are (but the plugin is not limited, you can create your own)
With these states, it solve elegantly the following use cases.
Scenario 1: Flawed versions
It turns out that my-app-1.4.2.jar contains a serious security issue and is therefore flawed. Clients of this JAR should actually switch to a newer version my-app-1.4.3.jar which fixes the bug and which is safe to use.
Scenario 2: Decommissioning
Let's assume that my-app-1.4.2.jar is not supported anymore and projects should actually switch to a new release stream
(my-app-2.x.y.jar).
Scenario 3: Restricted usage
Consider a library which has a restricted set of client projects, e.g. only certain projects are allowed to depend on a specific artifact.
Artifact lifecycle metadata must be placed in a file named maven-artifact-lifecycle.xml in the corresponding group directory. For instance, if you want to define lifecycle information for struts, the corresponding metadata file is located here: struts/struts/maven-artifact-lifecycle.xml
This plugin can be downloaded at http://madp.sourceforge.net/index.html
Privacy Statement | Copyright Notice | Licenses
© 1999-2012 Waltercedric.com. Designed by Cédric Walter. Sitemap
Reproduction without explicit permission is prohibited. All Rights Reserved. All photos remain copyright © their rightful owners. No copyright infringement is intended.
Disclaimer: The editor(s) reserve the right to edit any comments that are found to be abusive, offensive, contain profanity, serves as spam, is largely self-promotional, or displaying attempts to harbour irrelevant text links for any purpose.