Builder's Old Measurement (BOM or bm) is the method of calculating the size or cargo capacity of a ship used in England from approximately 1650 to 1849. It estimated the tonnage of a ship based on length and maximum beam. [http://en.wikipedia.org/wiki/Builder%27s_Old_Measurement]
![]()
I will show you in an Apache Maven configuration file how to copy files to server each time the package phase is executed.
This snippet of code is a ready to use code that make use of Apache Ant task scp, Just put this snippet of code in your Maven module where the assembly is executed or anywhere else to push all tar.gz files to a server just run a maven mvn package, you can add as many ant task and push to many server the same file during the reactor build.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>server-copy</id>
<goals>
<goal>run</goal>
</goals>
<phase>package</phase>
<configuration>
<target>
<echo message="Push to server/home/"/>
<scp trust="yes"
todir="user:password@server:/home/">
<fileset dir="${basedir}/target">
<include name="**/*.tar.gz"/>
</fileset>
</scp>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.2</version>
</dependency>
</dependencies>
</plugin>
The maven-deploy-plugin allows you to configure the deploy phase to deploy to a server using scp. There is a page in the documentation that describes how it can be done.
Another alternative would be to use Maven Wagon SCP like described in this post for example
First a big thanks to Packt Publishing for having sent me this book to review! I did enjoy going through this book, while I did not learn a lot of new stuff (I am using Apache Maven daily since 2006!), I found it to be concise and would recommend it anytime to any of my colleagues. But let’s go through my review of this cookbook of over 50 recipes towards optimal Java Software Engineering with Maven 3:

Apache Maven 3 Cookbook is a clear, precise, well-written book that gives readers clear recipes for the release process using Apache Maven 3. The authors give a step-by-step account of expectations and hurdles for software development.
The first few chapters quickly bring you to the point to be comfortable using Maven on straightforward projects, and the later chapters provide even more recipes examples on subjects like running a Repository Manager, Writing Plugins, and details on various techniques. The book also covers numerous real world software delivery issues such as multi-module projects, web/enterprise projects, dependency management, automatic testing and documentation.
To sum up key points from this 224 pages book in a few bullets:
The author Srirangan go into detail in describing each of these themes.
if you want to be able to deliver your software to any target environment, using continuous delivery processes, chances are high that Apache Maven is the right tool for this job, and this book should be part of your technical library, beside also of course the free online book of Sonatype Maven: The Complete Reference
![]()
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
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
It is not unusual in a project to have a huge number of third party artifacts and Plug-in. Apache Maven help you keep track of them, along with their transitive dependencies.
But how do you know when a new version of an artifact is available? This is where the Maven Versions plug-in come hand in.
The Versions Plug-in is used when you want to manage the versions of artifacts in a project's POM.
By running
mvn versions:display-dependency-updates
in any Apache Maven project or modules, you’ll get for example (we have a lot of 25 Maven modules, here is only one presented as an example, the list being too long)
[INFO] --------------------------------------------------------------------------------------------------
[INFO] Building Unnamed - com.innoveo:skye-services-api:jar:2.2.0-M-06
[INFO] --------------------------------------------------------------------------------------------------
[INFO]
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO] junit:junit ............................................. 4.4 -> 4.8.1
[INFO] log4j:log4j ......................................... 1.2.15 -> 1.2.16
[INFO] org.springframework:spring ...................... 2.5.6 -> 2.5.6.SEC02
[INFO] org.springframework:spring-test ............... 2.5.6 -> 3.0.4.RELEASE
Read more: Keep your software stack up to date with the Apache Maven Versions Plugin
In which order are Apache Maven profiles executed? are Apache Maven profiles ordered? how can you insured that Apache Maven profiles are activated in the right order?
You normally don’t end up with these questions, issues may only appear if
The use case behind this article is very simple, as I have a a continuous build were:
All these steps are done using several Apache Maven pom profiles.
As it is a bit complicated to explain, lets first refresh some Apache Maven concepts
Read more: Apache Maven profiles order in multi modules projects

I found this time a new way to deploy Maven artefacts using the Oracle Weblogic Ant API!
If you remember my previous post, there is many ways to deploy your war/ear to Oracle Weblogic
And now using the official ANT API of Oracle, by far the MOST stable of all!
Read more: Auto deployment of Maven artifacts to Oracle Weblogic
Depending on your project requirements/number of customers, you may have to support different target environment. This article will help you to make your Maven build a bit more portable in that sense. Maven can help you avoiding having stage dependent data across all your Maven projects/ modules very easily thanks to resources filtering.
Let’s imagine you want to build your software against many different runtime stack:
And that your software is somehow configurable, can be through properties files, xml files, environment variables. Some of your configurations files are containing data that are depending on runtime (paths, password, login, connection settings to database, profiling/tuning settings)
Read more: Maven project filtering
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.