2

无论我做什么,我都无法在项目的最终名称中获得 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>

提前致谢。

4

1 回答 1

5

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 插件,但事实并非如此。

于 2013-06-19T12:06:17.523 回答