1

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.

Tristan
  • 8,733
  • 7
  • 48
  • 96
  • 1
    The `..` defines only the name which is used in `target` directory but does not influence the name if its installed or deployed. If this would be possible the whole concept of the maven repository would break... – khmarbaise Jul 31 '18 at 16:46
  • Ok, but how can I influence the name of the deployed artifact ? – Tristan Jul 31 '18 at 20:27
  • The name which are being used via `mvn install` or `mvn deploy` can't be influenced. The question is why do you need that? Furthermore why do you need the build time? Why not using such things as git sha1 for spring boot artifacts which has appropriate management endpoint...? Furthermore generating artifacts locally which are consumed by other is a bad idea...better use a CI solution which makes sure the state is reproducible via version control..? – khmarbaise Aug 01 '18 at 07:05
  • I want to control the name of the artifact stored in my Artifactory which is an app published as a super jar (not a jar used as a dependency in other projects). Local deploy is just a first test, but jenkins will use the same command right ? This example says the contrary of what you are saying btw (in the attribute) : https://stackoverflow.com/a/4245890/668455 – Tristan Aug 01 '18 at 07:29
  • can you use another tool besides the maven deploy plugin for deploying your artifact? – Dror Bereznitsky Aug 01 '18 at 13:53
  • Sure, what would u suggest ? – Tristan Aug 01 '18 at 14:16

1 Answers1

1

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

Tristan
  • 8,733
  • 7
  • 48
  • 96