Skip to content

Maven 3.10.x should use Maven 3.1 validation in strict mode - #1542

Merged
gnodet merged 1 commit into
apache:maven-3.10.xfrom
gnodet:fix-validation-level
Sep 21, 2026
Merged

gnodet merged 1 commit into
apache:maven-3.10.xfrom
gnodet:fix-validation-level

Conversation

@gnodet

@gnodet gnodet commented May 29, 2024 •

Copy link
Copy Markdown
Contributor

Changes VALIDATION_LEVEL_STRICT from VALIDATION_LEVEL_MAVEN_3_0 (30) to VALIDATION_LEVEL_MAVEN_3_1 (31).

In strict mode (the default for project builds), the getSeverity(request, errorThreshold) method returns ERROR when validationLevel >= threshold and WARNING otherwise. By raising the strict level from 3.0 to 3.1, the following checks are promoted from warnings to errors:

  • Duplicate plugin declarations in build/plugins
  • Banned characters in version strings (e.g. backslash, expression fragments)
  • Unsupported snapshot version formats (non-standard SNAPSHOT qualifiers)
  • Banned characters in repository IDs
  • Reserved repository ID local

Additional warnings are now emitted for:

  • system scope dependency deprecation
  • Hard-coded system paths in systemPath
  • ${basedir}-relative system paths

The test resource duplicate-plugins-merged-pom.xml was updated to move the duplicate plugin into a profile (avoiding the raw validation error while still testing plugin merge behavior).

Unit tests updated to explicitly use VALIDATION_LEVEL_MAVEN_3_0 where the test exercises pre-3.1 behavior, and to use the default (now 3.1) level where the stricter validation is expected.

Companion IT PR: apache/maven-integration-testing#441

@cstamas

cstamas commented May 29, 2024

Copy link
Copy Markdown
Member

Let's see CI, as it may have some quirks...

@cstamas cstamas modified the milestone: 3.9.8 Jun 5, 2024
@cstamas

cstamas commented Jun 5, 2024

Copy link
Copy Markdown
Member

Oups, not yet, these are IT failures...

@gnodet gnodet added the mvn3 label Aug 29, 2024
@gnodet
gnodet marked this pull request as draft January 22, 2025 08:20
@gnodet
gnodet changed the base branch from maven-3.9.x to maven-3.10.x September 2, 2026 21:12
@gnodet gnodet added this to the 3.10.0 milestone Sep 2, 2026
@gnodet
gnodet force-pushed the fix-validation-level branch 2 times, most recently from f92658b to 309feec Compare September 2, 2026 22:03
@gnodet
gnodet marked this pull request as ready for review September 2, 2026 22:17
@gnodet

gnodet commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Companion IT PR: apache/maven-integration-testing#441

@cstamas cstamas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But title mentions 3.9.x...

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

The test logic and constant change are sound. VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_1 is the right move for Maven 3.10.x — the 3.1 checks (duplicate plugins, bad version chars, bad snapshot format, bad/reserved repo IDs) have been stable since Maven 3.1 (2012), and promoting them to errors in a new minor is reasonable. The test split into *30 / default variants is clean and exhaustive.

One structural concern with duplicate-plugins-merged-pom.xml (see inline).

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Comment thread maven-core/src/test/resources/projects/duplicate-plugins-merged-pom.xml Outdated

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

Previous finding — addressed ✅
The activeByDefault fragility I flagged is now fixed: the profile uses <activation><property><name>activateFooProfile</name></property></activation> (activated when the property is set, not silently deactivated by other profiles), and the test explicitly activates it via setActiveProfileIds(["foo"]). This makes testDuplicatePluginDefinitionsMerged environment-independent. Good fix.

Remaining issue — PR title is wrong
The title says "Maven 3.9.x should use Maven 3.1 validation in strict mode" but the PR targets the maven-3.10.x branch with milestone 3.10.0. 3.9.x is a distinct release line that is not the target of this change. The title should read something like "Maven 3.10.x should use Maven 3.1 validation in strict mode" (or simply "Raise VALIDATION_LEVEL_STRICT to VALIDATION_LEVEL_MAVEN_3_1 for Maven 3.10.x"). This was already noted by @cstamas and is still not updated.

Validator logic — verified ✅
The tests correctly reflect the validator's getSeverity logic:

  • validateBannedCharacters and validate20ProperSnapshotVersion use errOn31 → ERROR at 3.1 strict.
  • system scope deprecation warning fires unconditionally at >= 3.1 (not gated on errOn31), so testHardCodedSystemPath correctly expects 3 warnings (not errors) at strict level — the deprecation warning was new at 3.1 in the original validator, not promoted to an error.
  • All six test pairs (testDuplicatePlugin30/testDuplicatePlugin, testReservedRepositoryId30/testReservedRepositoryId, testBadVersion30/testBadVersion, testBadSnapshotVersion30/testBadSnapshotVersion, testBadRepositoryId30/testBadRepositoryId, testHardCodedSystemPath, testSystemPathRefersToProjectBasedir) are complete and consistent.

Please update the PR title before merge.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet changed the title Maven 3.9.x should use Maven 3.1 validation in strict mode Maven 3.10.x should use Maven 3.1 validation in strict mode Sep 21, 2026
@gnodet

gnodet commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

PR title updated to "Maven 3.10.x should use Maven 3.1 validation in strict mode" as suggested by @cstamas and noted in the re-review.

- Set VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_1 so that
  3.1-level checks (duplicate plugins, bad version chars, bad snapshot
  format, reserved/bad repository IDs) are reported as errors in strict
  mode, matching the maturity of the 3.1 checks since Maven 3.1 (2012)
- Add tests for the new strict-mode behaviour (*30 variants vs default)
- Fix fragile activeByDefault profile in test fixture: use explicit
  profile activation via setActiveProfileIds to avoid CI environments
  deactivating the profile when other profiles are active
@gnodet
gnodet force-pushed the fix-validation-level branch from 7f77651 to 43f2ab8 Compare September 21, 2026 11:23
@gnodet
gnodet merged commit af936f4 into apache:maven-3.10.x Sep 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants