在我的父母 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 时提供的属性