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-api-x.y.jar contains too many properties which may break tests #3780

Closed
blindpirate opened this issue Dec 12, 2017 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@blindpirate
Copy link
Collaborator

blindpirate commented Dec 12, 2017

Expected Behavior

Generated gradle-api-x.y.jar should be at the end of test classpath when forking test worker process.

Current Behavior

Now it's at the beginning of the test classpath, which might cause weird test failures.

Context

Recently I found a build of mine is broken after upgrading to 4.4. The failure looks unrelated to the upgrade, but it does exist. I extract a minimum sample here: https://github.com/blindpirate/gradle44-breaking-change

In short, some 3rd dependencies might be leaked into test classpath. If I run test with dependency gradleApi(), the simple test would succeed with 4.3.1, but fail with 4.4. However, running in IDEA always succeed and gradle dependencies with 4.3.1 and 4.4 are identical:

# zhb @ bs-MacBook-Pro in ~/Projects/tmp/gradle44-breaking-change on git:master o [9:03:44] 
$ gradle431 test

BUILD SUCCESSFUL in 3s
2 actionable tasks: 2 executed

# zhb @ bs-MacBook-Pro in ~/Projects/tmp/gradle44-breaking-change on git:master o [9:11:44] 
$ gradle44 test

> Task :test FAILED

GitCloneTest > gitCloneTest FAILED
    org.apache.commons.exec.ExecuteException at GitCloneTest.groovy:65

1 test completed, 1 failed


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/zhb/Projects/tmp/gradle44-breaking-change/build/reports/tests/test/index.html

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

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

BUILD FAILED in 3s
2 actionable tasks: 2 executed

# zhb @ bs-MacBook-Pro in ~/Projects/tmp/gradle44-breaking-change on git:master o [9:11:53] C:1
$ gradle431 dependencies > 431 && md5 431
MD5 (431) = 6f72e1993a16a4cd69aec326835561fd

# zhb @ bs-MacBook-Pro in ~/Projects/tmp/gradle44-breaking-change on git:master x [9:12:14] 
$ gradle44 dependencies > 44 && md5 44
MD5 (44) = 6f72e1993a16a4cd69aec326835561fd

After some investigation, finally I found the reason is the huge gradle-api-x.y.jar which is generated by Gradle when it encounters gradleApi dependency declaration.

Previously, gradle-api-4.3.1.jar didn't contain any JGit dependencies so it works fine. In 4.4, JGit was introduced into version-control subproject, so its resources are shaded into gradle-api-4.4.jar. In this case, org/eclipse/jgit/internal/JGitText.properties from org.eclipse.jgit:org.eclipse.jgit:4.5.3.201708160445-r are loaded from gradle-api-4.4.jar instead of the correct JGit jar. We can see the debug log at this line, the test classpath order is:

Using application classpath [..., /Users/zhb/.gradle/caches/4.4/generated-gradle-jars/gradle-api-4.4.jar, ... , /Users/zhb/.gradle/caches/modules-2/files-2.1/org.eclipse.jgit/org.eclipse.jgit.http.server/4.9.1.201712030800-r/6ecb5bd14f45fe07995074613c9255a3447623b2/org.eclipse.jgit.http.server-4.9.1.201712030800-r.jar ]

Looks like there're no work arounds.

Steps to Reproduce (for bugs)

https://github.com/blindpirate/gradle44-breaking-change

@blindpirate blindpirate self-assigned this Dec 12, 2017
@blindpirate blindpirate changed the title Potential breaking change in 4.4 Potential regression in 4.4 Dec 12, 2017
@blindpirate blindpirate changed the title Potential regression in 4.4 gradle-api-x.y contains too many classes Dec 12, 2017
@blindpirate blindpirate changed the title gradle-api-x.y contains too many classes gradle-api-x.y.jar contains too many classes Dec 12, 2017
@blindpirate blindpirate changed the title gradle-api-x.y.jar contains too many classes gradle-api-x.y.jar contains too many classes which may break tests Dec 12, 2017
@oehme oehme added this to the 4.4.1 milestone Dec 12, 2017
@blindpirate blindpirate changed the title gradle-api-x.y.jar contains too many classes which may break tests gradle-api-x.y.jar contains too many properties which may break tests Dec 12, 2017
@blindpirate blindpirate modified the milestone: 4.4.1 Dec 12, 2017
@oehme
Copy link
Contributor

oehme commented Dec 12, 2017

For 4.4.1 we should exclude the JGit .properties files from the API jar. They are always looked up using the qualified name, so we don't need to keep the copy with the original name. Long term we need to come up with a better solution for our API jar, since these leakages keep biting us.

@big-guy Since the native team introduced this dependency, would you mind taking over this issue?

@oehme oehme assigned big-guy and unassigned blindpirate Dec 12, 2017
@big-guy
Copy link
Member

big-guy commented Dec 12, 2017

@oehme yep, we'll take a look.

big-guy added a commit that referenced this issue Dec 15, 2017
big-guy added a commit that referenced this issue Dec 15, 2017
Do not leave JGit resources in their original location in gradle api
Enable test that reproduces #3780
Only run test on JDK8+ because JGit 4.6+ requires it
@big-guy big-guy closed this as completed Dec 17, 2017
@big-guy
Copy link
Member

big-guy commented Dec 17, 2017

This has been fixed in release

big-guy added a commit that referenced this issue Dec 20, 2017
* origin/release:
  Fix JGit leakage regression
  Add failing test for #3780
  Add smoke test for dependency lock plugin using 2 different versions
  Reinstate constructor that is used by Nebula dependency-lock plugin
  Bump version and reset binary compatibility baseline
  Use Gradle 4.4 to build
  Upgrade kotlin-dsl {0.13.1 => 0.13.2}
  Let production build environment assertion allow using Java 8 to run the build (#3746)
  Let the JVM used to run tests in the gradle/gradle build be set by a Gradle/System property (#3735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants