You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Cedric Beust (JIRA)" <ji...@apache.org> on 2017/04/08 17:00:43 UTC

[jira] [Comment Edited] (MRESOLVER-21) Maven Resolver trying to resolve optional dependencies

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

Cedric Beust edited comment on MRESOLVER-21 at 4/8/17 5:00 PM:
---------------------------------------------------------------

Digging into the rabbit hole further.

Here is the lovely dependency that JCenter has:

http://jcenter.bintray.com/commons-logging/commons-logging/99.0-does-not-exist/

The parent dependency is `jasperreports/jasperreports/2.0.5/jasperreports-2.0.5.pom` and it depends on `commons-logging` with:

```
                <dependency>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                        <version>[1.0,)</version>
                        <scope>compile</scope>
                </dependency>
```

It's a version range, so Maven Resolver takes the highest it can find on JCenter, which is... 99-doesnt-exist. And boom.







was (Author: cbeust):
Digging into the rabbit hole further.

Here is the lovely dependency that JCenter has:

http://jcenter.bintray.com/commons-logging/commons-logging/99.0-does-not-exist/

The parent dependency is `jasperreports/jasperreports/2.0.5/jasperreports-2.0.5.pom` and it depends on `commons-logging` with:

```
                <dependency>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                        <version>[1.0,)</version>
                        <scope>compile</scope>
                </dependency>
```

So it's a version range, so Maven Resolver takes the highest it can find on JCenter, which is... 99-doesnt-exist. And boom.






> 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:
> {noformat}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{noformat}
> {code:java}
>     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();
>         }
>     }
> {code}



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