You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2022/02/20 18:55:00 UTC

[jira] [Commented] (MNG-5982) The POM for ... is invalid, transitive dependencies ... while property was overriden

    [ https://issues.apache.org/jira/browse/MNG-5982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17495215#comment-17495215 ] 

Michael Osipov commented on MNG-5982:
-------------------------------------

I can confirm that this issue is now fixed with MNG-7417:
{noformat}
mosipov@bsd1srv:/tmp/test-properties/1-installme (master=)
$ /tmp/apache-maven-4.0.0-alpha-1-SNAPSHOT/bin/mvn clean install  -Dcom.sun.tools.path=/usr/local/openjdk8/lib/tools.jar
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for 'test.properties.installme:dependency:pom:1.0-SNAPSHOT'
[WARNING] 'dependencyManagement.dependencies.dependency.scope' for com.sun:tools:jar declares usage of deprecated 'system' scope  @ line 18, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] module                                                             [pom]
[INFO] dependency                                                         [pom]
[INFO] root                                                               [pom]
[INFO]
[INFO] ------------------< test.properties.installme:module >------------------
[INFO] Building module 1.0-SNAPSHOT                                       [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[WARNING] Version not locked for default bindings plugins [maven-clean-plugin, maven-install-plugin], you should define versions in pluginManagement section of your pom.xml or parent
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ module ---
[INFO]
[INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) @ module ---
[INFO] Installing /tmp/test-properties/1-installme/module/pom.xml to /home/mosipov/.m2/repository/test/properties/installme/module/1.0-SNAPSHOT/module-1.0-SNAPSHOT.pom
[INFO]
[INFO] ----------------< test.properties.installme:dependency >----------------
[INFO] Building dependency 1.0-SNAPSHOT                                   [2/3]
[INFO] --------------------------------[ pom ]---------------------------------
[WARNING] Version not locked for default bindings plugins [maven-clean-plugin, maven-install-plugin], you should define versions in pluginManagement section of your pom.xml or parent
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ dependency ---
[INFO]
[INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) @ dependency ---
[INFO] Installing /tmp/test-properties/1-installme/dependency/pom.xml to /home/mosipov/.m2/repository/test/properties/installme/dependency/1.0-SNAPSHOT/dependency-1.0-SNAPSHOT.pom
[INFO]
[INFO] -------------------< test.properties.installme:root >-------------------
[INFO] Building root 1.0-SNAPSHOT                                         [3/3]
[INFO] --------------------------------[ pom ]---------------------------------
[WARNING] Version not locked for default bindings plugins [maven-clean-plugin, maven-install-plugin], you should define versions in pluginManagement section of your pom.xml or parent
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ root ---
[INFO]
[INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) @ root ---
[INFO] Installing /tmp/test-properties/1-installme/pom.xml to /home/mosipov/.m2/repository/test/properties/installme/root/1.0-SNAPSHOT/root-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for root 1.0-SNAPSHOT:
[INFO]
[INFO] module ............................................. SUCCESS [  0.432 s]
[INFO] dependency ......................................... SUCCESS [  0.008 s]
[INFO] root ............................................... SUCCESS [  0.006 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.602 s
[INFO] Finished at: 2022-02-20T19:51:22+01:00
[INFO] ------------------------------------------------------------------------
{noformat}
and
{noformat}
mosipov@bsd1srv:/tmp/test-properties/2-buildme (master=)
$ /tmp/apache-maven-4.0.0-alpha-1-SNAPSHOT/bin/mvn dependency:tree  -Dcom.sun.tools.path=/usr/local/openjdk8/lib/tools.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< test.properties:buildme >-----------------------
[INFO] Building buildme 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) @ buildme ---
[INFO] test.properties:buildme:pom:1.0-SNAPSHOT
[INFO] \- test.properties.installme:module:pom:1.0-SNAPSHOT:compile
[INFO]    \- log4j:log4j:jar:1.2.17:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.478 s
[INFO] Finished at: 2022-02-20T19:52:13+01:00
[INFO] ------------------------------------------------------------------------
{noformat}

> The POM for ... is invalid, transitive dependencies ... while property was overriden
> ------------------------------------------------------------------------------------
>
>                 Key: MNG-5982
>                 URL: https://issues.apache.org/jira/browse/MNG-5982
>             Project: Maven
>          Issue Type: Bug
>          Components: Dependencies, Inheritance and Interpolation, POM
>    Affects Versions: 3.0, 3.3.9
>         Environment: Linux and Mac
>            Reporter: Fabrice Pipart
>            Priority: Minor
>              Labels: must-be-in-4.0.0-alpha-1, needs-attention
>             Fix For: 4.0.x-candidate, 3.8.x-candidate
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> I experienced issues with a maven build that does not behave the same way if done on Windows (like they were done in the past) or Linux (like I want to do them now).
> I want to build a project that has a dependency on another project that pom that itself imports a pom that contains a Windows path.
> {code:xml}
>    my project   |           other project
>                 |
> mybuild  -------|------> pom --------> pom with systemPath
>             dependency        import
>                 |
> {code}
> But in a nutshell, here is my pom:
> {code:xml}
> <groupId>test.properties</groupId>
> <artifactId>buildme</artifactId>
> <version>1.0-SNAPSHOT</version>
> ...
> <dependencies>
>   <dependency>
>     <groupId>test.properties.installme</groupId>
>     <artifactId>module</artifactId>
>     <version>1.0-SNAPSHOT</version>
>     <type>pom</type>
>   </dependency>
> </dependencies>
> {code}
> And I depend on a pom that looks like this (not under my control)
> {code:xml}
> <groupId>test.properties.installme</groupId>
> <artifactId>module</artifactId>
> <version>1.0-SNAPSHOT</version>
> ...
> <dependencyManagement>
>   <dependencies>
>     <dependency>
>       <groupId>test.properties.installme</groupId>
>       <artifactId>dependency</artifactId>
>       <version>1.0-SNAPSHOT</version>
>       <scope>import</scope>
>       <type>pom</type>
>     </dependency>
>   </dependencies>
> </dependencyManagement>
> <dependencies>
>   <dependency>
>     <groupId>log4j</groupId>
>     <artifactId>log4j</artifactId>
>     <version>1.2.17</version>
>   </dependency>
> </dependencies>
> {code}
> and the problem lies in this last pom (not under my control again):
> {code:xml}
> <modelVersion>4.0.0</modelVersion>  
> <groupId>test.properties.installme</groupId>
> <artifactId>dependency</artifactId>
> <version>1.0-SNAPSHOT</version>
> ...
> <properties>
>   <com.sun.tools.path>D:/java/jdk1.8.0_65/lib/tools.jar</com.sun.tools.path>
> </properties>
> <dependencyManagement>
>   <dependencies>
>     <dependency>
>       <groupId>com.sun</groupId>
>       <artifactId>tools</artifactId>
>       <version>1.8</version>
>       <scope>system</scope>
>       <systemPath>${com.sun.tools.path}</systemPath>
>     </dependency>
>   </dependencies>
> </dependencyManagement>
> {code}
> I have no control on the other project in question. I totally agree that a refactoring to use environment variable in place of the hard coded paths would solve my problem. But instead the Windows path is defined in a property. *One would think that overriding the value of the property depending on my platform would be enough.* But it is not.
> Unfortunately in this precise case case maven seems to behave to behave poorly.
> Before applying any property override in any form (in settings.xml, -Dproperty=, redefinition in root pom), maven starts building the effective pom. And during that step, if it finds the pattern I mentioned above (a dependency on another pom that itself imports a pom that contains a Windows path), then it says:
> {code:xml}
> The POM for <groupId>:<artifactId>:jar:<version> is invalid, transitive dependencies (if any) will not be available
> {code}
> As a consequence, my project needs to explicitly define all the dependencies of the second project. And I cannot rely on transitive dependencies which gives me a lot of trouble.
> In order to illustrate the issue, I created a minimal example showing the problem. It can be found here: [https://github.com/fabricepipart/test-properties]
> Can you confirm this is a bug from maven?
> I tested with several versions of maven. 3.0 up to a 3.3.9 I think.
> The issue remains the same. It is all a matter of redefining the value of the property based on the environment. If I *launch maven with -Dcom.sun.tools.path=/correct/linux/path*, globally my build is fine. Because when the classes are compiled, it is the *overriden Linux path that is taken*, not the Windows one. 
> But during the *initial evaluation of the pom*(before any maven phase is started), the error I mentioned above is thrown because the *value of the property is still the Windows one* (and the path is considered invalid).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)