Maven 1.x Tips

If you have a Maven 1.x tip, send it to us and we'll post it.

M1 Tip#13: Running Maven in English

If you're like me and you have an OS running in a non-English locale but you still Maven to run in English then here's a tip for you (tip gleaned from Emmanuel Venisse). … continue

M1 Tip#12: Be Maven 2 Friendly

When you deploy a Maven 1 artifact to a remote Maven 1 repository you are also deploying your project's POM (project.xml).

If you're deploying to a Maven 1 repository that is synced with ibiblio your project.xml will find its way on the ibiblio Maven 1 repository where it'll automatically converted into a Maven 2 pom.xml file that will be put into the ibilio Maven 2 repository. … continue

General tip: Finding the version of a JAR

when you're converting an existing Ant project to Maven, one of the first tedious task is to find out the version of the jars that you had been using. Of course you can try to open the JAR and look for the Manifest file but alas in most cases the version is not filled… … continue

General tip: Depending on J2EE

If you're building a J2EE application you'll need to add a dependency on the J2EE JAR in your POM. You have probably noticed that the Sun J2EE JAR is not available on ibiblio. This is due to licensing restrictions. … continue

M1 Tip#11: Customize project's version for nightbuilds

It might be useful to customize a project's current version in certain circumstances. For instance, a continuous integration tool can build a NIGHTBUILD-SNAPSHOT of your project. While the deploy-snapshot achieves this goal, it does not allow external teams to depend on the project, especially if multiple versions are used. In this case, you might have different instances with 1.3-NIGHTBUILD-SNAPSHOT, 2.0-NIGHTBUILD-SNAPSHOT, etc. … continue

M1 Tip#10: Discover plugin releases

There's a useful plugin in Maven 1 called the Multichanges plugin. It's meant to be used un a multiproject scenario and it will create a report listing the latest releases of all plugins. It uses the changes.xml files to discover this information.

Thus … continue

M1 Tip#9: Catch build failure

Sometime you want to execute some Jelly script or call some goal and you don't want the build to stop in case of a failure. For example you might want to call some specific goal even if another goal that you call fails. … continue

M1 Tip#8: Dynamic Property

It's possible to have dynamic properties in Maven. A dynamic property is a property whose name is computed. … continue

M1 Tip #7: Referencing tools.jar

If you're writing a plugin you may have the need to add the tools.jar file to some classpath. You can't add a dependency in your plugin's POM as this Sun JAR cannot be redistributed by Maven on ibiblio. … continue

M1 Tip #6: Jelly and Numbers

Adding two numbers in Jelly is straightforward:
<j:set var="result" value="${value1 + value2}"/>
Remember that expression between curly braces is akin to a Java expression and thus value1 and value2 must be numbers.
continue

M1 Tip #5: Listing Dependencies

There are cases when you wish to list all your multiproject dependencies. To do that you can call the multiproject:projects-init goal from the Multi-Project plugin.
continue

M1 Tip #4: Download menu

If you want to see a "Download" menu appear in the generated web site (as on the Clover plugin web site you'll need to ensre you have the following set up:
  • You need to have defined your releases using the <version> tag in your project's … continue

M1 Tip #3: Prevent new lines on console

When you use Jelly expressions in your plugin.jelly or maven.xml files without wrapping them in a Jelly tag you'll discover that new lines are printed in the console.
continue

M1 Tip #1: Get a plugin's Project object

Let's imagine you wish to get information from an installed plugin. You may think that the following would work:
${pom.getPluginContext('<artifactId>')
  .getProject()}
… but it doesn't! It returns your current Project's object and not the plugin's.
continue