12

i am using Apache Maven 3.0 Nexus Open Source Edition, Version: 1.8.0.1

this is part of my pom.xml

<plugin>
   <artifactId>maven-deploy-plugin</artifactId>
   <version>2.5</version>
</plugin>
<plugin>
   <artifactId>maven-release-plugin</artifactId>
   <version>2.1</version>
</plugin>

<distributionManagement>
   <repository>
   <id>nexus</id>
   <name>nexus</name>
   <url>http://myrepo/nexus/content/repositories/releases</url>
   </repository>
</distributionManagement>

it is a very simple project. when i do

  mvn release:prepare
  mvn release:perform

everything runs fine:

...
[INFO] [INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) @ simple ---
[INFO] Uploading: http://myrepo/nexus/content/repositories/releases/...pom
[INFO] 4 KB   
[INFO] 5 KB   
[INFO]        
[INFO] Uploaded: http://myrepo/nexus/content/repositories/releases/....pom (5 KB at 1.0 KB/sec)
[INFO] Downloading: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml
[INFO] 603 B   
[INFO]         
[INFO] Downloaded: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml (603 B at 1.5 KB/sec)
[INFO] Uploading: http://myrepo/nexus/content/repositories/releases/.../maven-metadata.xml
[INFO] 634 B   
[INFO]         
[INFO] Uploaded: http://myrepo/nexus/content/repositories/.../maven-metadata.xml (634 B at 1.6 KB/sec)

Now i download http://myrepo/nexus/content/repositories/.../maven-metadata.xml it looks like this:

<metadata>
<groupId>simple</groupId>
<artifactId>simple</artifactId>
<versioning>
<latest>0.5.8</latest>
<release>0.5.8</release>
<versions>
<version>0.5.9</version>
<version>0.1</version>
<version>0.3</version>
<version>0.4</version>
<version>0.5.1</version>
<version>0.5.2</version>
<version>0.5.3</version>
<version>0.5.4</version>
<version>0.5.5</version>
<version>0.5.6</version>
<version>0.5.7</version>
<version>0.5.8</version>
</versions>
<lastUpdated>20110202190804</lastUpdated>
</versioning>
</metadata>

my latest and just released version is not marked as "latest" and "release".

Now i do "Rebuild Metadata" inside Nexus WebUI. I download metadata after this again. It looks now like this

<metadata>
  <groupId>simple</groupId>
  <artifactId>simple</artifactId>
  <versioning>
    <latest>0.5.9</latest>
    <release>0.5.9</release>
    <versions>
      <version>0.1</version>
      <version>0.3</version>
      <version>0.4</version>
      <version>0.5.1</version>
      <version>0.5.2</version>
      <version>0.5.3</version>

      <version>0.5.4</version>
      <version>0.5.5</version>
      <version>0.5.6</version>
      <version>0.5.7</version>
      <version>0.5.8</version>
      <version>0.5.9</version>

    </versions>
    <lastUpdated>20110202191117</lastUpdated>
  </versioning>
</metadata>

This looks like a bug in nexus or in maven? Does anybody has a solution for this?

carlspring
  • 27,224
  • 23
  • 101
  • 178
Janning
  • 7,357
  • 8
  • 59
  • 79

1 Answers1

9

Have you tried setting updateReleaseInfo to true in your deploy plugin configuration?

<plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <updateReleaseInfo>true</updateReleaseInfo>
    </configuration>
</plugin>

Note, I haven't tried this, just happened to have the deploy plugin docs open when I read this question and it seems reasonable.

From the Maven docs:

updateReleaseInfo:
Parameter used to update the metadata to make the artifact as release.

Type: boolean
Required: No
Expression: ${updateReleaseInfo}
Default: false
user944849
  • 13,003
  • 2
  • 55
  • 76
  • 1
    I tried this but don-t think it's a solution. In fact this will just force `` in `maven-metadata.xml` to be set to whatever version you're uploading, even if ti's ending in -SNAPSHOT. It doesn't update LATEST at all. – protoboolean Mar 20 '12 at 15:00
  • @Xan, I believe you would only want to use that configuration if you were actually doing a release, not for snapshot deploys. There are 2 ways to do this; either include the config shown inside a `` that you activate for releases (e.g. `mvn -Prelease release:perform` where `-Prelease` activates the profile with ID "release". Or, you could skip the deploy config entirely and use `mvn -DupdateReleaseInfo=true release:perform` which does the same. – user944849 Mar 20 '12 at 16:44
  • 7
    I belive nobody is talking about performing a release here, the issue is why the metadata is not updated?!? I have to run a job every 30seconds on Nexus to refresh it or I can never get the LATEST artifact. In fact I implemented a job for continuous integration on Hudson to deploy the LATEST successfully built artifact. The problem is that the metadata doesn't have the LATEST tag set correctly. – protoboolean Mar 20 '12 at 22:06
  • @Xan I have a similar problem but thought that the issue was more with Nexus API incorrectly resolving v=LATEST. FWIW, see my post [here](http://permalink.gmane.org/gmane.comp.apache.maven.nexus.user/5515). No answer so far... – Nikita Mar 21 '12 at 19:37
  • @Nikita I noticed that running the task to rebuild the maven metadata, the LATEST tag is updated. In your case it will become 11-SNAPSHOT. After that I bet that Nexus API will respond the way you expect. (By the way, what does it mean FWIW?) – protoboolean Mar 21 '12 at 22:28
  • @Xan For What It's Worth. I also noticed that running rebuild metadata fixes the issue. But that seems like a bug - just not yet clear where – Nikita Mar 22 '12 at 02:45