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

Gradle fails to resolve dependency net.bytebuddy:byte-buddy #188

Closed
thokuest opened this issue Jun 12, 2020 · 15 comments
Closed

Gradle fails to resolve dependency net.bytebuddy:byte-buddy #188

thokuest opened this issue Jun 12, 2020 · 15 comments
Labels
AssertJ Support the xmlunit-assertj module
Milestone

Comments

@thokuest
Copy link

The following build.gradle snippet

dependencies {
    testImplementation platform("org.junit:junit-bom:5.6.2")
    testImplementation 'org.junit.jupiter:junit-jupiter-api'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
    testRuntimeOnly 'org.junit.platform:junit-platform-runner'
    
    testImplementation "org.assertj:assertj-core:3.16.1"
    testImplementation "org.xmlunit:xmlunit-core:2.7.0"
    testImplementation "org.xmlunit:xmlunit-assertj:2.7.0"
}

fails to resolve Byte Buddy with the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':server:compileTestJava'.
> Could not resolve all files for configuration ':server:testCompileClasspath'.
   > Could not find net.bytebuddy:byte-buddy:.
     Required by:
         project :server > org.xmlunit:xmlunit-assertj:2.7.0

Which version of Byte Buddy do I need to include?

assertj-core itself depends on Byte Buddy already but shades the dependency into it's own jar.

bodewig added a commit that referenced this issue Jun 12, 2020
might make things easeier for Gradle, see #188
@bodewig
Copy link
Member

bodewig commented Jun 12, 2020

Depends on the version of Java. The parent POM lists 1.10.0 inside the Java7+ profile and 1.10.10 in the Java14+ profile. It looks as if Gradle didn't mimic maven when several active profiles contribute to dependencyManagement.

I think I added the 1.10.10 version in order to fix the builds on Java 14.

Honestly I haven't followed what @krystiankaluzny is doing with the help of bytebuddy in the assertj module closely, no idea whether unconditionally bumping the dependency to 1.10.10 will break anything. I guess we will see what Travis says: c261b72

@bodewig bodewig added the AssertJ Support the xmlunit-assertj module label Jun 12, 2020
@bodewig
Copy link
Member

bodewig commented Jun 12, 2020

OK, that didn't hurt too much.

As I type a 2.8.0-SNAPSHOT build is going up to the Sonatype OSS Nexus. Can you please give it a try with Gradle to see whether it likes to work with that?

@thokuest thokuest changed the title Gralde fails to resolve dependency net.bytebuddy:byte-buddy Gradle fails to resolve dependency net.bytebuddy:byte-buddy Jun 13, 2020
@thokuest
Copy link
Author

No, this didn't work.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':server:compileTestJava'.
> Could not resolve all files for configuration ':server:testCompileClasspath'.
   > Could not find net.bytebuddy:byte-buddy:.
     Required by:
         project :server > org.xmlunit:xmlunit-assertj:2.8.0-SNAPSHOT:20200612.154140-1

Looking at the pom.xml, I'm pretty sure it's due to net.bytebuddy:byte-buddy being provided scoped. Hence the consuming project or any other dependency is expected to depend on it separately which also may make sense given the fast pace at which new Java versions are released and the role Byte Buddy plays here!

<dependency>
    <groupId>net.bytebuddy</groupId>
    <artifactId>byte-buddy</artifactId>
    <version>1.10.10</version>
    <scope>provided</scope>
</dependency

I wonder if Maven projects produce a different result.

With regard to profile support in Gradle, yes, Gradle supports Maven profiles to some limited extend.

Consuming Maven dependencies that rely on profiles

We have discussed the role of Maven profiles in configuring a build and alternative approaches in Gradle. As Gradle supports depending on POM-based artifacts we must also consider how Maven profiles affect dependency resolution.

Some published Maven artifacts, especially in the public Maven Central repository, depend on the information declared in their POM profiles for the dependency resolution process. Such a practice is considered to be an anti-pattern to be avoided as it influences the reproducibility of a build. Nevertheless, it is used in practice and Gradle 1.12 introduces support for some profile usage that affects dependency resolution.

Supported profile criteria in Gradle

There are two activation criteria Gradle considers:

  1. Profiles that are active by default (available with Gradle 1.12 and higher)
  2. Profiles that are active on the absence of a system property (available with Gradle 2.0 and higher)

From: Gradle's Support for Maven POM Files

@bodewig
Copy link
Member

bodewig commented Jun 28, 2020

Any suggestion what we should change on our side to make things easier?

@thokuest
Copy link
Author

I need to check how it works in Maven first. I keep you posted once I'm clear what can be done.

@bodewig
Copy link
Member

bodewig commented Jul 29, 2020

@thokuest the doc snippet you've posted indicates gradle wouldn't support profiles triggered by JDK version, so I've now simply moved the dependencyManagement section outside of the profile and published new SNAPSHOTS. Could you please give the 20200729 SNAPSHOT a try?

@thokuest
Copy link
Author

thokuest commented Aug 1, 2020

Thanks @bodewig! Will do once I'm back from vacation!

@bodewig
Copy link
Member

bodewig commented Aug 1, 2020

Enjoy your vacation @thokuest :-)

@thokuest
Copy link
Author

I just checked the latest snapshot build. I decided to setup a Maven project to check whether the build tool is important in some shape of form. The Maven build fails as well with a similar message indicating missing bytebuddy:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running de.tk.XmlunitAssertjTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.097 s <<< FAILURE! - in de.tk.XmlunitAssertjTest
[ERROR] test  Time elapsed: 0.087 s  <<< ERROR!
java.lang.NoClassDefFoundError: net/bytebuddy/matcher/ElementMatcher
        at de.tk.XmlunitAssertjTest.test(XmlunitAssertjTest.java:10)
Caused by: java.lang.ClassNotFoundException: net.bytebuddy.matcher.ElementMatcher
        at de.tk.XmlunitAssertjTest.test(XmlunitAssertjTest.java:10)

See reproducer https://github.com/thokuest/xmlunit-issue-188-reproducer for your convenience.

Maybe it's an issue in the project, but isn't it so that transitive provided scope dependencies are not consumable?

@bodewig
Copy link
Member

bodewig commented Aug 19, 2020

OK, so it seems we're breaking automatic transitive dependency resolution for bytebuddy and force people to explicitly depend on bytebuddy themselves, right?

@krystiankaluzny do you recall why you made bytebuddy provided in the first place?

@thokuest
Copy link
Author

OK, so it seems we're breaking automatic transitive dependency resolution for bytebuddy and force people to explicitly depend on bytebuddy themselves, right?

Yes!

@bodewig
Copy link
Member

bodewig commented Sep 27, 2020

I've changed the scope and am just now publishing new SNAPSHOTs, would be good if you could give it a try.

@bodewig
Copy link
Member

bodewig commented Sep 27, 2020

2.8.0-SNAPSHOT, that is.

@bodewig bodewig added this to the 2.8.0 milestone Sep 27, 2020
@thokuest
Copy link
Author

Confirmed working with commit 8bb2221. Thanks a lot @bodewig!

@bodewig
Copy link
Member

bodewig commented Oct 30, 2020

I've finally released 2.8.0, thanks @thokuest for the patience and for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AssertJ Support the xmlunit-assertj module
Projects
None yet
Development

No branches or pull requests

2 participants