Repository navigation
Conversation
781c931 to
07738af
Compare
|
This PR removes Option A — Merge as-is (inline, plugin-local) Option B — Rework maven-archiver for Maven 4 Option C — New shared manifest library (no plexus-archiver) Options B and C are only worth the effort if we expect multiple plugins to converge on Maven 4 in the near term; otherwise Option A avoids premature abstraction. If the consensus is Option A, this PR is ready (modulo the open review comments). If B or C, it makes sense to prototype the shared layer first and rebase this on top. What's the preferred direction? |
07738af to
d3edc35
Compare
|
I suggest to start with option A with amendments: Make the new classes package-private, so that they cannot be used outside the Maven JAR plugin (no committed API). Then simplify this pull requests by removing all getters/setters in It will be possible to switch to option C later, when it will appear useful. At that time, we may have more information about what would be the best strategy. I'm a big fan of Joshua Bloch's golden rule of API design "in case of doubt, leave it out". |
d3edc35 to
7a26269
Compare
|
Thanks Martin. The intent is fully aligned — package-private with direct field access is exactly the right design for an implementation-internal class. However, there's a practical blocker: even in Maven 4 API plugins, the mojo parameter configurator is still I've opened apache/maven#13459 to track this for 4.1.0 — the ask is that the configurator for Maven 4 API plugins either calls For now I'll keep |
2a057b6 to
5ff0509
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Solid dependency removal — inlining the manifest-building logic from maven-archiver and plexus-archiver cleanly cuts two transitive deps. The implementation is clear and well-structured. A few issues to address:
Summary of findings:
- Dead code —
asList()inManifestBuilderis unused (line 372);AbstractJarMojohas its own copy at line 354. - Stale
@link—ManifestConfiguration— the referenced class does not exist; the actual class isArchiveConfiguration.ManifestConfig. - Loop-invariant computation —
resolveLayout()at line 268 is called on every iteration but its three inputs never change inside the loop. - Stale
@link—MavenArchiver#getManifest—MavenArchiveris removed from the classpath in this PR, so the Javadoc link is dangling. - Missing unit tests —
ManifestBuilderandArchiveConfigurationare ~760 lines of new logic with zero dedicated test coverage.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Replace MavenArchiveConfiguration/MavenArchiver with local ArchiveConfiguration and ManifestBuilder classes. ManifestBuilder inlines the manifest generation logic from MavenArchiver.getManifest(), using: - java.util.jar.Manifest directly (no plexus types) - org.apache.maven.api.services.Interpolator for classpath layout interpolation (replaces plexus-interpolation) - Inlined BuildHelper.discoverJavaRelease() (pure Maven API) ArchiveConfiguration replaces MavenArchiveConfiguration with inner ManifestConfig and ManifestSection classes matching the same plugin parameter XML structure.
5ff0509 to
6949b2a
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Thanks for the PR — the new ManifestBuilder is a nice cleanup that removes the maven-archiver/plexus-archiver dependency.
A few items to address before merging:
This review was generated by an AI agent, Hermès on behalf of @gnodet.
- Fix stale @link: ManifestConfig#isAddBuildEnvironmentEntries() does not exist (bare field, no getter); use field reference instead - Add null/empty name guard in manifest section loop to prevent NPE at Manifest.getEntries().put(null, attrs) when <name> is missing - Add ManifestBuilderTest covering: Build-Jdk-Spec presence/absence, extra entry precedence and sanitization, null/empty section name guard, Manifest-Version, and Created-By defaults
gnodet-bot
left a comment
There was a problem hiding this comment.
Thanks for the new ManifestBuilder and ArchiveConfiguration — a clean removal of the maven-archiver/plexus-archiver dependency chain. A few notes on the new code:
Build-Jdk-Spec is now absent by default
In maven-archiver, Build-Jdk-Spec was included in the default addDefaultEntries path (controlled by a flag that defaulted to true). In this implementation, AbstractJarMojo always calls setBuildJdkSpecDefaultEntry(archive.getManifest().addBuildEnvironmentEntries), and addBuildEnvironmentEntries defaults to false. So Build-Jdk-Spec will no longer appear in manifests for users who have never set <addBuildEnvironmentEntries>. This is a user-visible behavioral difference from the previous version and should be documented in the migration notes / changelog.
buildClasspath() has no unit test coverage
The buildClasspath method contains non-trivial interpolation logic across three layout types (simple, repository, custom), unique-versions handling, prefix prepend, and user Class-Path merge. The previous review explicitly requested test coverage for this path. The new ManifestBuilderTest covers Build-Jdk-Spec, extra entries, and manifest sections — but there are no tests for classpath generation. Even basic unit tests (simple layout, repository layout, user-supplied Class-Path prefix) would significantly reduce regression risk.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
…sleading test, add classpath tests - ManifestBuilder: move null/empty name guard before building Attributes object in manifest section loop (fail-fast, no needless allocation) - ManifestBuilderTest: rename buildJdkSpecPresentByDefault to buildJdkSpecPresentWhenFieldDefaultIsTrue with a comment clarifying this tests the field-level default, not production behaviour (which AbstractJarMojo always overrides to false via addBuildEnvironmentEntries) - ManifestBuilderTest: add classpath unit tests via SessionWithServices stub that vends inline DependencyResolver and Interpolator stubs: * classpathSimpleLayout — simple layout with useUniqueVersions=true * classpathRepositoryLayout — repository layout (groupId path) * classpathWithPrefix — classpathPrefix prepended to each entry
gnodet-bot
left a comment
There was a problem hiding this comment.
Good progress — the classpath test coverage (classpathSimpleLayout, classpathRepositoryLayout, classpathWithPrefix) addresses the previous request, and the commit message clarification about the Build-Jdk-Spec field default is appreciated.
Two site documentation issues remain:
1. Stale ${mavenArchiverVersion} Velocity variable in usage.md.vm
Line 34 still links to /shared/maven-archiver/ and lines 37–38 read:
This version of the Maven JAR Plugin uses Maven Archiver ${mavenArchiverVersion} to handle manifest configuration.
The <mavenArchiverVersion> POM property was removed by this PR — ${mavenArchiverVersion} will render as a literal string on the generated site. This section needs to be updated or removed.
2. Stale Maven Archiver references across site documentation
Several site pages still describe Maven Archiver as an active dependency:
src/site/markdown/index.md(lines 57–58): "The plugin uses Maven Archiver to handle manifest configuration"src/site/faq/faq.md(lines 34–35): "defined by the Maven Archiver library"src/site/markdown/manifest-customization.md.vm(lines 32, 36, 43): three links to Maven Archiver examplessrc/site/site.xml(lines 35, 37): sidebar links to Maven Archiver examples
None of these files are modified in this PR. Since maven-archiver is being removed as a dependency, these references should be updated to point to the new ArchiveConfiguration/ManifestBuilder docs, or removed.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
The maven-archiver dependency has been removed in this PR. Update all
site documentation that still linked to or described Maven Archiver:
- usage.md.vm: drop stale archiver link and ${mavenArchiverVersion}
variable; update last-line executable JAR link to local example
- index.md: rename section to 'Archive Configuration'; replace Maven
Archiver prose with ManifestBuilder/ArchiveConfiguration description
- faq.md: rewrite archive-parameter answer in terms of ArchiveConfiguration
- manifest-customization.md.vm: replace three Maven Archiver links with
local ManifestBuilder description and plugin-info reference
- site.xml: remove two Maven Archiver sidebar entries
('Creating an Executable JAR File' and 'Using Your Own Manifest File')
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all 9 previous findings have been addressed. The docs cleanup in this commit is solid with one inaccuracy.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Built-By and Build-Jdk-Spec are only included when addBuildEnvironmentEntries is true (default: false). Only Created-By (and Java-Version when discoverable) are present by default.
gnodet-bot
left a comment
There was a problem hiding this comment.
Previous finding addressed — the doc inaccuracy about default manifest attributes is now correct.
The new commit fixes the one remaining issue from my last review: Built-By and Build-Jdk-Spec are now correctly described as conditional on addBuildEnvironmentEntries, with only Created-By (and Java-Version when discoverable) listed as defaults. ✅
LGTM. No further issues.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
There was a problem hiding this comment.
🟡 Changes recommended
Configuration compatibility, classpath normalization, and manifest metadata regressions remain unresolved.
4 open issues
What changed in this PR
Moves manifest generation into the plugin, removing Maven Archiver and Plexus Archiver while retaining JDK jar packaging.
Changes:
- Adds local archive configuration and manifest-building classes.
- Updates packaging integration and adds unit tests.
- Replaces external archiver documentation with plugin-specific guidance.
| File | Description |
|---|---|
src/test/java/org/apache/maven/plugins/jar/ManifestBuilderTest.java |
Tests manifest attributes, sections, and classpaths. |
src/test/java/org/apache/maven/plugins/jar/ArchiveConfigurationTest.java |
Tests configuration defaults and containers. |
src/site/site.xml |
Removes external archiver example links. |
src/site/markdown/usage.md.vm |
Updates manifest configuration guidance. |
src/site/markdown/index.md |
Describes plugin-owned manifest generation. |
src/site/markdown/faq.md |
Updates archive configuration references. |
src/site/markdown/examples/manifest-customization.md.vm |
Adds configuration tables and examples. |
src/main/java/org/apache/maven/plugins/jar/ToolExecutor.java |
Uses the local archive configuration. |
src/main/java/org/apache/maven/plugins/jar/MetadataFiles.java |
Adapts metadata generation to the replacement type. |
src/main/java/org/apache/maven/plugins/jar/ManifestBuilder.java |
Implements manifest generation and classpath interpolation. |
src/main/java/org/apache/maven/plugins/jar/ArchiveConfiguration.java |
Defines local archive configuration types. |
src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java |
Integrates the new manifest builder. |
pom.xml |
Removes archiver dependencies and adds Maven XML API. |
Review effort: Balanced
…rmalization, specificationVersion, packageName/addExtensions Addresses issues raised in Copilot review: 1. addBuildEnvironmentEntries: restore Build-Tool (Apache Maven <version>), Build-Os (os.name, version, arch), and the full Build-Jdk format (java.version + vendor in parentheses), matching maven-archiver behaviour. 2. classpathPrefix normalization: replace backslashes with forward slashes and add a trailing '/' automatically when absent, preventing '<classpathPrefix>lib</classpathPrefix>' from producing 'liblib-a-1.0.jar' instead of 'lib/lib-a-1.0.jar'. 3. specificationVersion(): avoid producing an invalid trailing-dot string (e.g. '1.' for version '1.foo'); only append a dot if the next character is also a digit. 4. ArchiveConfiguration.ManifestConfig: add 'packageName' field (generates the Package manifest attribute) and 'addExtensions' field (accepted for compatibility with maven-archiver; no-op in this implementation). Documentation and unit tests updated accordingly.
the component has to be extracted, no choice: yes, this PR is a learning experience, but merging it is a no go |
CLASSPATH_LAYOUT_TYPE_REPOSITORY and CLASSPATH_LAYOUT_TYPE_CUSTOM were only used internally in resolveLayout() and were not more readable than the literal strings. Inline them as per @elharo's suggestion. CLASSPATH_LAYOUT_TYPE_SIMPLE is kept as it serves as the default value in ArchiveConfiguration.
gnodet-bot
left a comment
There was a problem hiding this comment.
Re-review after commits db18fba–e723df12.
All prior findings from my previous reviews are resolved. The Oct 18 commits address elharo's feedback:
- ✅
JAVA_VERSION,BUILD_JDK_SPEC,BUILD_JDK,BUILT_BYconstants inlined (c59169c) - ✅
k→normalizedKey,c→classifierrenamed (bb940cd) - ✅
CLASSPATH_LAYOUT_TYPE_REPOSITORYandCLASSPATH_LAYOUT_TYPE_CUSTOMinlined to string literals (e723df1) - ✅ Deprecated
Implementation-Vendor-IdandImplementation-Urlattributes dropped (bb940cd) - ✅ Velocity
${esc.d}escaping applied to classpath layout expressions in the.md.vmtemplate (db18fba) - ✅
Build-Tool,Build-Os,Build-Jdk(with vendor string),packageName,addExtensionsrestored in27c4866— previously missing fromaddBuildEnvironmentEntries. Regression tests added forBuild-Tool,Build-Os, andBuild-Jdkformat.classpathPrefixnormalization also restored and covered byclasspathPrefixAutoAddsTrailingSlash. - ✅
specificationVersion()trailing-dot guard improved:"1.foo"now correctly produces"1"instead of"1.".
One minor observation: after e723df1, resolveLayout() has a mixed constant/literal style — CLASSPATH_LAYOUT_TYPE_SIMPLE is kept as a named constant (because ArchiveConfiguration.ManifestConfig uses it as the default value), while "repository" and "custom" are bare string literals. This is slightly asymmetric but not incorrect — CLASSPATH_LAYOUT_TYPE_SIMPLE serves as the contract between the default field initializer and the switch arm, which is a reasonable use of a named constant. Not a blocker.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
this PR should be done in maven-archiver, no choice |
Can we be more accurate about which consistency we are talking about? I had the feeling that Maven Archiver was a collection of formats, with special cases for JAR, special cases for EAR, special cases for WAR, etc. Now that we migrated to the JAR tools, the only part of Maven Archiver that was still used is adding a few attributes to the |
|
All review feedback has been addressed. Summary of recent changes: @hboutemy — The archive configuration documentation you requested has been added. @elharo — All inline nits have been addressed: variable renames ( Copilot findings — All four medium-severity items addressed: CI is green across all matrix configurations. Could @hboutemy and @elharo re-review when you get a chance? |
See Guillaume's reply above. If we nevertheless want to push for a shared library, then we need to identify what to share. My impression is that in a "post-migration to JAR tool" world, there is close to nothing left to share. If I'm wrong, then lets list which |
|
just read the page https://maven.apache.org/shared/maven-archiver/ that defines everything that is shared and we can't fork without creating a huge mess in the longer term (with discrepencies between plugins) |
|
The archive configuration documentation has been added in commits fd665b3 and eb74b21. The @hboutemy — could you take another look and confirm this addresses your concern? |
|
everything copied in 1 plugin: and other plugins? at Maven and at wider community https://central.sonatype.com/artifact/org.apache.maven/maven-archiver/dependents ? they will copy/paste too code and documentation? removing plexus-archiver is a good move: removing maven-archiver is not |
That page describes attributes to store in the JAR's To be more specific, the list of other plugins using Maven Archiver does not tell whether Maven Archiver is still useful. This pull request replaces the @Parameter
protected MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); |
@hboutemy — to make the choice concrete, there are really two paths: Option 1 — This PR as-is Option 2 — Trim maven-archiver first One important consequence of Option 2: since no other packaging plugin is currently being migrated to Maven 4 API, a trimmed Option 2 addresses your concern about consistency sooner, but at the cost of designing the shared API with only |
| * The package name for the {@code Package} manifest attribute. | ||
| * When set, the {@code Package} entry is added to the manifest main section. | ||
| */ | ||
| String packageName; |
There was a problem hiding this comment.
The package attribute does not seem standard. Is it Maven-specific? Can we describe it a bit more, or provide a link to its description?
| * Kept for compatibility with maven-archiver; has no effect in this implementation | ||
| * because the JAR plugin does not manage extensions. | ||
| */ | ||
| boolean addExtensions; |
There was a problem hiding this comment.
Then maybe this field should be deprecated?
|
you write option 2 as if the need for common code for MANIFEST customization was new: you are just rewriting the API for https://maven.apache.org/shared/maven-archiver/ and OF COURSE, the 4 branch is for Maven 4 plugins only = what will happen at scale in the future |
We need to rewrite (or refactor) Maven Archiver anyway. So it is more a question of "when". Are you suggesting to create a new branch of Maven Archiver with everything deleted except |
elharo
left a comment
There was a problem hiding this comment.
I approve option 1, this PR as is
|
Also option 1 for me. It does not mean that we will not share code later. But the change are so massive for Maven Archiver, it is just impossible to do that in a backward compatible way while meting our goal of removing Plexus and similar weight. Code sharing can be done on new ground when we have at least one other plugin showing us what need to be shared. |
|
-1 to this PR: ignoring this fact will loose modification history, and the migration of maven-jar-plugin and maven-source-plugin to the updated dependency, that should prepare future move of every packaging plugin 4 in the future this is fundamental Maven code structure https://maven.apache.org/scm.html at packaging plugins level = something every past Maven committer knew but seems to be lost recently with new maintainers. When doing the Java Module plan https://cwiki.apache.org/confluence/spaces/MAVEN/pages/393677487/Full+Java+Modules+Support+-+Current+State we need to keep this or we'll break consistency between all plugins creating jars in a subtle way = the worse scenario |
|
thank you Guillaume, apache/maven-archiver#422 is the way to go |
|
Superseded by #625 |

Summary
The plugin now uses the JDK
jartool to create archives, soplexus-archiverwas no longer used to package files. However it (andmaven-archiver) were still needed for manifest generation.This PR inlines the manifest generation directly into the plugin, removing both dependencies:
ArchiveConfigurationreplacesMavenArchiveConfiguration(with innerManifestConfigandManifestSection). The<archive>plugin parameter XML structure is preserved.ManifestBuilderreplacesMavenArchiver.getManifest():java.util.jar.Manifestdirectly (no plexus types)org.apache.maven.api.services.Interpolatorfor classpath layout interpolation (replacesplexus-interpolation)BuildHelper.discoverJavaRelease()using pure Maven 4 API (org.apache.maven.api.model)Dependencies removed
org.apache.maven.shared:maven-archiverorg.codehaus.plexus:plexus-archiverorg.codehaus.plexus:plexus-interpolation(transitive)Notes
<archive>parameter XML schema is identical from the user's perspectivemaven-war-pluginandmaven-source-pluginstill usemaven-archiverindependently