maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cedric Beust (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (MRESOLVER-21) Maven Resolver trying to resolve optional dependencies
Date Sun, 02 Apr 2017 15:42:41 GMT

     [ https://issues.apache.org/jira/browse/MRESOLVER-21?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Cedric Beust updated MRESOLVER-21:
----------------------------------
    Description: 
I modified the `ResolveTransitiveDependencies.java` example in two ways:

- Modified the id to `"org.springframework:spring-context-support:2.5.6.SEC03"`
- Replaced the filter with one that excludes optional dependencies

I'm including the full code below.

Despite that, `system.resolveDependencies()` fails with a `DependencyResolutionException when
trying to resolve a bunch of optional dependencies, sugh as `jasperreports`.

Head of the stack trace:

```
org.eclipse.aether.resolution.DependencyResolutionException: Failed to collect dependencies
at org.springframework:spring-context-support:jar:2.5.6.SEC03 -> jasperreports:jasperreports:jar:2.0.5
-> commons-logging:commons-logging:jar:99.0-does-not-exist
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:380)
	at org.apache.maven.resolver.examples.ResolveTransitiveDependencies.main(ResolveTransitiveDependencies.java:71)
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect
dependencies at org.springframework:spring-context-support:jar:2.5.6.SEC03 -> jasperreports:jasperreports:jar:2.0.5
-> commons-logging:commons-logging:jar:99.0-does-not-exist
	at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:291)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:341)
	... 1 more
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact
descriptor for commons-logging:commons-logging:jar:99.0-does-not-exist
```


```
    public static void main( String[] args )
        throws Exception
    {
        System.out.println( "------------------------------------------------------------"
);
        System.out.println( ResolveTransitiveDependencies.class.getSimpleName() );

        RepositorySystem system = Booter.newRepositorySystem();

        RepositorySystemSession session = Booter.newRepositorySystemSession( system );

        Artifact artifact = new DefaultArtifact( "org.springframework:spring-context-support:2.5.6.SEC03"
);

        DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE
);
        DependencyFilter optionalFilter = new DependencyFilter() {
            @Override
            public boolean accept(DependencyNode dependencyNode, List<DependencyNode>
list) {
                return ! dependencyNode.getDependency().getOptional();
            }
        };
        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) );
        collectRequest.setRepositories( Booter.newRepositories( system, session ) );

        DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, optionalFilter
);

        try {
            List<ArtifactResult> artifactResults =
                    system.resolveDependencies(session, dependencyRequest).getArtifactResults();

            for (ArtifactResult artifactResult : artifactResults) {
                System.out.println(artifactResult.getArtifact() + " resolved to "
                        + artifactResult.getArtifact().getFile());
            }
        } catch(Exception ex) {
            ex.printStackTrace();
        }
    }
```


  was:
I modified the `ResolveTransitiveDependencies.java` example in two ways:

- Modified the id to `"org.springframework:spring-context-support:2.5.6.SEC03"`
- Replaced the filter with one that excludes optional dependencies

I'm including the full code below.

Despite that, `system.resolveDependencies()` fails with a `DependencyResolutionException when
trying to resolve a bunch of optional dependencies, sugh as `jasperreports`.

```
    public static void main( String[] args )
        throws Exception
    {
        System.out.println( "------------------------------------------------------------"
);
        System.out.println( ResolveTransitiveDependencies.class.getSimpleName() );

        RepositorySystem system = Booter.newRepositorySystem();

        RepositorySystemSession session = Booter.newRepositorySystemSession( system );

        Artifact artifact = new DefaultArtifact( "org.springframework:spring-context-support:2.5.6.SEC03"
);

        DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE
);
        DependencyFilter optionalFilter = new DependencyFilter() {
            @Override
            public boolean accept(DependencyNode dependencyNode, List<DependencyNode>
list) {
                return ! dependencyNode.getDependency().getOptional();
            }
        };
        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) );
        collectRequest.setRepositories( Booter.newRepositories( system, session ) );

        DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, optionalFilter
);

        try {
            List<ArtifactResult> artifactResults =
                    system.resolveDependencies(session, dependencyRequest).getArtifactResults();

            for (ArtifactResult artifactResult : artifactResults) {
                System.out.println(artifactResult.getArtifact() + " resolved to "
                        + artifactResult.getArtifact().getFile());
            }
        } catch(Exception ex) {
            ex.printStackTrace();
        }
    }
```



> Maven Resolver trying to resolve optional dependencies
> ------------------------------------------------------
>
>                 Key: MRESOLVER-21
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-21
>             Project: Maven Resolver
>          Issue Type: Bug
>          Components: resolver
>            Reporter: Cedric Beust
>
> I modified the `ResolveTransitiveDependencies.java` example in two ways:
> - Modified the id to `"org.springframework:spring-context-support:2.5.6.SEC03"`
> - Replaced the filter with one that excludes optional dependencies
> I'm including the full code below.
> Despite that, `system.resolveDependencies()` fails with a `DependencyResolutionException
when trying to resolve a bunch of optional dependencies, sugh as `jasperreports`.
> Head of the stack trace:
> ```
> org.eclipse.aether.resolution.DependencyResolutionException: Failed to collect dependencies
at org.springframework:spring-context-support:jar:2.5.6.SEC03 -> jasperreports:jasperreports:jar:2.0.5
-> commons-logging:commons-logging:jar:99.0-does-not-exist
> 	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:380)
> 	at org.apache.maven.resolver.examples.ResolveTransitiveDependencies.main(ResolveTransitiveDependencies.java:71)
> Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect
dependencies at org.springframework:spring-context-support:jar:2.5.6.SEC03 -> jasperreports:jasperreports:jar:2.0.5
-> commons-logging:commons-logging:jar:99.0-does-not-exist
> 	at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:291)
> 	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:341)
> 	... 1 more
> Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read
artifact descriptor for commons-logging:commons-logging:jar:99.0-does-not-exist
> ```
> ```
>     public static void main( String[] args )
>         throws Exception
>     {
>         System.out.println( "------------------------------------------------------------"
);
>         System.out.println( ResolveTransitiveDependencies.class.getSimpleName() );
>         RepositorySystem system = Booter.newRepositorySystem();
>         RepositorySystemSession session = Booter.newRepositorySystemSession( system );
>         Artifact artifact = new DefaultArtifact( "org.springframework:spring-context-support:2.5.6.SEC03"
);
>         DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE
);
>         DependencyFilter optionalFilter = new DependencyFilter() {
>             @Override
>             public boolean accept(DependencyNode dependencyNode, List<DependencyNode>
list) {
>                 return ! dependencyNode.getDependency().getOptional();
>             }
>         };
>         CollectRequest collectRequest = new CollectRequest();
>         collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) );
>         collectRequest.setRepositories( Booter.newRepositories( system, session ) );
>         DependencyRequest dependencyRequest = new DependencyRequest( collectRequest,
optionalFilter );
>         try {
>             List<ArtifactResult> artifactResults =
>                     system.resolveDependencies(session, dependencyRequest).getArtifactResults();
>             for (ArtifactResult artifactResult : artifactResults) {
>                 System.out.println(artifactResult.getArtifact() + " resolved to "
>                         + artifactResult.getArtifact().getFile());
>             }
>         } catch(Exception ex) {
>             ex.printStackTrace();
>         }
>     }
> ```



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message