为什么 maven-deploy-plugin 无法解析我的自定义系统属性?
我正在使用 gmaven-plugin 在我的 POM 中设置自定义系统属性。这似乎有效,因为我能够使用 maven-antrun-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.
Why is the maven-antrun-plugin能够解析我的自定义系统属性,而 maven-deploy-plugin 不是?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定,但我相信
${...}
占位符语法只能解析项目属性。我相信系统属性是在构建过程中的某个时刻添加到项目属性中的,这就是为什么系统属性以这种方式可用,但稍后在构建中添加的系统属性将不可用。您应该将该属性添加到项目属性。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.我不确定这是如何相关的,但我最近发现了使用
${...}
语法和 gmaven-plugin 时遇到的问题。在我的插件中,我为构建生成了一个 FinalName。 pom 的这一部分看起来像:然后,在 maven
部分中,我有类似的内容:
pom 是为了一场战争。当我运行maven时,输出总是:
经过多次绞尽脑汁,我终于弄清楚如何解决问题。
myvar
需要声明为String!I'm not sure how this is related, but I recently figured out a problem I was having using the
${...}
syntax and the gmaven-plugin. In my plugin I was generating a finalName for the build. This part of the pom looks like:Then, in the maven
<source>
section I had something like:The pom was for a war. When I ran maven, the output was always:
After much head scratching I finally figured out how to solve the problem.
myvar
needed to be declared as a String!