You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "laeubi (via GitHub)" <gi...@apache.org> on 2026/08/15 10:43:22 UTC

[I] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   ### New feature, improvement proposal
   
   Currently the jar goal mixes effectively two things:
   
   1. Generation of descriptors (controlled by `addMavenDescriptor`) and a Manifest (with possibly customization like `manifestEntries` and `manifestFile`)
   2. the actual packaging of things into a physical jar file (e.g `compress` option)
   
   This has some limitations that surface at different levels:
   
   - Tools like bnd / felix-bundle-plugin / Tycho can't intercept without special configurations
   - There is no way to generate the metadata files to be used elsewhere (e.g. in an IDE - m2e uses reflection to only call the generation part of the mojo and not package a full jar) or further processed
   
   If there where split into different mojos (e.g. one `generate` and one `jar` mojo) it would be possible to bind the first to the `prepare-package` and the later to the `package` phase allowing other plugins to further customize/use the data before it is being packed.
   
   Since Maven 4 even allows interleaving phases this could then even be more flexible, e.g. another plugin that only needs the manifest data but not necessarily the full packaged physical jar could use this before the heavy weight jar packaging happens. It would also be a good time to do a major release with that change tailored to Maven 4.


-- 
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] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   That sounds interesting but also brittle (as one has to replicate the jar tool then). I think one good thing already is that with that change it would use the manifest from `target/classes` but still wondering if "generate the manifest" and "package it into a zip file with jar extension" should be two dedicated steps what would make this much more "maven like".


-- 
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] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   Indeed, preparing a `MANIFEST.MF` file could be bound to the already existing (but ignored by current JAR plugin) `prepare-package` phase.


-- 
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] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   > Indeed, preparing a `MANIFEST.MF` file could be bound to the already existing (but ignored by current JAR plugin) `prepare-package` phase.
   
   Just for completeness this would affect MavenDescriptor as well .. what currently is mangled into the jar goal as well. If one would be really maven-purist (a mojo should only do one job at a time) it would result in:
   
   - `jar:generate-descriptor` (default phase `prepare-package`)
   - `jar:generate-manifest` (default phase `prepare-package`)
   - `jar:jar` (default phase `package`)


-- 
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] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   Still it would be rather cumbersome to let users reconfigure the toolId (+ raises the question where the tool would come from -> likely more configuration).
   
   Just think about how it works for a compiler, you can plug any custom processing/generation to `process-classes` phase and then compiler just produces the bytecode.
   
   Similar here, if the generation of the manifest is bound to `prepare-package` one can easily intercept/process further before `package` phase takes everything and put it into a (binary) jar.


-- 
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] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   With #508, one possible approach would be to use the new `toolId` field which has been added as a side effect of that work. If this field is set to a non-null value, the plugin searches for a `java.util.spi.ToolProvider` implementation of that name. Alternatively, Eclipse (for example) could also override the `AbstractJarMojo.getJarTool()` method and returns directly their own `ToolProvider` instance.
   
   The plugin invokes `ToolProvider.run(in, out, args)` where `args` is all arguments given to the tool. Therefore, a `ToolProvider` implementation could, for example, search for the `--manifest` option and do its own stuff with the `MANIFEST.MF` file instead of generating the JAR 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] [idea] split the jar goal into two mojos that can be bound to different phases [maven-jar-plugin]

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

   > That sounds interesting but also brittle (as one has to replicate the jar tool then).
   
   I thoug that, if someone is interested only in `META-INF.MF`, it could only search for the `--manifest` option and ignore the rest. If it is interested in both `META-INF.MF` and generating the JAR, then it could search for the `--manifest` option, modify it if it wants, then forward everything to the standard `jar` tools. The `ToolProvider` contains basically only a `run` method, so this is only one method to define.


-- 
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