How to get Maven project version to the bash command line

The Maven Help Plugin is somehow already proposing something for this: help:evaluate evaluates Maven expressions given by the user in an interactive mode. Here is how you would invoke it on the command line to get the ${project.version}: mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate \ -Dexpression=project.version As noted in the comments by Seb T, to only print the version … Read more

I want to execute shell commands from Maven’s pom.xml

Here’s what’s been working for me: <plugin> <artifactId>exec-maven-plugin</artifactId> <groupId>org.codehaus.mojo</groupId> <executions> <execution><!– Run our version calculation script –> <id>Version Calculation</id> <phase>generate-sources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${basedir}/scripts/calculate-version.sh</executable> </configuration> </execution> </executions> </plugin>

Maven 2 assembly with dependencies: jar under scope “system” not included

I’m not surprised that system scope dependencies are not added (after all, dependencies with a system scope must be explicitly provided by definition). Actually, if you really don’t want to put that dependency in your local repository (for example because you want to distribute it as part of your project), this is what I would … Read more

Sharing Test code in Maven

I recommend using type instead of classifier (see also: classifier). It tells Maven a bit more explicitly what you are doing (and I’ve found that m2eclipse and q4e both like it better). <dependency> <groupId>com.myco.app</groupId> <artifactId>foo</artifactId> <version>1.0-SNAPSHOT</version> <type>test-jar</type> <scope>test</scope> </dependency>