I'm using the gmaven-plugin to set a custom system property in my POM. This seems to work, as I'm able to successfully echo the property using the maven-antrun-plugin; however, the maven-deploy-plugin seems completely unaware of the property and is unable to resolve it.
Relevant portion of the POM:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
System.setProperty("nodotsversion", "${env.PATCH_VERSION}".replace('.', ''))
</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version><!-- 1.2 in central -->
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<echo message="${nodotsversion}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>artifactory</repositoryId>
<packaging>sql</packaging>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<groupId>com.company.product</groupId>
<artifactId>patch${nodotsversion}</artifactId>
<version>1.0.0-SNAPSHOT</version>
<file>${WORKSPACE}/myfile.sql</file>
</configuration>
</plugin>
</plugins>
</build>
When I run this with mvn clean install deploy:deploy-file
, I get the following error:
Caused by: org.apache.maven.plugin.MojoExecutionException: The artifact information is incomplete or not valid:
[0] 'artifactId' with value 'patch${nodotsversion}' does not match a valid id pattern.
Why is the maven-antrun-plugin able to resolve my custom system property, while the maven-deploy-plugin is not?
I'm not sure, but I believe that the ${...}
placeholder syntax can only resolve project properties. I believe the system properties are added to the project properties at a point in the build, which is why system properties are available in this way, but a system property added later in the build won't be available. You should add the property to the project properties instead.