2009-09-05

Tips on Maven []

Moved to the pages http://3rdstage.wikia.com/wiki/Readings_on_Maven and http://3rdstage.wikia.com/wiki/Tips_on_Maven in my wiki as of 23th Jul. 2012.

Overview

Readings : references, tutorials and articles

Sonatype books
Maven assemblies
Maven snapshot repositories
Deployment process and security
Site process
Release process
Property and Interpolation
misc

Referencing Maven project properties of List type

//@todo

This syntax works within pom.xml and Ant build files using Maven Ant plugin. But this doesn't working with resource filtering of Maven. I can't find any explain or reason for this. Is it a bug?


   ...
   <artifact:pom id="this-pom" file="${basedir}/pom.xml"/>
   <xsddoc out="${this-pom.reporting.outputDirectory}/xsddocs"
      verbose="true">
      <fileset dir="${this-pom.build.resources[0].directory}" 
         includes="**/*.xsd"/>
   </xsddoc>
   ...

Build Lifecycle, Build Phase, Plugin and Goal

Simple tips and troubleshooting

  • The value of Maven property "project.build.directory" in normal case is ${basedir}/target. You can confirm this using the following command line : "mvn help:evaluate -Dexpression=project.build.directory".
  • Solving "org.apache.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60" exception when running site:site goal
    Simply add a dependency on a newer version(eg. 3.8) of icu4j
  • Solving "[ERROR] Unable to determine if resource ... exists in .." error.
    Or just add <dependency.locations.enabled>false</dependency.locations.enabled> into the <properties> element of POM file.
  • Using <addClasspath> when you have no dependencies fails with FileNotFoundException
    Configuring to add classpath to MANIFEST file can cause unreasonable exception when running maven-jar-plugin without compile or run-time scope dependency. If you run package with -X option, you can identify exception whose stack goes like this.

Dependency on local library not in Maven repository and with no POM file

Sometimes your project may have dependency on a JAR file that is not registered to any of Maven repositories and so have no it's own POM file. In this case, you can use <systemPath> element to specify your module's dependency on it.

Note that systemPath could be specified only with system scope. You should specify groupId, artifactId, and version 'cause they are mandatory but you can specify any value and don't need pom file.

Escaping expression interpolation

It may necessary not to interpolate Maven expression in resources. In other words, you just want to leave ${some-property} as it is. For this, you can specify the escape string with escapeString parameter of maven-resource-plugin. You can also define maven.resources.escapeString property in your POM file.

For more refer this page : http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#escapeString

Client configuration

The location of client configuration files for subversion is dependent on operating system.

  • Windows : %USERPROFILE%\Application Data\Subversion\config
  • Linux : ~/.subversion/config

Configurable options are described here : http://svnbook.red-bean.com/en/1.5/svn.advanced.confarea.html#svn.advanced.confarea.opts.config

Working with Subversion working copy in format of ver. 1.7

The default configuration of Maven release plugin(maven-release-plugin) up to ver. 2.2.2 or Maven scm plugin(maven-scm-plugin) up to ver. 1.6 can't work correctly with Subversion working copy in format of ver. 1.7.
To solve this problem, you should override the configuration of release plugin or scm plugin to use maven-scm-provider-svnjava and svnkit 1.7.

For now, svnkit 1.7 has no release and is in snapshot version.

If you let the plugins use svnkit 1.3.x which is default setting as of now, you would meet the exceptions like the following.

For more, refer the followings,

0 comments:

Post a Comment