You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "dmlloyd (via GitHub)" <gi...@apache.org> on 2026/01/14 20:31:59 UTC

[I] Add easy support for automatic module name [maven-jar-plugin]

dmlloyd opened a new issue, #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520

   ### New feature, improvement proposal
   
   It would be nice if there was a configuration property to easily set the automatic module name of a JAR, since this is a very frequent activity when migrating projects to use modules. It should print a warning (and do nothing) if a module descriptor is found in the project.
   
   I have a patch to do this, which I will propose in a PR forthwith.
   
   Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "dmlloyd (via GitHub)" <gi...@apache.org>.
dmlloyd commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4708606538

   There are many things that should not, as a matter of principle, be set from the command line. However, the ability to do so in this case is a merely side-effect of allowing the use of a property to configure the name. Every POM (that I work with at least) declares properties. I should be able to declare my automatic module name among them, for maximum simplicity and clarity (the user should not have to dig down into build config to know what the automatic module name is). This only takes one additional line for the user, *and* doesn't interfere with the configuration of other unrelated manifest properties.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4716337914

   Note: if I remember right, the class that defines the `<archive>` element is outside the Maven JAR Plugin. I think it is in some shared library (maybe Maven Archiver). It makes this change less easy to do. An easier approach may be to do this change after #508 is merged instead (if 508 is accepted). The latter is a rewrite of the JAR plugin but using `java.util.spi.ToolProvider` instead of Maven Archiver. The definition of `<archive>` could easily be migrated in the JAR plugin after 508, thus making easier to add elements.
   
   508 is waiting only for Maven 4.0.0-rc6 before it can be submitted. We will need to resolve conflicts caused by commits added since the time when 508 was created, but it should be all.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4712802276

   Module name in `MANIFEST.MF` file is indeed a different thing that module name on `module-info.java`. As @dmlloyd said, it is a compromise created by Oracle for allowing a gradual transition for projects that are not yet able to provide a real `module-info.java`.
   
   In my understanding, the root of the problem is that a mechanism already exists in Maven 3, but it does not work well with properties. While setting module name on the command line is not something that I would like to encourage, using properties is nevertheless possible in Maven for all sort of configuration, and we could expect `MANIFEST.MF` configuration in general (including automatic module name) to work with properties too. I would like to clarify what are the impediment in using properties for configuring tħe `MANIFEST.MF` file.
   
   As said in my previous comment, I would prefer to either fix the current `<manifestEntries>` way rather than introducing a new way, or if a new way is necessary, to put it into the existing `<manifest>` element rather than creating a new element having its own independent existence.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "dmlloyd (via GitHub)" <gi...@apache.org>.
dmlloyd commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4712821488

   > As said in my previous comment, I would prefer to either fix the current `<manifestEntries>` way rather than introducing a new way, or if a new way is necessary, to put it into the existing `<manifest>` element rather than creating a new element having its own independent existence.
   
   Should `<detectMultiReleaseJar>` also be in the same boat then and be reevaluated? I modeled this change after that one.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4701551583

   I don't think the automaticModuleName should be set from the command line. Setting it from the pom is more reliable and reproducible. I'm very tempted to close this one as won't do. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4702671799

   I also believe that the module name needs to be stable and predictable for the users of the JAR, and therefore that we should encourage the declaration of module name in a versioned file. If not in `module-info.java`, then at least in the `pom.xml` file.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "dmlloyd (via GitHub)" <gi...@apache.org>.
dmlloyd commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4712722644

   > I'm not convinced this should ever be set by anything other than module-info.java but even if it should there would have to be another other way to do this.
   
   Are you saying that you don't understand what automatic modules are? There's some good reading about them here: https://stackoverflow.com/questions/46741907/what-is-an-automatic-module
   
   They're a critical migration step and Maven should have a way to easily define them. I think your given standard - that things should be *forbidden* from being properties on the basis of not wanting users to set them from the command line - is unreasonable, and is also violated many many times over by nearly every parameter in nearly every standard Maven plugin, most of which should definitely not *normally* be command-line settable. I don't think it makes sense to have _my_ change, small as it is, be ground zero for introducing some new policy though.
   
   But even if your standard were somehow arguably reasonable, it would be far more appropriate to suggest another mechanism for it (assuming you have a better idea), than to unilaterally close the issue and PR with just a few vague bits of opinionated feedback. Surely you understand the importance of improving modularity support in Maven. This is poor maintainer behavior no matter how you slice it, and I hope you reflect on that and reconsider.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-3756760280

   The current plugin allows the following:
   
   ```xml
   <configuration>
     <archive>
       <manifestEntries>
         <Automatic-Module-Name>org.foo.bar</Automatic-Module-Name>
       </manifestEntries>
     </archive>
   </configuration>
   ```
   
   The pull requests #521 and #522 would allow to get the same result with the following, except for the warning when a `module-info.class` is present:
   
   ```xml
   <configuration>
     <automaticModuleName>org.foo.bar</automaticModuleName>
   </configuration>
   ```
   
   This is admittedly shorter, but is it worth to have two places for configuring the same attribute in the plugin configuration?
   
   If, nevertheless, there is a desire to handle the `Automatic-Module-Name` attribute in a special way, if we want to be consistent with other attributes that are handled in a special way such as `Main-Class`, then the attribute would need to be added in `org.apache.maven.shared.archiver.ManifestConfiguration`. The XML fragment would become like below:
   
   ```xml
   <configuration>
     <archive>
       <manifest>
         <automaticModuleName>org.foo.bar</automaticModuleName>
       </manifest>
     </archive>
   </configuration>
   ```
   
   Note that this is not really shorter than the existing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "dmlloyd (via GitHub)" <gi...@apache.org>.
dmlloyd commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-3761642065

   All your points are valid; my goal however isn't (only) less typing. I want to be able to supply an automatic module name using a just build property, e.g. `-Dmaven.jar.automaticModuleName=org.foo.myproject` (or more likely, a value at the top of my POM).
   
   This cannot really be done in the obvious way with the archiver configuration because IIUC if a property expression has an empty value, then the value will be an empty string, causing an empty `Automatic-Module-Name` property to be added to the manifest.
   
   (That said, I see I ironically forgot to account for the empty string in my PRs, so I'll fix that now.)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4712926269

   > Should `<detectMultiReleaseJar>` also be in the same boat then and be reevaluated? I modeled this change after that one.
   
   Good question. I don't know what was the rational at that time, but maybe it was because `<detectMultiReleaseJar>` does not control directly the `Multi-Release: true` attribute in `META-INF.MF` since Maven makes its own decision based on auto-detection. Also in principle, the effect is wider than only the `MANIFEST.MF` file because the JAR plugin should add the `*.class` files for other versions using the `--release` option (I'm not sure that the current plugin does that, but it should for allowing the `jar` tool to perform additional checks).
   
   By contrast, the `<mainClass>` element inside `<manifest>` should have an effect strictly limited to the `META-INF` file. I suggest to model an `<automaticModuleName>` on that instead.
   
   Note: if you decide to create a new pull request or edit the existing one, I suggest to target only the `master` branch instead of creating two pull requests for the two branches. It improves the chances that the discussion happens in one place, and the pull request created after the merge on master can be clearly identified as a backport.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on issue #520:
URL: https://github.com/apache/maven-jar-plugin/issues/520#issuecomment-4712573744

   I think this one is a no-go for now. It doesn't feel right to allow this to be set from the command line. In this case that means this should not be a property. I'm not convinced this should ever be set by anything other than module-info.java but even if it should there would have to be another other way to do this. This approach has  too strong a downside. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Add easy support for automatic module name [maven-jar-plugin]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo closed issue #520: Add easy support for automatic module name
URL: https://github.com/apache/maven-jar-plugin/issues/520


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org