【发布时间】:2012-12-20 21:53:04
【问题描述】:
在我的父母 pom 我有
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<doUpdate>true</doUpdate>
</configuration>
</plugin>
在子模块中运行具有上述默认属性的 java Main 类:buildName 和 scmBranch:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>my-execution</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>${MyMainClass}</argument>
<argument>test-${scmBranch}-${buildNumber}</argument>
</arguments>
</configuration>
但变量在我的主类中从未被替换/扩展。有什么想法吗?
来自文档:
required: false
type: java.lang.String
expression: ${maven.buildNumber.buildNumberPropertyName}
default: buildNumber
You can rename the buildNumber property name to another
property name if desired.
据我了解,buildNumber 是包含 buildnumber-maven-plugin 时提供的属性
【问题讨论】:
-
属性 scmBranch 和 buildNumber 定义在哪里?你能把那个代码也贴一下吗?
-
据我了解,它们是在您使用插件时提供的
-
你的 pom 中定义了
<scm>块吗?这是构建号插件了解如何与源代码控制系统通信所必需的。另外,我建议您为<revisionOnScmFailure>设置一个值,这样当出现问题时您可以很容易地看到一个错误的值,例如<revisionOnScmFailure>didn't work!</revisionOnScmFailure>。另外,你能粘贴maven的输出吗?内部版本号插件应该记录一些关于它在调用时所做的事情的信息。 -
能不能把生命周期阶段的定义去掉,使用插件默认的生命周期阶段重新勾选?你怎么叫 mvn ? mvn clean package ?
-
从生命周期中删除什么都不做,是的,我使用 mvn clean package 构建