首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用buildnumber-maven-plugin生成BuildNumber

不使用buildnumber-maven-plugin生成BuildNumber
EN

Stack Overflow用户
提问于 2012-12-20 21:53:04
回答 1查看 4.3K关注 0票数 4

在我父母的公寓里

代码语言:javascript
复制
<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主类:buildNamescmBranch

代码语言:javascript
复制
<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>

但是在我的主类中,变量从未被替换/展开。有什么想法吗?

从文件中:

代码语言:javascript
复制
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时提供的一个属性。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-03 20:36:39

在父pom中,还没有定义pluginManagement标记。没有它,您的子模块不会继承您定义的插件,它们仅由父pom使用。这就是您需要添加到父pom中的内容。

代码语言:javascript
复制
<build>
    <!-- plugins used by this POM and all inheriting POMs -->
    <pluginManagement>
        <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>
            <!-- other plugins -->
        </plugins>
    </pluginManagement>
</build>

现在,您的子模块可以访问buildnumber-maven-plugin。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13981120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档