Finding the root directory of a multi module Maven reactor project

use ${session.executionRootDirectory} For the record, ${session.executionRootDirectory} works for me in pom files in Maven 3.0.3. That property will be the directory you’re running in, so run the parent project and each module can get the path to that root directory. I put the plugin configuration that uses this property in the parent pom so that … Read more

How do I execute a set of goals before my Maven plugin runs?

You can do this by defining a custom lifecycle and invoking that lifecycle before your Mojo is executed via the execute annotation. In your Mojo, declare in the Javadoc the lifecycle to be executed: /** * Invoke the custom lifecycle before executing this goal. * * @goal my-goal * @execute lifecycle=”my-custom-lifecycle” phase=”process-resources” */ public class … Read more

What is the default annotation processors discovery process?

The default way to make an annotation processor available to the compiler is to register it in a file in META-INF/services/javax.annotation.processing.Processor. The file can contain a number of processors: each the fully-qualified class name on its own line, with a newline at the end. The compiler will default to using processors found in this way … Read more

Using Maven for deployment

Ok, I think the following might do what you need. The drawback of this approach is that there will be an interval between each deployment as the subsequent build is executed. Is this acceptable? Define a profile in each project with the same name (say “publish”). Within that profile you can define a configuration to … Read more

Building same project in Maven with different artifactid (based on JDK used)

The Maven way to do this is not to change the finalName of the artifact but to use a classifier. For example: <project> … <build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <classifier>${envClassifier}</classifier> </configuration> </plugin> </plugins> </build> … <profiles> <profile> <id>jdk16</id> <activation> <jdk>1.6</jdk> </activation> <properties> <envClassifier>jdk16</envClassifier> </properties> </profile> <profile> <id>jdk15</id> <activation> <jdk>1.5</jdk> </activation> <properties> <envClassifier>jdk15</envClassifier> </properties> </profile> </profiles> … Read more