Search code examples
xmlmavenmaven-3artifactory

Why is maven ignoring finalName and "build-helper-maven-plugin" when using "deploy"?


I have my "finalName" and the build-helper-maven-plugin configured like this in my main module :

<build>

    <finalName>${project.artifactId}_${build.time}</finalName>

    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>timestamp-property</id>
                    <goals>
                        <goal>timestamp-property</goal>
                    </goals>
                    <configuration>
                        <name>build.time</name>
                        <pattern>yyyy-MM-dd.HHmm</pattern>
                        <locale>fr_FR</locale>
                        <timeZone>Europe/Paris</timeZone>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

</build>

It works fine when I use "mvn package" on the aggregator, but if I do "mvn deploy", it's just ignored : the artifacts use a pattern similar to version_artifactId_maven-timestamp (maven-timestamp using UTC). Also the "version" used in the uploaded artifact is "1.0.0-SNAPSHOT" when the only version I have is in the parent and is "1.0.0-CD".

How can I solve this ?

P.S. : all these tests are local, not using some CI server yet.

P.P.S. : I have to say only artifacts uploaded to Artifactory have wrong names, the artifacts in my target directories are fine.


Solution

  • No answer so far, so here is how I solved this problem.

    I'm using the possibility offered by Maven (without any warning from Maven v3.2.1) to set the version of a pom externally : Allow continuous delivery friendly versions.

    So I replace every <version>1.0.0-SNAPSHOT</version> occurences in aggregator, parent, module (including dependencies) by <version>${revision}</version>.

    And to setup my timezoned timestamp in my release version, I use the "BUILD TIMESTAMP plugin" from Jenkins.

    So the maven deploy command line in jenkins becomes in "Build > Goals and options" : deploy scm:tag -Drevision=1.0.0_$BUILD_TIMESTAMP

    No offense to @khmarbaise, most credits to : Maven Release Plugin: Dead and Buried