Skip to content

ModelVersionProcessor should accept dynamic version from any property source, not just jgit #179

Closed

Description

@gnodet

Context

When using nisse for zero-commit releases (as described in this blog post), source archives (GitHub tarballs, git archive output) cannot be built because they lack a .git directory.

We attempted to fix this using git's export-subst mechanism (jline/jline3#2151): .mvn/maven-user.properties contains $Format:...$ placeholders that git archive expands at archive time. In a git checkout, nisse overwrites these with the real values from git.

The export-subst correctly populates the properties:

nisse.jgit.dynamicVersion=4.3.1
nisse.jgit.date=2026-06-30T21:15:51+02:00

And nisse injects them into user properties:

[INFO] Nisse injecting 19 properties into User Properties

But the build still fails:

[ERROR] 'version' must be a constant version but is '${nisse.jgit.dynamicVersion}'.

Root cause

When the jgit source fails to find a .git directory, it logs:

[DEBUG] Seems this is not a git checkout; ignoring property source jgit

This disables the ModelVersionProcessor that allows ${nisse.jgit.dynamicVersion} in <version> fields. Even though the property value is available (from nisse's file source / maven-user.properties), the version processor doesn't accept it because the jgit source was not the one that provided it.

Passing the same property via -D works:

./mvx mvn validate -Dnisse.jgit.dynamicVersion=4.3.1
# BUILD SUCCESS

Suggestion

The ModelVersionProcessor should accept ${nisse.jgit.dynamicVersion} in <version> whenever the property is available from any nisse property source — not only when the jgit source actively resolved it. This would enable the export-subst approach and make source archives buildable without -D flags.

Reproducible test case

# 1. Clone JLine (which has the export-subst fix merged)
curl -sL https://github.com/jline/jline3/archive/refs/heads/master.tar.gz | tar xzf -
cd jline3-master

# 2. Verify the property is expanded
cat .mvn/maven-user.properties
# Shows: nisse.jgit.dynamicVersion=4.3.1-72-g35fc24edb

# 3. Try to build — fails
./mvx mvn validate
# ERROR: 'version' must be a constant version

# 4. Same property via -D — works
./mvx mvn validate -Dnisse.jgit.dynamicVersion=4.3.1
# BUILD SUCCESS

Activity

  1. gnodet commented on Aug 8, 2026

    @gnodet
    ContributorAuthor

    Maven 4 variant of this issue

    There's a related Maven 4-specific problem in extension4's NissePropertyContributor that prevents the export-subst approach from working even in a git checkout (not just archives).

    Root cause

    Maven 4 auto-loads .mvn/maven-user.properties before extensions run. When using the export-subst mechanism, this file contains unexpanded placeholders like:

    nisse.jgit.dynamicVersion=$Format:%(describe:tags=true)$

    In a git checkout, git archive substitution hasn't happened, so the raw $Format:...$ placeholder is loaded as-is into user properties. When Nisse's PropertyContributor runs and computes the real value from jgit, line 64 uses putIfAbsent:

    nisseProperties.forEach(result::putIfAbsent);

    Since the key already exists (pre-loaded by Maven 4 with the unexpanded placeholder), putIfAbsent keeps the placeholder value $Format:%(describe:tags=true)$. This value contains :, which Maven 4's strict POM validation rejects.

    Fix

    PR #181 changes putIfAbsent to put so Nisse-computed values always take precedence over pre-loaded values. This is the correct semantic — Nisse is the authoritative source for these properties.

    Discovered via maveniverse/scalpel#62.

  2. cstamas commented on Aug 20, 2026

    @cstamas
    Member

    @gnodet does this issue still applies?

  3. gnodet commented on Aug 20, 2026

    @gnodet
    ContributorAuthor

    @gnodet does this issue still applies?

    Yes! This will definitely improve the zero-commit release process.

  4. cstamas commented on Aug 20, 2026

    @cstamas
    Member

    But isn't this solved by "low priority properties" already present? At least the first issue. The Maven 4 issue stands, as I see

  5. added a commit that references this issue on Aug 20, 2026
  6. cstamas commented on Aug 20, 2026

    @cstamas
    Member

    Added fix, but not closing this issue, right now am in hurry, the fix will need test coverage

  7. gnodet commented on Aug 26, 2026

    @gnodet
    ContributorAuthor

    All work for this issue has been completed across several PRs:

    Core fix (0.9.7):

    • 99c113e — Added isUnexpandedPlaceholder() detection and override loop in extension4's NissePropertyContributor. Unexpanded placeholders ($Format:...$ from git export-subst, ${...} from Maven interpolation) pre-loaded by Maven 4 are now overridden by Nisse-computed values, while CLI -D overrides are preserved.

    Fallback mechanism (0.9.5):

    Test coverage & cleanup:

    • Remove dead putIfAbsent line and add user-props-override ITs (#179) #192 (33a056e) — Removed the dead putIfAbsent line left after the fix, and added user-props-override integration tests for both extension4 (Maven 4) and extension3 (Maven 3).
    • 5c822dd — Added integration tests for the .mvn/nisse.properties fallback (happy path, unexpanded placeholders, empty values, priority ordering).

    Closing as fully resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions