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

Introduce automatic module names into all libraries being built. #781

Merged
merged 3 commits into from
Jan 23, 2020
Merged

Introduce automatic module names into all libraries being built. #781

merged 3 commits into from
Jan 23, 2020

Conversation

JonathanGiles
Copy link
Contributor

This is a proposal to fix #691, by adding automatic module names into the built manifest.mf files that ship within the jar files for each library. These names are all proposals and I am happy to change them as you suggest. Thanks.

Fixes #691

@codecov-io
Copy link

codecov-io commented Jan 22, 2020

Codecov Report

Merging #781 into master will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #781      +/-   ##
============================================
- Coverage     78.58%   78.55%   -0.04%     
+ Complexity      778      777       -1     
============================================
  Files           101      101              
  Lines          2779     2779              
  Branches        268      268              
============================================
- Hits           2184     2183       -1     
- Misses          493      494       +1     
  Partials        102      102
Impacted Files Coverage Δ Complexity Δ
...elemetry/opentracingshim/SpanContextShimTable.java 89.28% <0%> (-7.15%) 7% <0%> (-1%)
...elemetry/sdk/trace/export/BatchSpansProcessor.java 89.65% <0%> (+0.86%) 7% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd4f373...d93c716. Read the comment docs.

@jkwatson
Copy link
Contributor

jkwatson commented Jan 22, 2020

Is there any gradle magic we can do so we don't have repeat that jar section in every build.gradle? Some top level allSubModules thing, maybe?

@JonathanGiles
Copy link
Contributor Author

I wondered the same thing. My Gradle these days is weak, so I was hoping someone else had guidance, otherwise I'll go and research.

@carlosalberto
Copy link
Contributor

It should be possible to re-use this part, although I don't remember myself now the specifics. Once you do this, we should be able to merge this PR.

@jkwatson
Copy link
Contributor

Also, please sign the CLA. :) Thanks very much for the contribution!

@JonathanGiles
Copy link
Contributor Author

I did sign the CLA today, not sure how long it takes to update...

@jkwatson
Copy link
Contributor

You might need to add a comment saying "I signed it"

@JonathanGiles
Copy link
Contributor Author

I signed it

@jkwatson
Copy link
Contributor

Guess not. Sometimes that kicks the CLAbot into action

api/build.gradle Outdated
manifest {
attributes 'Automatic-Module-Name': moduleName
}
}
Copy link

Choose a reason for hiding this comment

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

Missing empty newline at the end of these.

Copy link
Member

Choose a reason for hiding this comment

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

Please fix this everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added an empty new line to the root build.gradle, as it did not have one (prior to my involvement). All other files no longer have been touched at the end of the file, so they remain as they were.

Copy link
Member

@thisthat thisthat left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution :)
I think we can group all these changes in the main build script. We could modify the jar.manifest section to:

jar.manifest {
        ext.moduleName = "io." + project.name.replaceAll("-",".")
        attributes('Implementation-Title': name,
                'Implementation-Version': version,
                'Automatic-Module-Name': moduleName,
                'Built-By': System.getProperty('user.name'),
                'Built-JDK': System.getProperty('java.version'),
                'Source-Compatibility': sourceCompatibility,
                'Target-Compatibility': targetCompatibility)
}

But I am not sure if "io." + project.name.replaceAll("-",".") does all the magic correctly

@JonathanGiles
Copy link
Contributor Author

I think we should centralise it but still explicitly set the module names. From my experience doing it as you suggest tends to lead to... Surprises after it is too late. But happy to follow consensus...

@thisthat
Copy link
Member

With a quick test, I see that there is some difference between package structure and module name. Therefore, I agree with you that setting explicitly the module names is a better strategy on the long term.

@JonathanGiles
Copy link
Contributor Author

I managed to centralise the configuration into the root build.gradle. Please take another look and let me know of any further concerns. Thanks.

@carlosalberto
Copy link
Contributor

LGTM.

@@ -1,4 +1,5 @@
description = 'OpenTelemetry API'
ext.moduleName = "io.opentelemetry.api"
Copy link
Member

Choose a reason for hiding this comment

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

we don't have "api" in the package names, does that matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it doesn't matter. Module names do not need to relate to the package name, although they are a good starting point for choosing a good module name.

@bogdandrutu bogdandrutu merged commit ecad860 into open-telemetry:master Jan 23, 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.

Support JDK 9 modules
7 participants