mvn依赖项:树,多模块和$ {revision}

时间:2019-04-07 21:08:38

标签: maven maven-3

dependency:tree是否理解$ {revision}?

我有一个多模块项目X:

<groupId>org.X</groupId>
<artifactId>X-parent</artifactId>

<version>${revision}</version>
<properties>
    <revision>8.0.0-SNAPSHOT</revision>
</properties>

<modules>
    <module>X-A</module>
    :

它已安装到我的本地.m2(并且仅安装在本地)。

我有一个项目Y,该项目取决于X-A,版本8.0.0-SNAPSHOT

Y项目的pom还包括:

  <repositories>
        <repository>
          <id>rescarta</id>
          <url>http://software.rescarta.org/nexus/content/groups/public/</url>
        </repository>
    </repositories> 

当我在项目Y上运行mvndependency:tree时,它会抱怨:

$ mvn -U dependency:tree
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.0.1/maven-dependency-plugin-3.0.1.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.0.1/maven-dependency-plugin-3.0.1.pom (14 kB at 7.0 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.0.1/maven-dependency-plugin-3.0.1.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.0.1/maven-dependency-plugin-3.0.1.jar (164 kB at 186 kB/s)
[INFO] 
[INFO] -------------------< com.y:Y >-------------------
[INFO] Building Y 8.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from rescarta: http://software.rescarta.org/nexus/content/groups/public/org/x/X-A/8.0.0-SNAPSHOT/maven-metadata.xml
Downloading from rescarta: http://software.rescarta.org/nexus/content/groups/public/org/x/X-parent/$%7Brevision%7D/X-parent-$%7Brevision%7D.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/x/X-parent/$%7Brevision%7D/X-parent-$%7Brevision%7D.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.681 s
[INFO] Finished at: 2019-04-08T06:45:53+10:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Y: Could not resolve dependencies for project com.y:Y:jar:8.0.0-SNAPSHOT: Failed to collect dependencies at org.x:X-A:jar:8.0.0-SNAPSHOT: Failed to read artifact descriptor for org.x:X-A:jar:8.0.0-SNAPSHOT: Could not find artifact org.x:X-parent:pom:${revision} in rescarta (http://software.rescarta.org/nexus/content/groups/public/) -> [Help 1]

请注意,它正在尝试下载org.x:X-parent:pom:$ {revision},而不是org.x:X-parent:pom:8.0.0-SNAPSHOT

dependency:tree是否不知道如何解析$ {revision}?

1 个答案:

答案 0 :(得分:0)

https://stackoverflow.com/a/52173650/1031689中说明的flatten-maven-plugin似乎是一种有效的解决方法。