【问题标题】:Couldn'tmake buildnumber-maven-plugin plugin work无法使 buildnumber-maven-plugin 插件工作
【发布时间】:2013-06-15 22:52:39
【问题描述】:

无论我做什么,我都无法在项目的最终名称中获得 buildNumber :( 再次请 Maven 专家看看并提出一些解决方案。

这是我的 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-    
instance" xsi:schemaLocation ="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-     
v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>in.techieme.springmaven</groupId>
<artifactId>SimpleProject</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SimpleProject Maven Webapp</name>
<url>http://maven.apache.org</url>


<properties>
    <spring.version>3.1.1.RELEASE</spring.version>
    <jdk.version>1.6</jdk.version>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                        <configuration>



<useLastCommittedRevision>true</useLastCommittedRevision>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-timestamp</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                        <configuration>
                            <format>{0,date,yyyy-MM-dd}</format>
                            <items>
                                <item>timestamp</item>
                            </items>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
            </plugin>

        </plugins>
    </pluginManagement>
    <finalName>${artifactId}-${buildRevision}-${buildDateTime}-${buildNumber}</finalName>
</build>

<scm>
    <connection>scm:svn:http://localhost/project1/{project.artifactId}</connection>
    <developerConnection>scm:svn:http://localhost/project1/{project.artifactId}</developerConnection>
    <tag>HEAD</tag>
    <url>http://localhost/project1/{project.artifactId}</url>
</scm>

提前致谢。

【问题讨论】:

    标签: maven maven-3 buildnumber-maven-plugin


    【解决方案1】:

    finalName 仅用于target 文件夹中工件的名称,而不是用于将部署到存储库的工件的名称。

    您遇到的简单问题是您在 pluginManagement 中定义了 buildnumber-maven-plugin 而不是在构建区域中:

    将以下内容添加到您的 pom 文件中:

    <project>
      <build>
        <pluginManagement>
         ...
        </pluginManagement>
        <plugins>
           <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>buildnumber-maven-plugin</artifactId>
           </plugin>
        </plugins>
       ...
      </build>
    </project>
    

    您需要真正执行 buildnumber 插件,但事实并非如此。

    【讨论】:

    • 好吧,战争已经生成并放置在最终名称的目标文件夹中。目前我的战争名称如下所示:SimpleProject-${buildRevision}-${buildDateTime}.war
    • 修复它...我删除了 标签。如果您能告诉我这个标签的用途,我将不胜感激。
    • pluginManagement 标签用于在父级中定义插件的配置/版本,这使得只有一个定义版本/配置的点成为可能。
    • buildnumber-maven-plugin 文档缺少此代码 sn-p,所以我遇到了同样的麻烦。见mojohaus.org/buildnumber-maven-plugin/usage.html
    • 嗨@Davi,你能在 [Github|github.com/mojohaus/buildnumber-maven-plugin/issues] 上创建一个票证并描述遗漏或不正确的地方吗...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    • 2018-05-27
    • 1970-01-01
    相关资源
    最近更新 更多