Snapshot plugins cannot be resolved correctly with java6
--------------------------------------------------------

                 Key: MNG-2793
                 URL: http://jira.codehaus.org/browse/MNG-2793
             Project: Maven 2
          Issue Type: Bug
          Components: Artifacts and Repositories, Dependencies
    Affects Versions: 2.0.4
            Reporter: Daniel Kulp
         Attachments: maven-artifact-manager.patch

With java 6, builds that use snapshot repositories are consistently failing if 
the snapshots are not available in the local repository.  The error is 
something like:
[INFO] 
----------------------------------------------------------------------------
[DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins::1 for 
project: null:maven-site-plugin:maven-plugin:2.0-beta-5 from the repository.
[DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent::1 for project: 
org.apache.maven.plugins:maven-plugins:pom:1 from the repository.
[DEBUG] Retrieving parent-POM: org.apache:apache::1 for project: 
org.apache.maven:maven-parent:pom:1 from the repository.
[DEBUG] maven-install-plugin: using locally installed snapshot
[DEBUG] maven-install-plugin: resolved to version 2.2-SNAPSHOT from repository 
central
[DEBUG] Skipping disabled repository central
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.apache.maven.plugins:maven-install-plugin

Reason: Error getting POM for 'org.apache.maven.plugins:maven-install-plugin' 
from the repository: Failed to resolve artifact, possibly due to a repository 
list that is not appropriately equipped for this artifact's metadata.
  org.apache.maven.plugins:maven-install-plugin:pom:2.2-SNAPSHOT

from the specified remote repositories:
  apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository),
  central (http://repo1.maven.org/maven2)




If the artifacts are first downloaded by building with JDK 1.5, everything 
works fine.


After investigating, the problem is in the transforms that the 
maven-artifact-manager.   With JDK 1.5, the order they run is:
org.apache.maven.artifact.transform.LatestArtifactTransformation
org.apache.maven.artifact.transform.ReleaseArtifactTransformation
org.apache.maven.artifact.transform.SnapshotTransformation

but with Java 6, for some reason, the order is:

org.apache.maven.artifact.transform.SnapshotTransformation
org.apache.maven.artifact.transform.LatestArtifactTransformation
org.apache.maven.artifact.transform.ReleaseArtifactTransformation

The LatestArtifactTransform is what uses to the metadata to determine 
the "actual" version number (for the install plugin, 2.2-SNAPSHOT).  The 
SnapshotTransform then converts that to 2.2-20061118.060401-2 which is what 
is then downloaded.   However, in the java 6 case, the SnapshotTransform is 
run first and since the version is not a "SNAPSHOT" version number, it 
doesn't do any processing so then the downloading ends up looking for 
2.2-SNAPSHOT, not the full version, which then fails.


I chatted with brett_ on IRC about this:
[09:46:35] <dkulp> OK.  I'm trying to track down why  my builds are failing 
with JDK 1.6
[09:46:53] <dkulp> The issue is the transforms are in a different order with 
1.6 than 1.5
[09:47:17] <brett_> yikes
[09:47:42] <dkulp> With 1.5, its Latest/Release/Snapshot.
[09:47:46] <brett_> not sure why that would matter. But I guess sorting the 
transforms consistently would help.
[09:47:50] <dkulp> With 1.6, it's Snapshot/Latest/Release
[09:48:06] <brett_> ok, fairly simple to fix in Maven.
[09:48:10] <dkulp> The Latest needs to be before Snapshot.
[09:49:08] <dkulp> I tried changing the order of things in the components.xml.  
 Didn't seem to change anything.   But this is plexus stuff which I don't know 
anything about.
[09:49:22] <brett_> hmm, it should be populated as a list
[09:49:28] <brett_> but maybe the list is backed by a map
[09:49:35] <dkulp> Yep.   Verified it's and ArrayList
[09:49:51] <brett_> s/backed/populated by/
[09:50:48] <dkulp> That would definitely do it.
[09:51:21] <dkulp> Any hints on where to look?
[09:51:48] <brett_> oh, I would go into plexus
[09:51:52] <dkulp> (or how to debug)?
[09:51:58] <brett_> sorry, wouldn't
[09:52:13] <brett_> it's changing too much
[09:52:18] <brett_> 2.0.5 will be stuck with alpha-10
[09:52:24] <brett_> so, need to work around it in Maven
[09:53:00] <brett_> perhaps just hack the order in the code, and then fix 
plexus to honour the order in components.xml in trunk
[09:54:57] <dkulp> Hmm..    ok.    Is there something plexus will call after 
setting the List field so I can resort it?
[09:55:30] <dkulp> Or will adding a "setArtifactTransformations(List)" work?
[09:55:40] <dkulp> (again, not familiar with plexus)
[09:56:25] <brett_> no, it sets it using private field injection
[09:57:04] <dkulp> No  optional "init" methods or anything that are called 
after everything is done?
[09:57:42] <brett_> you can implement Initializable and modify them then
[09:57:50] <brett_> but you could just as easily do that inside the method 
using it
[09:58:08] <dkulp> There are 4 methods using it that are called to resolve 
every artifact.
[09:58:24] <dkulp> Sorry, 3.
[09:58:37] <dkulp> Kind of just wanted to sort once, not for each artifact.
[09:58:46] <brett_> but the transformations should just exist in one class, and 
only used in one place, IIRC
[10:06:46] <dkulp> brett_: thanks.   That actually works.


The attached patch forces the "Snapshot" transform to the end of the list.   
It's definitely not ideal.   Ideally, plexus would be fixed to honor ordering, 
but if plexus is in a state of flux, that might not be doable.







-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to