Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot handle Maven transitive system-scoped optional dependencies #10058

Closed
carlspring opened this issue Jul 23, 2019 · 3 comments
Closed

Cannot handle Maven transitive system-scoped optional dependencies #10058

carlspring opened this issue Jul 23, 2019 · 3 comments

Comments

@carlspring
Copy link

carlspring commented Jul 23, 2019

Expected Behavior

I need to use compile group: 'org.apache.yetus', name: 'audience-annotations', version: '0.10.0' in a Gradle project. However, as can be seen here, it has a system-scoped optional dependency defined like this:

  <dependencies>
    <dependency>
      <!-- Version and location set in project pom -->
      <groupId>jdk.tools</groupId>
      <artifactId>jdk.tools</artifactId>
      <scope>system</scope>
      <!-- Mark as optional so that it isn't taken transitively -->
      <optional>true</optional>
    </dependency>
  </dependencies>

The Problem: Because this is: a) a system-scoped and b) optional dependency, Gradle should not be trying to resolve it.

I have the following defined in my build.gradle file:

allprojects {

    configurations.all {
        exclude group: 'jdk.tools', module 'jdk.tools'
    }
    
}

I was expecting this would take care of erasing the dependency from the dependency tree/graph.

However, it's still complaining with:

carlspring@carlspring:/java/opensource/gradle/possible-gradle-bug> gradle --no-daemon clean build

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.apache.yetus:audience-annotations:0.10.0.
  Required by:
      project :
   > Could not resolve org.apache.yetus:audience-annotations:0.10.0.
      > Could not parse POM https://repo1.maven.org/maven2/org/apache/yetus/audience-annotations/0.10.0/audience-annotations-0.10.0.pom
         > Unable to resolve version for dependency 'jdk.tools:jdk.tools:jar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
2 actionable tasks: 1 executed, 1 up-to-date

I don't think it should be attempting to resolve the dependency's pom, or validate it's coordinates in any way, as it's being told to exclude this dependency.

What more do I need to do in order to really exclude this dependency, which shouldn't actually be required, as I'm building the code using a JDK (1.8.0_144)?

I'm using Gradle 4.2.1, (not sure, if upgrading will be an option, unless it's a 4.x version).

I have a "Hello, World!" application illustrating this here.

Current Behavior

The system-scoped optional Maven dependency is not being excluded, like it's being told to.

Steps to Reproduce

Checkout this Hello, World! project and run:

gradle --no-daemon clean build

Your Environment

------------------------------------------------------------
Gradle 4.2.1
------------------------------------------------------------

Build time:   2017-10-02 15:36:21 UTC
Revision:     a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_101 (Oracle Corporation 25.101-b13)
OS:           Linux 4.14.6-1-default amd64

See Also

  • Originally asked on Stackoverflow here, but I suspect this is an actual bug.
    The same thing occurs on Windows 10 as well with Gradle 4.2.1.
  • Raised a follow-up bug with Apache Yetus under YETUS-897.
@dsaikia
Copy link

dsaikia commented Jul 24, 2019

Looks like this got fixed with Gradle 4.10.2 OR somewhere in between these two releases. I have tried running the Hello World , and that works fine with 4.10.2.

Environment:

Gradle 4.10.2

Build time: 2018-09-19 18:10:15 UTC
Revision: b4d8d5d

Kotlin DSL: 1.0-rc-6
Kotlin: 1.2.61
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_202
OS: Mac OS X 10.14.4 x86_64

@carlspring
Copy link
Author

Thanks for checking this! It really does work in 4.10.2, unlike 4.2.1.

Please, feel free to close this!

@ljacomet
Copy link
Member

Closing as requested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants