Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6988

muti module project user parent profile assign properties control dependency version have problem

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 3.2.3, 3.2.5
    • Fix Version/s: None
    • Component/s: Dependencies, Profiles
    • Labels:
      None
    • Environment:
      MacBook Pro (Retina, 15-inch, Mid 2015) ,Maven3.2.3,Maven3.6.1

      Description

      I have two project bbb and aaa, use parent profiles define properties to control module version ,the pom like this.

      bbb: 

      //代码占位符
      

       

      <modelVersion>4.0.0</modelVersion>

      <groupId>hygtest</groupId>
      <artifactId>bbb</artifactId>
      <packaging>pom</packaging>
      <version>1.0-SNAPSHOT</version>
      <modules>
      <module>bbbA</module>
      </modules>

      <profiles>
      <profile>
      <id>dev</id>
      <properties>
      <bbb-bbbA.version>1.0-DEV-SNAPSHOT</bbb-bbbA.version>
      </properties>
      <activation>
      <activeByDefault>true</activeByDefault>
      </activation>
      </profile>

      <profile>
      <id>qa</id>
      <properties>
      <bbb-bbbA.version>1.0-QA-SNAPSHOT</bbb-bbbA.version>
      </properties>
      </profile>

      <profile>
      <id>prod</id>
      <properties>
      <bbb-bbbA.version>1.0</bbb-bbbA.version>
      </properties>
      </profile>

      </profiles>

       

      submodule bbbA like this

      //代码占位符
      

      <parent>
      <artifactId>bbb</artifactId>
      <groupId>hygtest</groupId>
      <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>

      <artifactId>bbb-A</artifactId>
      <version>${bbb-bbbA.version}</version>

       

      aaa:

      //代码占位符
      

      <modelVersion>4.0.0</modelVersion>

      <groupId>hygtest</groupId>
      <artifactId>aaa</artifactId>
      <packaging>pom</packaging>
      <version>1.0-SNAPSHOT</version>
      <modules>
      <module>aaaA</module>
      <module>aaaB</module>
      </modules>

      <profiles>
      <profile>
      <id>dev</id>
      <properties>
      <aaa-aaaA.version>1.0-DEV-SNAPSHOT</aaa-aaaA.version>
      <aaa-aaaB.version>1.0-DEV-SNAPSHOT</aaa-aaaB.version>
      <bbb-bbbA.version>1.0-DEV-SNAPSHOT</bbb-bbbA.version>
      </properties>
      <activation>
      <activeByDefault>true</activeByDefault>
      </activation>
      </profile>

      <profile>
      <id>qa</id>
      <properties>
      <aaa-aaaA.version>1.0-QA-SNAPSHOT</aaa-aaaA.version>
      <aaa-aaaB.version>1.0-QA-SNAPSHOT</aaa-aaaB.version>
      <bbb-bbbA.version>1.0-QA-SNAPSHOT</bbb-bbbA.version>
      </properties>
      </profile>

      <profile>
      <id>prod</id>
      <properties>
      <aaa-aaaA.version>1.0</aaa-aaaA.version>
      <aaa-aaaB.version>1.0</aaa-aaaB.version>
      <bbb-bbbA.version>1.0</bbb-bbbA.version>
      </properties>
      </profile>

      </profiles>

       

      submodule aaaA like this

      //代码占位符
      

      <parent>
      <artifactId>aaa</artifactId>
      <groupId>hygtest</groupId>
      <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>

      <artifactId>aaa-A</artifactId>

      <version>${aaa-aaaA.version}</version>

      <dependencies>
      <dependency>
      <groupId>hygtest</groupId>
      <artifactId>bbb-A</artifactId>
      <version>${bbb-bbbA.version}</version>
      </dependency>
      </dependencies>

       

      submodule aaaB like this

       

      //代码占位符
      

      <parent>
      <artifactId>aaa</artifactId>
      <groupId>hygtest</groupId>
      <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>

      <artifactId>aaa-B</artifactId>

      <version>${aaa-aaaB.version}</version>

      <dependencies>
      <dependency>
      <groupId>hygtest</groupId>
      <artifactId>aaa-A</artifactId>
      <version>${aaa-aaaA.version}</version>
      </dependency>
      </dependencies>

       

      module relation like this

      aaa-B -->  aaa-A --> bbb-A

       

      when use Maven 3.2.3 to execute "mvn clean install -Dmaven.test.skip=true -P qa -U" show log like this 

      //代码占位符
      

      [INFO] Scanning for projects...
      [WARNING]
      [WARNING] Some problems were encountered while building the effective model for hygtest:aaa-A:jar:1.0-QA-SNAPSHOT
      [WARNING] 'version' contains an expression but should be a constant. @ hygtest:aaa-A:${aaa-aaaA.version}, /Users/huyg/Downloads/aaa/aaaA/pom.xml, line 14, column 14
      [WARNING]
      [WARNING] Some problems were encountered while building the effective model for hygtest:aaa-B:jar:1.0-QA-SNAPSHOT
      [WARNING] 'version' contains an expression but should be a constant. @ hygtest:aaa-B:${aaa-aaaB.version}, /Users/huyg/Downloads/aaa/aaaB/pom.xml, line 14, column 14
      [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] aaa
      [INFO] aaa-A
      [INFO] aaa-B
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building aaa 1.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ aaa —
      [INFO]
      [INFO] — maven-install-plugin:2.4:install (default-install) @ aaa —
      [INFO] Installing /Users/huyg/Downloads/aaa/pom.xml to /Users/huyg/.m2/repository/hygtest/aaa/1.0-SNAPSHOT/aaa-1.0-SNAPSHOT.pom
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building aaa-A 1.0-QA-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      Downloading: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb-A/1.0-QA-SNAPSHOT/maven-metadata.xml
      Downloading: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb/1.0-SNAPSHOT/maven-metadata.xml
      [INFO]
      [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ aaa-A —
      [INFO] Deleting /Users/huyg/Downloads/aaa/aaaA/target
      [INFO]
      [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ aaa-A —
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] Copying 0 resource
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ aaa-A —
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ aaa-A —
      [INFO] Not copying test resources
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:testCompile (default-testCompile) @ aaa-A —
      [INFO] Not compiling test sources
      [INFO]
      [INFO] — maven-surefire-plugin:2.12.4:test (default-test) @ aaa-A —
      [INFO] Tests are skipped.
      [INFO]
      [INFO] — maven-jar-plugin:2.4:jar (default-jar) @ aaa-A —
      [INFO] Building jar: /Users/huyg/Downloads/aaa/aaaA/target/aaa-A-1.0-QA-SNAPSHOT.jar
      [INFO]
      [INFO] — maven-install-plugin:2.4:install (default-install) @ aaa-A —
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaA/target/aaa-A-1.0-QA-SNAPSHOT.jar to /Users/huyg/.m2/repository/hygtest/aaa-A/1.0-QA-SNAPSHOT/aaa-A-1.0-QA-SNAPSHOT.jar
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaA/pom.xml to /Users/huyg/.m2/repository/hygtest/aaa-A/1.0-QA-SNAPSHOT/aaa-A-1.0-QA-SNAPSHOT.pom
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building aaa-B 1.0-QA-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      Downloading: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb-A/1.0-DEV-SNAPSHOT/maven-metadata.xml
      [INFO]
      [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ aaa-B —
      [INFO] Deleting /Users/huyg/Downloads/aaa/aaaB/target
      [INFO]
      [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ aaa-B —
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] Copying 0 resource
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ aaa-B —
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ aaa-B —
      [INFO] Not copying test resources
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:testCompile (default-testCompile) @ aaa-B —
      [INFO] Not compiling test sources
      [INFO]
      [INFO] — maven-surefire-plugin:2.12.4:test (default-test) @ aaa-B —
      [INFO] Tests are skipped.
      [INFO]
      [INFO] — maven-jar-plugin:2.4:jar (default-jar) @ aaa-B —
      [INFO] Building jar: /Users/huyg/Downloads/aaa/aaaB/target/aaa-B-1.0-QA-SNAPSHOT.jar
      [INFO]
      [INFO] — maven-install-plugin:2.4:install (default-install) @ aaa-B —
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaB/target/aaa-B-1.0-QA-SNAPSHOT.jar to /Users/huyg/.m2/repository/hygtest/aaa-B/1.0-QA-SNAPSHOT/aaa-B-1.0-QA-SNAPSHOT.jar
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaB/pom.xml to /Users/huyg/.m2/repository/hygtest/aaa-B/1.0-QA-SNAPSHOT/aaa-B-1.0-QA-SNAPSHOT.pom
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO]
      [INFO] aaa ................................................ SUCCESS [ 0.322 s]
      [INFO] aaa-A .............................................. SUCCESS [ 1.148 s]
      [INFO] aaa-B .............................................. SUCCESS [ 0.082 s]
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 1.662 s
      [INFO] Finished at: 2020-09-11T18:39:43+08:00
      [INFO] Final Memory: 14M/308M
      [INFO] ------------------------------------------------------------------------

       

       

      the info 

      "Building aaa-A 1.0-QA-SNAPSHOT"

      "Downloading: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb-A/1.0-QA-SNAPSHOT/maven-metadata.xml"

      is correct

       

      but the info 

      "Building aaa-B 1.0-QA-SNAPSHOT"

      "Downloading: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb-A/1.0-DEV-SNAPSHOT/maven-metadata.xml"

      is wrong

       

      when use Maven 3.6.1 to execute "mvn clean install -Dmaven.test.skip=true -P qa -U" show log like this 

      //代码占位符
      

      [INFO] Scanning for projects...
      [WARNING]
      [WARNING] Some problems were encountered while building the effective model for hygtest:aaa-A:jar:1.0-QA-SNAPSHOT
      [WARNING] 'version' contains an expression but should be a constant. @ hygtest:aaa-A:${aaa-aaaA.version}, /Users/huyg/Downloads/aaa/aaaA/pom.xml, line 14, column 14
      [WARNING]
      [WARNING] Some problems were encountered while building the effective model for hygtest:aaa-B:jar:1.0-QA-SNAPSHOT
      [WARNING] 'version' contains an expression but should be a constant. @ hygtest:aaa-B:${aaa-aaaB.version}, /Users/huyg/Downloads/aaa/aaaB/pom.xml, line 14, column 14
      [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] aaa [pom]
      [INFO] aaa-A [jar]
      [INFO] aaa-B [jar]
      [INFO]
      [INFO] ---------------------------< hygtest:aaa >----------------------------
      [INFO] Building aaa 1.0-SNAPSHOT [1/3]
      [INFO] -------------------------------[ pom ]--------------------------------
      [INFO]
      [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ aaa —
      [INFO]
      [INFO] — maven-install-plugin:2.4:install (default-install) @ aaa —
      [INFO] Installing /Users/huyg/Downloads/aaa/pom.xml to /Users/huyg/.m2/repository/hygtest/aaa/1.0-SNAPSHOT/aaa-1.0-SNAPSHOT.pom
      [INFO]
      [INFO] --------------------------< hygtest:aaa-A >---------------------------
      [INFO] Building aaa-A 1.0-QA-SNAPSHOT [2/3]
      [INFO] -------------------------------[ jar ]--------------------------------
      Downloading from nexus: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb-A/1.0-QA-SNAPSHOT/maven-metadata.xml
      Downloading from nexus: http://mvn2.qdingnet.com/nexus/content/groups/public/hygtest/bbb/1.0-SNAPSHOT/maven-metadata.xml
      [INFO]
      [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ aaa-A —
      [INFO] Deleting /Users/huyg/Downloads/aaa/aaaA/target
      [INFO]
      [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ aaa-A —
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] Copying 0 resource
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ aaa-A —
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ aaa-A —
      [INFO] Not copying test resources
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:testCompile (default-testCompile) @ aaa-A —
      [INFO] Not compiling test sources
      [INFO]
      [INFO] — maven-surefire-plugin:2.12.4:test (default-test) @ aaa-A —
      [INFO] Tests are skipped.
      [INFO]
      [INFO] — maven-jar-plugin:2.4:jar (default-jar) @ aaa-A —
      [INFO] Building jar: /Users/huyg/Downloads/aaa/aaaA/target/aaa-A-1.0-QA-SNAPSHOT.jar
      [INFO]
      [INFO] — maven-install-plugin:2.4:install (default-install) @ aaa-A —
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaA/target/aaa-A-1.0-QA-SNAPSHOT.jar to /Users/huyg/.m2/repository/hygtest/aaa-A/1.0-QA-SNAPSHOT/aaa-A-1.0-QA-SNAPSHOT.jar
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaA/pom.xml to /Users/huyg/.m2/repository/hygtest/aaa-A/1.0-QA-SNAPSHOT/aaa-A-1.0-QA-SNAPSHOT.pom
      [INFO]
      [INFO] --------------------------< hygtest:aaa-B >---------------------------
      [INFO] Building aaa-B 1.0-QA-SNAPSHOT [3/3]
      [INFO] -------------------------------[ jar ]--------------------------------
      [INFO]
      [INFO] — maven-clean-plugin:2.5:clean (default-clean) @ aaa-B —
      [INFO] Deleting /Users/huyg/Downloads/aaa/aaaB/target
      [INFO]
      [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ aaa-B —
      [INFO] Using 'UTF-8' encoding to copy filtered resources.
      [INFO] Copying 0 resource
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ aaa-B —
      [INFO] Nothing to compile - all classes are up to date
      [INFO]
      [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ aaa-B —
      [INFO] Not copying test resources
      [INFO]
      [INFO] — maven-compiler-plugin:3.1:testCompile (default-testCompile) @ aaa-B —
      [INFO] Not compiling test sources
      [INFO]
      [INFO] — maven-surefire-plugin:2.12.4:test (default-test) @ aaa-B —
      [INFO] Tests are skipped.
      [INFO]
      [INFO] — maven-jar-plugin:2.4:jar (default-jar) @ aaa-B —
      [INFO] Building jar: /Users/huyg/Downloads/aaa/aaaB/target/aaa-B-1.0-QA-SNAPSHOT.jar
      [INFO]
      [INFO] — maven-install-plugin:2.4:install (default-install) @ aaa-B —
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaB/target/aaa-B-1.0-QA-SNAPSHOT.jar to /Users/huyg/.m2/repository/hygtest/aaa-B/1.0-QA-SNAPSHOT/aaa-B-1.0-QA-SNAPSHOT.jar
      [INFO] Installing /Users/huyg/Downloads/aaa/aaaB/pom.xml to /Users/huyg/.m2/repository/hygtest/aaa-B/1.0-QA-SNAPSHOT/aaa-B-1.0-QA-SNAPSHOT.pom
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary:
      [INFO]
      [INFO] aaa 1.0-SNAPSHOT ................................... SUCCESS [ 0.442 s]
      [INFO] aaa-A 1.0-QA-SNAPSHOT .............................. SUCCESS [ 1.472 s]
      [INFO] aaa-B 1.0-QA-SNAPSHOT .............................. SUCCESS [ 0.046 s]
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 2.097 s
      [INFO] Finished at: 2020-09-11T18:41:23+08:00
      [INFO] ------------------------------------------------------------------------

       

       

      when maven 2.3.2, i think the parent active profile was not inherited in as follow situations.

      aaa-B -->  aaa-A --> bbb-A

       

      Please help to determine whether this situation is a bug,

      I need to go to other departments based on the feedback and ask them to upgrade.

        Attachments

        1. bbb.zip
          13 kB
          huyonggang
        2. aaa.zip
          18 kB
          huyonggang

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              yonggang huyonggang
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: