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

Create abstraction for library dependencies for instrumentation. #977

Merged
merged 18 commits into from
Aug 18, 2020

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Aug 14, 2020

Adds three configurations library, testLibrary, latestDepTest library as described here

When Gradle is run with -PtestLatestDeps=true, the standard testImplementation configuration is overridden with the latest dep test wildcards. Without the property, it's as if the wildcards don't exist. This means IntelliJ won't read the wildcard versions anymore. The bottom-left corner of IDE with all the external libraries is still huge, but far smaller than before, presuambly speeding up some IntelliJ indexing / refactoring operations. Most importantly, now IntelliJ won't ever freeze to refresh dynamic versions in the middle of development.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it.

Gradle files look really nice.

library type makes a lot of sense too, as it represents the library under instrumentation / test.

@iNikem
Copy link
Contributor

iNikem commented Aug 14, 2020

Have you tried it with some module where latestDeps differ significantly from compileOnly? If we have such.

If it works, it is a very good simplification :)

@anuraaga
Copy link
Contributor Author

I'm continuing to play with this PR and think I have the concepts mostly ready. I've ended up defining three configurations

library - added to compileOnly and testImplementation as is normally, and when -PtestLatestDeps=true, instead added to testImplementation with the version override of +

testLibrary - an additional library needed for testing (usually a runtime provider or framework of some sort). added to testImpelementation as is normally, and when -PtestLatestDeps=true, instead added to testImplementation with the version override of +

latestDepTestLibrary - essentially a version override for the latest dep test when + isn't appropriate. When -PtestLatestDeps=true, added to testImplementation as is without overriding version.

A couple of takeaways

  • I didn't do an official count, but it seems like about half, maybe a bit more, of the current latestDepTestImplementation wildcards are +. These have a lot of boilerplate removed by just using library. But there is some cognitive load, an alternative is to remove testLibrary and always have the version override explicit. Different from our current solution is this would still only happen when -PtestLatestDeps=true and the win for the IDE development will still be there.

  • Some tests have testLatestDeps source set. Some of these don't even have a wildcard for the latestDepTestImplementation version in which case I will rename them completely and let them run on the normal build (similar to my recent jms change). Some of them do have a wildcard, so these will still use the current solution and I'll add enabled = findProperty(testLatestDeps), but the IDE benefit won't exist. There are very few of these, I may try to find a solution even for them at some point but am not too worried right now.

Let me know if you have any thoughts on approach, naming, etc.

Anuraag Agrawal added 2 commits August 18, 2020 17:00
@anuraaga anuraaga marked this pull request as ready for review August 18, 2020 08:21
@anuraaga
Copy link
Contributor Author

Hopefully this is ready.

We can see the difference in dependencies in build scans like these
https://scans.gradle.com/s/glng4kkzyzzw2/dependencies?toggled=W1szOF0sWzM4LDExXV0
https://scans.gradle.com/s/2ko2puzwhly24/dependencies?toggled=W1szOF0sWzM4LDExXV0

@anuraaga
Copy link
Contributor Author

One point is there are just a few tests left that have actually separate sources for latestDepTest - this is exactly what the test-sets plugin is for :) As a follow up I will think about them a little more to see if something can be simplified but will probably leave them as is.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice ❤️

gradle/instrumentation-common.gradle Outdated Show resolved Hide resolved
Comment on lines +26 to +27
// TODO(anuraaga): Investigate why these tests don't pass on 5 or 6
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/1042
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see more general version of this issue #749

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@anuraaga anuraaga merged commit bbfdbb3 into open-telemetry:master Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants