Question

Whatever I do, I am not able to get teh buildNumber in the final name of the project :( Reequesting Maven experts to please have a look and suggest some solutions.

Here is my 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>

Thanks in Advance.

Était-ce utile?

La solution

The finalName is only for the name of the artifact in the target folder, but not for the artifact which will be deployed to a repository.

The simple problem you have is that you defined the buildnumber-maven-plugin only in the pluginManagement but not in the build area:

Add the following to your pom file:

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

You need to really execute the buildnumber plugin which is not the case.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top