Skip to content

Allow to not use --module-version for the Java compiler - #331

Merged
slawekjaranowski merged 1 commit into
apache:maven-compiler-plugin-3.xfrom
pzygielo:nmv
Jun 20, 2025
Merged

slawekjaranowski merged 1 commit into
apache:maven-compiler-plugin-3.xfrom
pzygielo:nmv

Conversation

@pzygielo

Copy link
Copy Markdown
Contributor

@pzygielo
pzygielo marked this pull request as ready for review May 26, 2025 12:27
@desruisseaux

Copy link
Copy Markdown
Contributor

Do we need to add a new useModuleVersion plugin configuration option? Couldn't the users set the existing moduleVersion configuration option to an empty value instead if they do not want module version? It would still require a change in the code, but would avoid increasing the number of plugin configuration options.

@pzygielo

Copy link
Copy Markdown
Contributor Author

Couldn't the users set the existing moduleVersion configuration option to an empty value instead if they do not want module version?

Let me explore that option. As long as the same goal is achieved I'm not attached to new parameter.

@pzygielo

Copy link
Copy Markdown
Contributor Author

Do we need to add a new useModuleVersion plugin configuration option? Couldn't the users set the existing moduleVersion configuration option to an empty value

Unclear how to preserve compatibility with current default of project.version (since 3.14). Using special value not conforming to ModuleDescriptor.Version could be considered, but I don't like that idea very much.

Thus I prefer proposed solution, but I'm open to see it being solved differently.

@desruisseaux

Copy link
Copy Markdown
Contributor

No special value, just allow users to specify <moduleVersion/>. The value is set to an empty or blank string, and the code just needs to test if (!moduleVersion.isEmpty()) { add the option }.

@pzygielo

Copy link
Copy Markdown
Contributor Author

With <moduleVersion/> project.version seems to be injected. So !moduleVersion.isEmpty would always be true unless default was removed.

@pzygielo

Copy link
Copy Markdown
Contributor Author

Then, I don't know how to differentiate the case of explicit empty or blank string set with <moduleVersion/> from the case this is not set at all, for the project.version to be used.

@desruisseaux

Copy link
Copy Markdown
Contributor

It may be a question for @gnodet: we have a configuration option declared that way:

@Parameter(property = "maven.compiler.moduleVersion", defaultValue = "${project.version}")
private String moduleVersion;

Do you know if it is possible for a user to explicitly set an empty value? Apparently, using <moduleVersion/> causes Maven to fallback on defaultValue. Is there a way to said "do not use the default"? (other than adding a new useMavenVersion plugin configuration option).

@slawekjaranowski

Copy link
Copy Markdown
Member

we can also use a special value like skip for moduleVersion parameter ... but I'm not sure if will be a clear way
so new parameter is ok for me

@slawekjaranowski slawekjaranowski added the enhancement New feature or request label Jun 6, 2025
@pzygielo

pzygielo commented Jun 6, 2025

Copy link
Copy Markdown
Contributor Author

I'm also not sure about special value.

But perhaps new option, if it's accepted, could have better name than I proposed here.

@slawekjaranowski

Copy link
Copy Markdown
Member

I'm also not sure about special value.

But perhaps new option, if it's accepted, could have better name than I proposed here.

for me name is ok πŸ˜„

@desruisseaux

Copy link
Copy Markdown
Contributor

Sorry for being silent (I have a meeting to prepare next week). It seems to me that the cleanest solution would be to put an empty value <moduleVersion>. I haven't investigated yet why it doesn't work. I thought that maybe, if we cannot rely on the value injected automatically by Maven in annotated field, maybe we can find this information in Model. I haven't checked yet if this is feasible.

@slawekjaranowski

Copy link
Copy Markdown
Member

Here is s reason:

so I would not to do a magic in plugin for it

@desruisseaux

Copy link
Copy Markdown
Contributor

Thanks for the link. Alternatively, in the following declaration (added in commit 09dce4e):

@Parameter(property = "maven.compiler.moduleVersion", defaultValue = "${project.version}")
private String moduleVersion;

What about removing the default value completely, and let users specify it explicitly? The rational given in MCOMPILER-579 (that ${project.version} is not a valid module version when the version ends with -SNAPSHOT) seems quite convincing.

@slawekjaranowski

Copy link
Copy Markdown
Member

Thanks for the link. Alternatively, in the following declaration (added in commit 09dce4e):

@Parameter(property = "maven.compiler.moduleVersion", defaultValue = "${project.version}")
private String moduleVersion;

What about removing the default value completely, and let users specify it explicitly? The rational given in MCOMPILER-579 (that ${project.version} is not a valid module version when the version ends with -SNAPSHOT) seems quite convincing.

when we remove default value we will break a current behavior

@pzygielo

pzygielo commented Jun 7, 2025

Copy link
Copy Markdown
Contributor Author

The rational given in MCOMPILER-579

There is something missing or misunderstood.

(that ${project.version} is not a valid module version when the version ends with -SNAPSHOT)

is completely valid module version when it ends with anything, as long as it follows ModuleDescriptor.Version spec (starts with the number, which the other example in issue HEAD-SNAPSHOT does not).

@pzygielo

pzygielo commented Jun 7, 2025 •

Copy link
Copy Markdown
Contributor Author

For the

when we remove default value we will break a current behavior

additionally consider, that using the project.version was not introduced in

It just enabled module version to be modified.
So the behaviour of not specifying explicit module version and having it anyway is the old, old feature (2ba3f26).

@desruisseaux

Copy link
Copy Markdown
Contributor

(...snip...) is completely valid module version when it ends with anything,

Ah, okay. I do not remember having tested.

@pzygielo

Copy link
Copy Markdown
Contributor Author

@desruisseaux Do you have any other comments?

@desruisseaux

Copy link
Copy Markdown
Contributor

No other comment. I'm still interested in making possible to set an empty value instead of adding a new parameter, but I may explore this possibility in version 4. I should probably learn more about the relationship between Eclipse SISU and Maven 4 (for eclipse-sisu#167).

@pzygielo

Copy link
Copy Markdown
Contributor Author

Then, this could be merged as proposed, right?

@desruisseaux

Copy link
Copy Markdown
Contributor

Yes, sorry for being so slow. For merges on the 3.x branch, I tend to leave it @slawekjaranowski or any other who is familiar with the long history of this plugin and its interaction with Maven 3 (I'm more familiar with Maven 4 code base than Maven 3).

@slawekjaranowski
slawekjaranowski merged commit 164bad4 into apache:maven-compiler-plugin-3.x Jun 20, 2025
@github-actions github-actions Bot added this to the 3.14.1 milestone Jun 20, 2025
@pzygielo
pzygielo deleted the nmv branch June 20, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants