5

I'd like to call

mvn clean install -Dsomeproperty=1.2.3-20110526-1836

to get

artifact-1.2.3-20110526-1836.jar

instead of

artifact-1.2.3-SNAPSHOT.jar

How can I pass that timestamp to maven ??

Bastl
  • 1,431
  • 3
  • 14
  • 15
  • 1
    Shouldn't you just put that version (`1.2.3-20110526-1836`) into the pom.xml? – Lukas Eder May 31 '11 at 11:51
  • Why you want to do something like this? If you want to prevent downloading artifact from remote repository use `--offline` switch. – teodozjan May 31 '11 at 11:57
  • 1
    we have a nightly build that produces the timestamped versions, I want to overwrite them with my local changes. This is a *BIG* build, so I can only play with some properties from time to time. I do not want to change the poms. – Bastl May 31 '11 at 13:10

3 Answers3

6

The following artifact setting in pom.xml seem to be doing what you want:

<groupId>testgroup</groupId>
<artifactId>testartifact</artifactId>
<version>${someproperty}</version>

Now if you execute "mvn clean install -Dsomeproperty=1.1.timestamp", the jar file produced also contains the timestamp in its name.

I'm not sure if this is what you are looking for.

EDIT

Another solution since the pom file cannot be changed.

Execute the "mvn clean install" command normally. This generates a jar file like artifact-1.2.3-SNAPSHOT.jar.

Install this file again - this time with "mvn install:install-file -Dfile=artifact-1.2.3-SNAPSHOT.jar -DgroupId=testgroup -DartifactId=testartifact -Dversion=1.2.3-123456-1234 -Dpackaging=jar. This will install artifact-1.2.3-123456-1234.jar in your local repository

Vijay
  • 385
  • 2
  • 7
  • yes, that comes close. But as I said I don't want to (must not) edit pom.xml - it's maintained by a special team. I want to set -Dproject.version=1.2.3-123456-1234, but that did not work. How do I do it properly? – Bastl May 31 '11 at 14:03
  • 2
    Correct. Did not notice your requirement on pom nature. I suggest another approach then. Execute the "mvn clean install" command normally. This generates a jar file like artifact-1.2.3-SNAPSHOT.jar. Now, install this file again - this time with "mvn install:install-file -Dfile=artifact-1.2.3-SNAPSHOT.jar -DgroupId=testgroup -DartifactId=testartifact -Dversion=1.2.3-123456-1234 -Dpackaging=jar. This will install artifact-1.2.3-123456-1234.jar in your local repository. – Vijay May 31 '11 at 16:10
1

While this will do what you specified:

<project ...>
    <properties>
         <someproperty>somproperty-default-value</someproperty>
    </properties>
    <build>
        <finalName>artifact-${someproperty}</finalName>
        ....
    </build>
    ....
</project>

I would recommend to use this: How do I add time-stamp information to Maven artifacts?

Community
  • 1
  • 1
Martín Schonaker
  • 7,273
  • 4
  • 32
  • 55
0

The fastest hack for this is to run

     mvn clean install --offline

This will prevent from loading your nightly build from remote repos.

You may also play with settings.xml

teodozjan
  • 913
  • 10
  • 35