Skip to content

Remove maven-archiver and plexus-archiver dependencies - #618

Closed
gnodet wants to merge 38 commits into
apache:maven-jar-plugin-4.xfrom
gnodet:feat/remove-maven-archiver-dep
Closed

gnodet wants to merge 38 commits into
apache:maven-jar-plugin-4.xfrom
gnodet:feat/remove-maven-archiver-dep

Conversation

@gnodet

@gnodet gnodet commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

The plugin now uses the JDK jar tool to create archives, so plexus-archiver was no longer used to package files. However it (and maven-archiver) were still needed for manifest generation.

This PR inlines the manifest generation directly into the plugin, removing both dependencies:

  • ArchiveConfiguration replaces MavenArchiveConfiguration (with inner ManifestConfig and ManifestSection). The <archive> plugin parameter XML structure is preserved.
  • ManifestBuilder replaces MavenArchiver.getManifest():
    • Uses java.util.jar.Manifest directly (no plexus types)
    • Uses org.apache.maven.api.services.Interpolator for classpath layout interpolation (replaces plexus-interpolation)
    • Inlines BuildHelper.discoverJavaRelease() using pure Maven 4 API (org.apache.maven.api.model)

Dependencies removed

  • org.apache.maven.shared:maven-archiver
  • org.codehaus.plexus:plexus-archiver
  • org.codehaus.plexus:plexus-interpolation (transitive)

Notes

  • All 16 unit tests pass
  • The <archive> parameter XML schema is identical from the user's perspective
  • maven-war-plugin and maven-source-plugin still use maven-archiver independently

@gnodet

gnodet commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

This PR removes maven-archiver and plexus-archiver from the JAR plugin by inlining manifest generation — a direction I fully support. Before merging, it would be worth aligning on which long-term approach we want, since the choice affects maven-war-plugin and other plugins that will follow:

Option A — Merge as-is (inline, plugin-local)
Keep ArchiveConfiguration + ManifestBuilder private to the JAR plugin. Each plugin that migrates to Maven 4 inlines its own manifest generation, accepting some duplication. Simple, zero-dependency, done now.

Option B — Rework maven-archiver for Maven 4
Keep maven-archiver alive but strip it down to manifest-only (remove everything JAR-specific: MavenArchiver.createArchive(), the plexus-archiver integration, etc.) and rewrite it against the Maven 4 API (no plexus types, no plexus-interpolation). Other plugins (maven-war-plugin, maven-source-plugin, …) could then share a single, maintained manifest library once they migrate to Maven 4.

Option C — New shared manifest library (no plexus-archiver)
Create a lean maven-manifest-builder (or similar) that is Maven-4-API-native from day one, with no plexus-archiver dependency. Avoids inheriting the baggage of the existing maven-archiver artifact while still enabling code sharing once the other plugins migrate.

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?

@gnodet
gnodet force-pushed the feat/remove-maven-archiver-dep branch from 07738af to d3edc35 Compare October 8, 2026 23:24
@desruisseaux

Copy link
Copy Markdown

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 ArchiveConfiguration. If that class is package-private, it is okay to read/write the fields directly because we don't need to protect anyone against potentially incompatible evolution of implementation details.

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

@gnodet

gnodet commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

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 EnhancedComponentConfigurator (Sisu/Plexus-based). It injects <archive> config via reflection from a different classloader/module, and without setAccessible(true) it cannot access package-private fields — we get IllegalAccessException at runtime. I confirmed this by trying it: all ITs that exercise <archive> config failed.

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 setAccessible(true) or uses a proper binding mechanism that doesn't depend on field visibility.

For now I'll keep ArchiveConfiguration public with its getters/setters, and we can revisit once #13459 lands.

@gnodet
gnodet marked this pull request as ready for review October 13, 2026 08:52
@gnodet
gnodet force-pushed the feat/remove-maven-archiver-dep branch 2 times, most recently from 2a057b6 to 5ff0509 Compare October 13, 2026 09:00

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

  1. Dead code — asList() in ManifestBuilder is unused (line 372); AbstractJarMojo has its own copy at line 354.
  2. Stale @link — ManifestConfiguration — the referenced class does not exist; the actual class is ArchiveConfiguration.ManifestConfig.
  3. Loop-invariant computation — resolveLayout() at line 268 is called on every iteration but its three inputs never change inside the loop.
  4. Stale @link — MavenArchiver#getManifest — MavenArchiver is removed from the classpath in this PR, so the Javadoc link is dangling.
  5. Missing unit tests — ManifestBuilder and ArchiveConfiguration are ~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.
@gnodet
gnodet force-pushed the feat/remove-maven-archiver-dep branch from 5ff0509 to 6949b2a Compare October 13, 2026 12:59

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

⚠️ Behavioral change: 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 gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 examples
  • src/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 gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.
@hboutemy

Copy link
Copy Markdown
Member

when that shared component is eventually extracted

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 gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_BY constants inlined (c59169c)
  • ✅ k → normalizedKey, c → classifier renamed (bb940cd)
  • ✅ CLASSPATH_LAYOUT_TYPE_REPOSITORY and CLASSPATH_LAYOUT_TYPE_CUSTOM inlined to string literals (e723df1)
  • ✅ Deprecated Implementation-Vendor-Id and Implementation-Url attributes dropped (bb940cd)
  • ✅ Velocity ${esc.d} escaping applied to classpath layout expressions in the .md.vm template (db18fba)
  • ✅ Build-Tool, Build-Os, Build-Jdk (with vendor string), packageName, addExtensions restored in 27c4866 — previously missing from addBuildEnvironmentEntries. Regression tests added for Build-Tool, Build-Os, and Build-Jdk format. classpathPrefix normalization also restored and covered by classpathPrefixAutoAddsTrailingSlash.
  • ✅ 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.

@hboutemy

Copy link
Copy Markdown
Member

this PR should be done in maven-archiver, no choice
and I don't know precisely how, in maven-archiver, have a temporary clone of maven-jar-plugin to easily test impact: this is the type of habit we need for efforts like shared components = something that we need even if harder than immediate copy/paste (that AI makes too easy, even easier than in the past)

@desruisseaux

Copy link
Copy Markdown

checking all Maven-maintained packaging plugins:

❯ grep maven-archiver */pom.xml
maven-acr-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-ear-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-ejb-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-jar-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-jlink-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-rar-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-source-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>
maven-war-plugin/pom.xml:      <artifactId>maven-archiver</artifactId>

consistency for all these plugins is key (and I'm not considering any community plugin that may use maven-archiver too)

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 MANIFEST.MF file. The remaining of Maven Archiver became ignored by Maven JAR Plugin. Aren't the MANIFEST.MF attributes specific to the JAR format? If no, which attributes are expected to be shared exactly?

@gnodet

gnodet commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

All review feedback has been addressed. Summary of recent changes:

@hboutemy — The archive configuration documentation you requested has been added. manifest-customization.md.vm now includes a full reference for the <archive> element (all fields, types, defaults, and descriptions), a note that this configuration is now managed locally and may diverge from the Maven Archiver docs, and classpath layout expression docs. The page also clearly states at the top that the configuration is no longer delegated to the external maven-archiver library.

@elharo — All inline nits have been addressed: variable renames (m→manifest, org→organization, p→plugin, k→normalizedKey, c→classifier), constants inlined per request, deprecated Implementation-Vendor-Id/Implementation-Url dropped.

Copilot findings — All four medium-severity items addressed: packageName/addExtensions/recompressAddedZips restored, Build-Tool/Build-Os/Build-Jdk format restored, classpathPrefix normalization (trailing slash, backslash conversion) restored, and specificationVersion() trailing-dot guard improved.

CI is green across all matrix configurations. Could @hboutemy and @elharo re-review when you get a chance?

@desruisseaux

Copy link
Copy Markdown

this PR should be done in maven-archiver, no choice

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 MANIFEST.MF attributes are also used by other plugins.

@hboutemy

hboutemy commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

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)

@gnodet

gnodet commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

The archive configuration documentation has been added in commits fd665b3 and eb74b21.

The manifest-customization.md page now includes a full self-contained reference for the <archive> element: all top-level options and all <manifest> sub-options with types, defaults, and descriptions. The page also explicitly notes at the top that the configuration is now handled locally (via ArchiveConfiguration/ManifestBuilder) and may differ from the Maven Archiver documentation.

@hboutemy — could you take another look and confirm this addresses your concern?

@hboutemy

Copy link
Copy Markdown
Member

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?
what is complex to understand in that topic?
maven-jar-plugin is not the only one

removing plexus-archiver is a good move: removing maven-archiver is not

@desruisseaux

desruisseaux commented Oct 18, 2026 •

Copy link
Copy Markdown

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)

That page describes attributes to store in the JAR's MANIFEST.MF. Are the same attributes stored in other formats too? All of them? Used in which formats?

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 MavenArchiveConfiguration and MavenArchiver classes. Is there any MOJO other than JAR with a confugiration like below?

@Parameter
protected MavenArchiveConfiguration archive = new MavenArchiveConfiguration();

@gnodet

gnodet commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

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? what is complex to understand in that topic? maven-jar-plugin is not the only one

removing plexus-archiver is a good move: removing maven-archiver is not

@hboutemy — to make the choice concrete, there are really two paths:

Option 1 — This PR as-is
 Inline manifest generation in maven-jar-plugin, package-private, no shared API. Other plugins continue using maven-archiver + plexus-archiver unchanged. When (if) they migrate to Maven 4 API and the jar tool, we extract the shared parts then — with full requirements from all plugins in hand.

Option 2 — Trim maven-archiver first
 Before merging this PR, create a maven-archiver 4.x branch that drops plexus-archiver and MavenArchiver.createArchive(), keeping only the manifest generation logic (<archive><manifest> config + MANIFEST.MF building), rewritten against the Maven 4 API. maven-jar-plugin depends on that. When other plugins migrate, they extend the same shared component rather than starting from scratch.

One important consequence of Option 2: since no other packaging plugin is currently being migrated to Maven 4 API, a trimmed maven-archiver 4.x would be manifest-only for the foreseeable future, as we decided to not expand the number of Maven 4 plugins in the near future. Any community plugin currently using maven-archiver for archive creation (not just manifest generation) could not upgrade to 4.x without losing that functionality — which is a significant regression for the broader ecosystem.

Option 2 addresses your concern about consistency sooner, but at the cost of designing the shared API with only maven-jar-plugin's requirements — before we know what WAR/EAR/EJB will need. That risks locking in the wrong API and having to break it later. Option 1 defers the shared component until we have the full picture.

* The package name for the {@code Package} manifest attribute.
* When set, the {@code Package} entry is added to the manifest main section.
*/
String packageName;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Then maybe this field should be deprecated?

@hboutemy

Copy link
Copy Markdown
Member

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

@desruisseaux

Copy link
Copy Markdown

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/

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 MavenArchiveConfiguration and the method populating a MANIFEST.MF from it? It would be unusable for all other plugins as they stand today.

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I approve option 1, this PR as is

@desruisseaux

Copy link
Copy Markdown

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.

@hboutemy

hboutemy commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

-1 to this PR:
this MANIFEST creation code belongs to maven-archiver 4.0.x branch (and has been copy pasted from there)

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

@hboutemy

Copy link
Copy Markdown
Member

thank you Guillaume, apache/maven-archiver#422 is the way to go

@gnodet

gnodet commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #625

@gnodet gnodet closed this Oct 20, 2026
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.

7 participants