Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[discuss]maven.version conflict in pom.xml & system property #516

Closed
lanmaoxinqing opened this issue Nov 15, 2021 · 3 comments
Closed

[discuss]maven.version conflict in pom.xml & system property #516

lanmaoxinqing opened this issue Nov 15, 2021 · 3 comments

Comments

@lanmaoxinqing
Copy link
Contributor

We have the maven.version property configed in root pom.xml, to specify the base maven version we used for mvnd.

    <properties>
        <maven.version>3.8.1</maven.version>
    </properties>

And we also setup this property in DaemonMavenCli.java, for --version usage to display system maven version, i guess?

        String mavenVersion = buildProperties.getProperty(CLIReportingUtils.BUILD_VERSION_PROPERTY);
        systemProperties.setProperty("maven.version", mavenVersion);

It works fine in each designed satuation, until i try to use maven.version in xxx.proerties files. maven.version defined in pom.xml is overrided by system property, according to Spring Externalized Configuration, so i can't get the maven version we use for mvnd.

Is this an expected feature, or a bug ?

@ppalaga
Copy link
Contributor

ppalaga commented Nov 16, 2021

It works fine in each designed satuation, until i try to use maven.version in xxx.proerties files.

Which xxx.properties files do you mean?

maven.version defined in pom.xml

Which pom.xml?

is overrided by system property, according to Spring Externalized Configuration, so i can't get the maven version we use for mvnd.

Not sure at all, how Spring Externalized Configuration comes into game?
Could you perhaps use an example to explain what you mean?

@lanmaoxinqing
Copy link
Contributor Author

lanmaoxinqing commented Nov 16, 2021

Oh, sorry for my ambiguous description troubled you. I'm aim to build different mvnd for each maven version, so i need to get the maven version defined in pom.

Let's show the test code first...
lanmaoxinqing@f2426a8

Here is the github action result
https://github.com/lanmaoxinqing/mvnd/actions/runs/1466173659

Download the zip and go into mvnd-0.7.1-SNAPSHOT-linux-amd64.jar:/mvn/lib/ext/mvnd-common-0.7.1-SNAPSHOT.jar:/org/mvndaemon/mvnd/common/build.properties, you will find the mvnVersion is 3.6.3, and the value i expect is 3.8.3

Here is the detail below:

Which pom.xml?

https://github.com/mvndaemon/mvnd/blob/85e4d0cf2a6c6de3c34a12c582c96ba0aa4a0baa/pom.xml#L49

Which xxx.properties files do you mean?

https://github.com/mvndaemon/mvnd/blob/85e4d0cf2a6c6de3c34a12c582c96ba0aa4a0baa/common/src/main/resources/org/mvndaemon/mvnd/common/build.properties#L22

I try to add a property named mvnVersion after it using maven.version property defined in pom.xml

mvnVersion=${maven.version}

how Spring Externalized Configuration comes into game?

https://github.com/mvndaemon/mvnd/blob/85e4d0cf2a6c6de3c34a12c582c96ba0aa4a0baa/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java#L1438-L1443

maven.version property is also defined in system property, and overrides the same property in pom.xml.

When i build mvnd with maven 3.6.3 and maven.version defined in pom.xml is 3.8.3, the mvnVersion finally i get is 3.6.3, rather than 3.8.3.

@gnodet
Copy link
Contributor

gnodet commented Apr 12, 2022

I don't think this is a mvn issue as maven defines those system properties explicitely:
https://github.com/apache/maven/blob/8456294977b40660ce37db853de344f0d26ee46d/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L1655-L1659

@gnodet gnodet closed this as completed Apr 12, 2022
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

No branches or pull requests

3 participants