[ 
https://issues.apache.org/jira/browse/MNG-5895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15383074#comment-15383074
 ] 

Karl Heinz Marbaise commented on MNG-5895:
------------------------------------------

So some more informations. I have dived more into this and found the following 
in Maven Core:
the calss {{DefaultArtifactResolver}}:
{code:java}
    public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
    {
        ......
        if ( request.isResolveTransitively() )
        {
            MetadataResolutionRequest metadataRequest = new 
DefaultMetadataResolutionRequest( request );

            metadataRequest.setArtifact( rootArtifact );
            metadataRequest.setResolveManagedVersions( managedVersions == null 
);

            try
            {
                ResolutionGroup resolutionGroup = source.retrieve( 
metadataRequest );

                if ( managedVersions == null )
                {
                    managedVersions = resolutionGroup.getManagedVersions();
                }

                Set<Artifact> directArtifacts = resolutionGroup.getArtifacts();

                if ( artifacts == null || artifacts.isEmpty() )
                {
                    artifacts = directArtifacts;
                }
                else
                {
                    List<Artifact> allArtifacts = new ArrayList<>();
                    allArtifacts.addAll( artifacts );
                    allArtifacts.addAll( directArtifacts );

                    Map<String, Artifact> mergedArtifacts = new 
LinkedHashMap<>();
                    for ( Artifact artifact : allArtifacts )
                    {
                        String conflictId = artifact.getDependencyConflictId();
                        if ( !mergedArtifacts.containsKey( conflictId ) )
                        {
                            mergedArtifacts.put( conflictId, artifact );
                        }
                    }

                    artifacts = new LinkedHashSet<>( mergedArtifacts.values() );
                }

                collectionRequest = new ArtifactResolutionRequest( request );
                collectionRequest.setServers( request.getServers() );
                collectionRequest.setMirrors( request.getMirrors() );
                collectionRequest.setProxies( request.getProxies() );
                collectionRequest.setRemoteRepositories( 
resolutionGroup.getResolutionRepositories() );
            }
            catch ( ArtifactMetadataRetrievalException e )
            {
                ArtifactResolutionException are =
                    new ArtifactResolutionException( "Unable to get dependency 
information for " + rootArtifact.getId()
                        + ": " + e.getMessage(), rootArtifact, 
metadataRequest.getRemoteRepositories(), e );
                result.addMetadataResolutionException( are );
                return result;
            }
        }

        if ( artifacts == null || artifacts.isEmpty() )
        {
            if ( request.isResolveRoot() )
            {
                result.addArtifact( rootArtifact );
            }
            return result;
        }

{code}
So the lines:
{code:java}
                ResolutionGroup resolutionGroup = source.retrieve( 
metadataRequest );

                if ( managedVersions == null )
                {
                    managedVersions = resolutionGroup.getManagedVersions();
                }

                Set<Artifact> directArtifacts = resolutionGroup.getArtifacts();
{code}
Producing the wrong version. {{directArtifacts}} contains artifacts with the 
wrong versions..

The {{artifacts}} contains the following correct artifacts:
{code}
com.soebes.examples.j2ee:webgui:war:2.0.0
com.soebes.examples.j2ee:service:ejb:2.0.0
com.soebes.examples.j2ee:shade:jar:2.0.0
junit:junit:jar:4.12
org.testng:testng:jar:6.9.8
log4j:log4j:jar:1.2.16
{code}
And the {{directArtifacts}} contains the artifacts with the wrong versions:
{code}
com.soebes.examples.j2ee:webgui:war:1.7.2-SNAPSHOT
com.soebes.examples.j2ee:service:ejb:1.7.2-SNAPSHOT
com.soebes.examples.j2ee:shade:jar:1.7.2-SNAPSHOT
junit:junit:jar:4.12
org.testng:testng:jar:6.9.8
log4j:log4j:jar:1.2.16
{code}

So what I don't understand is the need for this:
{code:java}
                ResolutionGroup resolutionGroup = source.retrieve( 
metadataRequest );

                if ( managedVersions == null )
                {
                    managedVersions = resolutionGroup.getManagedVersions();
                }
{code}
What should be resolved here? Cause all artifacts are already there ? And from 
where do those wrong versions are coming from ? 


> Problem with CI friendly usage of ${..} which is already defined via property 
> in pom file.
> ------------------------------------------------------------------------------------------
>
>                 Key: MNG-5895
>                 URL: https://issues.apache.org/jira/browse/MNG-5895
>             Project: Maven
>          Issue Type: Bug
>    Affects Versions: 3.2.1, 3.2.2, 3.2.5, 3.3.1, 3.3.3
>            Reporter: Karl Heinz Marbaise
>         Attachments: x.diff
>
>
> I have test project where i defined the pom like this:
> {code:xml}
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.soebes.examples.j2ee</groupId>
>   <artifactId>parent</artifactId>
>   <version>${revision}</version>
>   <packaging>pom</packaging>
> {code}
> If i define the revision on command line like this.
> {{mvn -Drevision=1.0-SNAPSHOT clean package}}
> everything fine...
> But now i want to make the usage a bit more convenient so i added the 
> following to my pom:
> {code:xml}
>   <properties>
>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>     <revision>1.0-SNAPSHOT</revision>
>   </properties>
> {code}
> to have a default for revision which works fine now...
> But if i would like to overwrite the property from command line like this:
> {{mvn -Drevision=1.0 clean package}}
> the build failes in the following location:
> {noformat}
> [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (assemblies) on 
> project assembly: 
> Failed to create assembly: Unable to resolve dependencies for assembly 
> 'archive': Failed to resolve dependencies for assembly: 
> Unable to get dependency information for 
> com.soebes.examples.j2ee:service-client:jar:1.0-SNAPSHOT: 
> Failed to process POM for 
> com.soebes.examples.j2ee:service-client:jar:1.0-SNAPSHOT: 
> Non-resolvable parent POM for 
> com.soebes.examples.j2ee:service-client:[unknown-version]: 
> Failure to find com.soebes.examples.j2ee:parent:pom:${revision} in 
> http://localhost:8081/nexus/content/groups/public was 
> cached in the local repository, resolution will not be reattempted until the 
> update interval of nexus has elapsed or 
> updates are forced
> [ERROR] com.soebes.examples.j2ee:service-client:jar:1.0-SNAPSHOT
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to