I've got a maven project that uses the buildnumber-maven-plugin
. If I run mvn validate
I see it's working:
[INFO] --- buildnumber-maven-plugin:1.3:create (default) @ myproject ---
[INFO] Executing: /bin/sh -c cd /Users/rob/Workspace/myproject && git rev-parse --verify HEAD
[INFO] Storing buildNumber: 5d315d8d1a43c3289fbf114c379fa1a3d3787044 at timestamp: 1477059166424
But if I run mvn resources:resources
the filtered file does not pick it up:
[INFO] --- maven-resources-plugin:2.6:resources (default-cli) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
The pom.xml
has:
<build>
...
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>version.txt</include>
</includes>
</resource>
version.txt
has:
${buildNumber}
But after maven runs, no filtering:
> cat target/classes/version.txt
${buildNumber}
The build number config in pom.xml
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals><goal>create</goal></goals>
</execution>
I don't know enough Maven. Shouldn't running the resources "goal" also get the buildNumber
property?
There is a difference in the commands that you execute:
mvn validate
executes the maven phase "valdate": meaning all phases that come before (in this case none)
mvn resources:resources
is a shortcut for executing the goal "resources" on the resources plugin. Actually its a shortcut for executing: org.apache.maven.plugins:maven-resources-plugin:3.0.1:resources
. These short names are resolved by maven and very typical for plugins in the Apache namespace.
As you can see on the maven life-cycle page the goal you may look for is: "mvn process-resources
". That phase has a default plugin binding to "resources:resources
" which will run the resource plugin. Since you execute a phase all phases before that will be run too, including the build number plugin.
The ":" indicates the difference for the maven command line.