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

add Automatic-Module-Name to JAR #85

Merged
merged 2 commits into from
Jul 22, 2021

Conversation

mattnworb
Copy link
Member

If the JAR for this repo is used in a project where the module system is
active, Java treats any "plain JAR" without a module descriptor as an
"automatic module" and allows it to be used by other modules in the
application.

For instance, a module in an application using JPMS can depend on this
project like

module com.mattnworb.jpms {
  requires com.spotify.completablefutures;
}

Defining an Automatic-Module-Name allows for explicitly controlling
the name that modules use when loading your automatic module, rather
JPMS guessing at the automatic module name for the JAR based on the
JAR's filename.

Alternatively we could add a module-info.java to this project to
enable it to be loaded as a regular (not automatic) module but that
would also require increasing the compiler target from 8 to 9.

Closes #82

If the JAR for this repo is used in a project where the module system is
active, Java treats any "plain JAR" without a module descriptor as an
"automatic module" and allows it to be used by other modules in the
application.

For instance, a module in an application using JPMS can depend on this
project like

```
module com.mattnworb.jpms {
  requires com.spotify.completablefutures;
}
```

Defining an `Automatic-Module-Name` allows for explicitly controlling
the name that modules use when loading your automatic module, rather
JPMS guessing at the automatic module name for the JAR based on the
JAR's filename.

Alternatively we could add a `module-info.java` to this project to
enable it to be loaded as a regular (not automatic) module but that
would also require increasing the compiler target from 8 to 9.

Closes #82
@mattnworb
Copy link
Member Author

I was curious to learn more about JPMS so when I saw the related issue I thought it would be a good excuse to finally do that :)

@mattnworb mattnworb requested review from spkrka and mbruggmann July 21, 2021 19:13
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.spotify.completablefutures</Automatic-Module-Name>
Copy link
Member

Choose a reason for hiding this comment

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

Knowing nothing about JPMS: The package name in use is com.spotify.futures. Should they match?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems like that is the convention but not required, but I figured we'd have a conflict if we ever did the same thing in https://github.com/spotify/futures-extra which has the same package name.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

oh nice, I did not realize there was a proper module-info there already

@mattnworb mattnworb merged commit 5a46ba2 into master Jul 22, 2021
@mattnworb mattnworb deleted the mattbrown/jpms-automatic-module-name branch July 22, 2021 15:10
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.

Provide a module descriptor for usage with JPMS
3 participants