-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add an Automatic-Module-Name manifest entry #1079
Comments
This sounds fine to me. I presume that we'll probably want the module names to match the maven artifact names?
etc. @netdpb WDYT? |
Package name seems more appropriate since it's agnostic to build system and
modules deal in exposing of packages.
…On Sun, Mar 4, 2018, 10:59 PM Ron Shapiro ***@***.***> wrote:
This sounds fine to me. I presume that we'll probably want the module
names to match the maven artifact names?
- com.google.dagger
- com.google.dagger.compiler
- com.google.dagger.producers
- com.google.dagger.android
- com.google.dagger.android.support
etc.
@netdpb <https://github.com/netdpb> WDYT?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1079 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEak9rj_DO5SCnhWxtknsUuXzt722ks5tbLgxgaJpZM4SScow>
.
|
To get this issue going, since it can be solved by a single line of configuration: I don't know how to configure bazel builds, but apparently there is this However, this argument doesn't exist for the java_library rule, which wouldn't make too much sense. Probably just bad documentation? |
Currently the build uses @iirina wrote:
Also To summarize bazel doesn't support custom As a workaround we could use |
@ronshapiro FYI currently without the
Because of that maven build outputs following message:
Seems like this autogenerated module name ( Java SE 9 - JPMS module naming |
As per the blog, the module name for each jar file is generally the root package name of the jar file. At a quick glance that would appear to be |
Could any of the decision-making contributors suggest / choose a solution?
Seems like (2) won't be accepted in bazel, (3) is stalled and adding the functionality in bazel is non trivial (core contributors didn't figure out yet how to implement it). Also (3) will require major changes in the |
Dagger already uses jarjar to create the Maven artifact. We can use or modify that to append to the MANIFEST.MF file. |
At the moment However the one that we are interested in is deployed directly:
Even if we would process it with jarjar it wouldn't help because it doesn't support manifest merging. Instead
Again we have few options here:
BTW @netdpb I guess I understand now how you came up with this idea :) |
Short-term, I think we'll want to go with option 2. |
Haha, yes. I should get back to that unfinished work.
…On Mon, Mar 9, 2020 at 12:50 PM Grzegorz Nowak ***@***.***> wrote:
At the moment jarjar_library is used for generation of
shaded_grpc_server_processor and shaded_android_processor here
<https://github.com/google/dagger/blob/master/BUILD#L56>.
However the one that we are interested in is deployed directly
<https://github.com/google/dagger/blob/master/util/execute-deploy.sh#L151>
:
deploy_library \
java/dagger/libcore.jar \
Even if we would process it with jarjar it wouldn't help because it doesn't
support manifest merging
<https://github.com/pantsbuild/jarjar/blob/master/src/main/java/org/pantsbuild/jarjar/ManifestProcessor.java#L34>.
Instead jarjar_library rule uses inlined bash script
<https://github.com/google/bazel-common/blob/master/tools/jarjar/jarjar.bzl#L36>
to do that:
# Concatenate similar files in META-INF that allow it.
mergeMetaInfFiles=(services/.* {merge_meta_inf_files})
for metaInfPattern in ${{mergeMetaInfFiles[@]}}; do
for file in $(find META-INF -regex "META-INF/$metaInfPattern\\(~[0-9]*\\)?"); do
original=$(echo $file | sed s/"~[0-9]*$"//)
if [[ "$file" != "$original" ]]; then
cat $file >> $original
rm $file
fi
done
done
Again we have few options here:
1. Extend jarjar to properly support manifest merging and
customizations. Update bazel build rule in the process. Not sure which one
though (google's <https://github.com/google/jarjar>, pants'
<https://github.com/pantsbuild/jarjar> or shevek's
<https://github.com/shevek/jarjar>. (The last one seems the most
updated)
2. Update jarjar_library rule to support additional attribute -
manifest file which will be merged with the ones extracted from input jars.
BTW @netdpb <https://github.com/netdpb> I guess I understand now how
<https://github.com/google/bazel-common/blob/master/tools/jarjar/jarjar.bzl#L25>
you came up with this idea :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1079?email_source=notifications&email_token=ABA3LSPK4BLTFWWN2B6MTWLRGUM5JA5CNFSM4ESJZIYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOIBZFA#issuecomment-596647060>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABA3LSMUA5LNC3HR2DXC2C3RGUM5JANCNFSM4ESJZIYA>
.
|
Any progress on this? :-) |
Yeah, I think we still need to decide on module names. Based off #1079 (comment), it seems like Going through each of our artifacts, I've listed the likely java module names in the table below. If these seem reasonable, I can try to add these to the META-INF as suggested in #1079 (comment)
|
Just something to bear in mind is that you can't have two modules with the same name loaded at the same time. The list above suggests you have split packages, where the same package appears in two different jar files. If that is the case, then you can't really modularise as is. (The exception to that rule is if the user is expected to choose one of the artifacts, eg one of"dagger-android-jarimpl", "dagger-android-legacy" or "dagger-android-processor".) |
Right, but the most critical is com.google.dagger:dagger, as that is the primary interface to other modules. Once that has a stable name, people can start publishing components referring to it. |
@rovarga it's not that simple. Once a project claims a module name, it's responsible for its contents and compatibility. If dagger is too eager, it may cause split package problem which will be hard to solve. Most of the projects from pre-JPMS era will require some API package refactoring to solve this, meaning major version release. |
@metteo True, but that needs analysis of whether com.google.dagger:dagger split packages against all the others. If it does not, it is fine. |
Any progress on this? |
Took another look at this and I think what might make sense is for us to add the automatic name entry in just the main dagger artifact to claim the module name I'll work on adding this entry assuming that sounds reasonable. |
Fixes #1079. RELNOTES=Added an automatic module name to the Dagger artifact PiperOrigin-RevId: 372615769
Now, that Dagger runs with JDK 9 (as issue #880 is resolved), it might be time to look forward to JPMS compatibility.
In a first step I'd suggest to add a
Automatic-Module-Name
entry to the jar manifest. This way other libraries depending on Dagger can be published to Maven Central or other repositories. Without it, the automatic module name would be derived from the Dagger .jar file and as such is pretty unreliable.This proposed change doesn't affect any code and will simply make a name reservation until an actual
module-info.java
will be added eventually. More info can be found in this blog post.The text was updated successfully, but these errors were encountered: