-
Notifications
You must be signed in to change notification settings - Fork 861
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
Avoid manual artifact/archive renaming (composite build readiness) #3603
Avoid manual artifact/archive renaming (composite build readiness) #3603
Conversation
This comment has been minimized.
This comment has been minimized.
afterEvaluate { | ||
// not available until evaluated. | ||
artifactId = base.archivesName.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting rid of this and ensuring that project name == archive name == artifact ID was key here.
Codecov Report
@@ Coverage Diff @@
## main #3603 +/- ##
============================================
- Coverage 88.55% 88.43% -0.13%
- Complexity 3571 3654 +83
============================================
Files 390 404 +14
Lines 11687 11961 +274
Branches 1156 1186 +30
============================================
+ Hits 10350 10578 +228
- Misses 968 1004 +36
- Partials 369 379 +10
Continue to review full report at Codecov.
|
@@ -175,7 +167,7 @@ dependencies { | |||
dependencyManagement(platform(project(":dependencyManagement"))) | |||
afterEvaluate { | |||
configurations.configureEach { | |||
if (isCanBeResolved && !isCanBeConsumed) { | |||
if (!isCanBeConsumed && this != dependencyManagement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is required for the composite build to work:
So this is not enough to make composite builds work as there is at least one other problem, namely how dependency management is set up. The constraints seem to be only applied if the ultimately built project has the constraints applied. For example, without this change, if I try inside the examples subdirectory:
$ ./gradlew classes --include-build ..
...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':opentelemetry-examples-zipkin:compileJava'.
> Could not resolve all task dependencies for configuration ':opentelemetry-examples-zipkin:compileClasspath'.
> Could not find io.zipkin.reporter2:zipkin-reporter:.
Required by:
project :opentelemetry-examples-zipkin > project :odin-java:exporters:opentelemetry-exporter-zipkin
We can see that opentelemetry-exporter-zipkin
has the dependency api("io.zipkin.reporter2:zipkin-reporter")
. However, the api configuration extends from nothing, so it does not have dependency management applied, and opentelemetry-examples-zipkin:compileClasspath does not use the java-conventions plugin so it does not have dependency management applied either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
da625fc
to
9e69dba
Compare
plugins { | ||
`maven-publish` | ||
signing | ||
|
||
id("otel.japicmp-conventions") | ||
} | ||
|
||
base { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts
@@ -25,6 +27,9 @@ | |||
private static final Tracer tracer = openTelemetry.getTracer("ConfigureSpanProcessorExample"); | |||
|
|||
public static void main(String[] args) { | |||
System.out.println( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this to test the included build, I can remove or adapt it if desired.
include(":sdk-extensions:opentelemetry-sdk-extension-jfr-events") | ||
include(":sdk-extensions:opentelemetry-sdk-extension-zpages") | ||
|
||
// Map project names to directory names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this instead of just renaming the folders for now. I would prefer renaming the folders but that makes the PR huge (1070 changed files). Can do in a follow-up.
9e69dba
to
f136531
Compare
As someone who writes a lot of code in this repo, the longer names will definitely hurt the contributor experience I think. Publishing snapshots usually works easily enough and I don't think we've had as much need to write -instrumentation code against HEAD -java code since releasing 1.0. The linked issue problem about gradle-plugins will probably be handled without using a composite build open-telemetry/opentelemetry-java-instrumentation#4112 Composite builds have been around for a while but the limitations seem to not be getting fixed - this makes me think the feature is not very popular. So I'm not too enthusastic about this change TBH. |
I was thinking that it is odd that the artifact IDs start with Also, for me, right now I always need to squint hard to find the artifact name for any given project. |
Would the typical contributor write much Gradle code? |
That makes sense. In that case, it might be possible to rename just the jar but not the artifact ID? But I don't see the problem with long project names anyway and would prefer to avoid any extra configuration if possible, since that makes everything more complex. |
I agree that simplicity of having project names equal to the desired artifact names and GAV coordinates is important enough to accept longer folder names during development. |
The typical contributor will run many Gradle tasks which is what gets more tedious.
We should use the same pattern in our three repos for sanity - so Flattening into just Losing control of your folder structure seems like a reasonable downside that is being missed. I'm still a -1 vote on it. |
That's a point. Counterpoint: I usually don't run tasks per project (incremental builds are great!) or I use the command line history, so the longer names wouldn't bother me. Also, you can abbreviate kebap-case names: https://docs.gradle.org/current/userguide/command_line_interface.html#sec:name_abbreviation E.g. |
Should be doable with |
We're still losing control of our folder naming scheme, which I think is a big enough downside. Basically we have to decide whether we accept tradeoffs to support composite builds - given that these bugs have been long-standing within Gradle, my inclination is not to support them. Publishing to maven local tends to work well enough for those times when doing cross-repo development, which I don't think happens that much anymore. While we theoretically can apply this pattern to the instrumentation repo, I'm pretty sure we wouldn't. I think compared to this repo, there it's just way too big of a regression compared to our current, at least IMO, easy to understand structure of three folders per instrumentation clearly being subcomponents of that project. Currently 99% of the build logic is shared among the repos and I'm interested in publishing a Gradle plugin soon so we can actually use just one source for them. This change I honestly expect to toss a big wrench into that, unless we really do apply the naming to the instrumentation repo, which seems like a loss. I am -1 for this still, but wouldn't block if there are enough votes otherwise and someone is committed to applying the pattern across the three repos. @trask @jkwatson please share your thoughts :) |
I'm against this change unless there is a really compelling reason for it. I haven't heard a very compelling reason articulated as of yet. |
As an alternative to this, there is also the possibility to declare substitutions in the consuming project: https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions
The alternative conclusion that nobody changes the artifact ID, so nobody is affected by this limitation would be just as valid. At Dynatrace we use composite builds extensively for our larger repositories. Maybe changing just the JAR name but not including |
What about keeping the folder structure but changing project names? Not artifacts names/coordinates, but sub-projects names? Just an idea, I haven't tried it. |
That's already what is being done here. The issue @anuraaga has are the task names, not the folder names, as far as I understand. |
Keeping folder names the same as the task path is the #1 priority. It's the only thing I would try to block regardless of a vote - it's just too confusing to know how to run commands if you can't trust the folder structure. This repo started with that, it was so hard. The scheme I am still fairly receptive to is a 100% flat structure - all project folders are at the top level. I think it's possible to apply to this repo, but I think it's impossible to apply to the instrumentation repo because our artifact names do not sort well alphabetically there, and we have tons of unpublished projects. Nor should they have to - this is a Gradle bug a PR to fix Gradle would have no tradeoffs :-D |
BTW filed gradle/gradle#18291 |
I agree that this is desirable. This PR only lets them diverge because you would otherwise have 1070 renamed files to review and the GH UI becomes very slow (see earlier PR versions). |
Yup I got that, this repo by itself we could then converge in the next PR on just the flat structure. I don't think it scales to repos like the instrumentation repo though - because we have such repos (large monorepos) we should take it into account. Loosing consistency among the repos is of course an option - but as possibly the only one who is proactive in all three it would be quite painful for me. |
Whatever happens here, we must not change the artifact names or maven coordinates of anything that we have marked stable at this point. |
Doesn't look like a gradle-side solution is coming 😕 gradle/gradle#18291 was closed as duplicate of the very old gradle/gradle#847. If the main concern is gradle task names, maybe a task rule could be used to dispatch tasks like |
Actually, I now learned that there is a way to solve my original problem in open-telemetry/opentelemetry-java-instrumentation#3626. Yes, automatic mapping of included project's modules to maven coordinates does not work for our repos atm. But you can manually specify dependency substitution rules as in https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4179/files#diff-0b68cb406e55a2431167c05be6ceb1c7e64c13ef9f460dc0b9c80cc860a2ea7d. It's not ideal, but it works. |
How does this |
|
OK, so you basically have to spell out for gradle what the publish configuration does in a different format. |
If we have just to strip |
We also have to replace the group and sometimes change singular to plural and I think for nested exporter packages you might need special handling. I was more thinking of doing this as part of the publish-conventions plugin, having a task that depends-on everything published that then can access the final publish configuration. You can see that the mapping I do from project names to paths currently in settings.gradle is not reversible (since I try both prefix and singularPrefix) |
Closing this one as there seems to be no realistic chance of it getting merged (especially after #3653). Maybe if something improves on the Gradle-side this would become interesting again. |
Instead of using tricks to be able to use shorter project names, just name the folders like we want the final published artifact to be named.
This should enable composite builds to use opentelemetry-java without hassle, but I'm currently still verifying this (there seems to be an issue with the substituted bom or similar).
Prerequisite for open-telemetry/opentelemetry-java-instrumentation#3626 (CC @iNikem)