我在我的POM中使用gmaven-plugin到set a custom system property。这似乎工作,因为我能够使用maven-antrun-plugin成功回显属性;然而,maven-deploy-plugin似乎完全不知道该属性,并且无法解决它。为什么maven-deploy-plugin无法解析我的自定义系统属性?
的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>
当我跑这跟mvn clean install deploy:deploy-file
,我得到以下错误:
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.
为什么Maven的antrun-插件能解决我的自定义系统属性,而maven-deploy-plugin不是?
'mvn clean deploy'工作吗? – Raghuram
@Raghuram - 不,我用这个POM创建的唯一工件是一个.sql文件,Maven没有sql包装类型。这意味着我无法运行deploy:deploy,而必须运行deploy:deploy-file。 –