compatibilty with maven 3
-------------------------

                 Key: NPANDAY-473
                 URL: https://issues.apache.org/jira/browse/NPANDAY-473
             Project: NPanday
          Issue Type: Bug
          Components: Maven Plugins
    Affects Versions: 1.4.1-incubating
         Environment: maven 3, 64 bit windows 7, jre 1.6.0.22
            Reporter: sergio rupena


I get this error when I run maven 3 with npanday:

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal 
org.apache.npanday.plugins:maven-compile-plugin:1.4.1-incubating-SNAPSHOT:initialize
 (default-initialize) on project TestDll: Execution default-initialize of goal 
org.apache.npanday.plugins:maven-compile-plugin:1.4.1-incubating-SNAPSHOT:initialize
 failed: An API incompatibility was encountered while executing 
org.apache.npanday.plugins:maven-
compile-plugin:1.4.1-incubating-SNAPSHOT:initialize: 
java.lang.NoSuchMethodError: 
org.apache.maven.artifact.ArtifactUtils.artifactMapByArtifactId(Ljava/util/Collection;)Ljava/util/Map;
[ERROR] -----------------------------------------------------
[ERROR] realm =    
plugin>org.apache.npanday.plugins:maven-compile-plugin:1.4.1-incubating-SNAPSHOT
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = 
file:/C:/Users/sr/.m2/repository/org/apache/npanday/plugins/maven-compile-plugin/1.4.1-incubating-SNAPSHOT/maven-compile-plugin-1.4.1-incubating-SNAPSHOT.jar
[ERROR] urls[1] = 
file:/C:/Users/sr/.m2/repository/org/apache/npanday/dotnet-registry/1.4.1-incubating-SNAPSHOT/dotnet-registry-1.4.1-incubating-SNAPSHOT.jar
[ERROR] urls[2] = 
file:/C:/Users/sr/.m2/repository/net/sf/kxml/kxml2/2.1.8/kxml2-2.1.8.jar
[ERROR] urls[3] = 
file:/C:/Users/sr/.m2/repository/xmlpull/xmlpull/1.1.3.4a/xmlpull-1.1.3.4a.jar
[ERROR] urls[4] = 
file:/C:/Users/sr/.m2/repository/org/openrdf/openrdf-repository-api/2.0-beta5/openrdf-repository-api-2.0-beta5.jar
[ERROR] urls[5] = 
file:/C:/Users/sr/.m2/repository/org/openrdf/openrdf-query/2.0-beta5/openrdf-query-2.0-beta5.jar
[ERROR] urls[6] = 
file:/C:/Users/sr/.m2/repository/org/openrdf/openrdf-sail-api/2.0-beta5/openrdf-sail-api-2.0-beta5.jar
[ERROR] urls[7] = 
file:/C:/Users/sr/.m2/repository/org/openrdf/openrdf-queryresultio-api/2.0-beta5/openrdf-queryresultio-api-2.0-beta5.jar
[ERROR] urls[8] = 
file:/C:/Users/sr/.m2/repository/org/openrdf/openrdf-rio-api/2.0-beta5/openrdf-rio-api-2.0-beta5.jar
[ERROR] urls[9] = 
file:/C:/Users/sr/.m2/repository/info/aduna/aduna-xml/1.2/aduna-xml-1.2.jar
[ERROR] urls[10] = 
file:/C:/Users/sr/.m2/repository/info/aduna/aduna-lang/1.3/aduna-lang-1.3.jar


It looks like the java class AssemblyResolverImpl.java. (from the 
dotnet-artifact project) can only use the maven 2 API.
I tried the following workaround just to see if I could get it work with maven 
3. I post it here as hack, as it's using reflection to fallback to the maven 3 
api.

{code}
private Map<String, Artifact> 
artifactMapByArtifactId(java.util.Collection<Artifact> artifacts){
        try{
                for(java.lang.reflect.Method method : 
ArtifactUtils.class.getDeclaredMethods()){
                        if (method.getName() == "artifactMapByVersionlessId"){
                                return (Map<String, 
Artifact>)method.invoke(null, new Object[]{artifacts});
                        }
                }
        } catch(java.lang.IllegalAccessException e){
                throw new RuntimeException("failed to map artifacts using 
ArtifactUtils class", e);
        }catch(java.lang.reflect.InvocationTargetException e){
                throw new RuntimeException("failed to map artifacts using 
ArtifactUtils class", e);
        }
        return ArtifactUtils.artifactMapByArtifactId( Collections.singleton( 
artifacts )) ;
}

public void resolve(Artifact artifact, List remoteRepositories, 
ArtifactRepository localRepository) throws ArtifactResolutionException, 
ArtifactNotFoundException
{
        
        String mavenProjectRefId = artifact.getGroupId() + ":" + 
artifact.getArtifactId() + ":" + artifact.getVersion();
        MavenProject mavenProjectRef = (MavenProject) mavenProjectRefs.get( 
mavenProjectRefId );
        if ( mavenProjectRef != null )
        {
                if ( "pom".equals( artifact.getType() ) )
                {
                        artifact.setFile( mavenProjectRef.getFile() );
                        return;
                }
                else
                {
                        Map artifactMapByArtifactId = new HashMap();
                        artifactMapByArtifactId.putAll( 
artifactMapByArtifactId( Collections.singleton( mavenProjectRef.getArtifact() ) 
) );
                        artifactMapByArtifactId.putAll( 
artifactMapByArtifactId( mavenProjectRef.getArtifacts() ) );
                        artifactMapByArtifactId.putAll( 
artifactMapByArtifactId( mavenProjectRef.getAttachedArtifacts() ) );

                        Artifact projectArtifact = (Artifact) 
artifactMapByArtifactId.get( artifact.getId() );
                        if ( projectArtifact != null )
                        {
                                artifact.setFile( projectArtifact.getFile() );
                                return;
                        }
                }
        }

        delegate.resolve( artifact, remoteRepositories, localRepository );
}
{code}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to