2016-03-01 45 views
0

分析下面是我使用的依賴關係樹:Maven的2和3的區別:用循環

[INFO] ------------------------------------------------------------------------ 
[INFO] Building PA 0.0.2-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ PA --- 
[INFO] myTest:PA:jar:0.0.2-SNAPSHOT 
[INFO] \- PC:PC:jar:0.0.1-SNAPSHOT:compile 
[INFO] \- myTest:PA:jar:0.0.1-SNAPSHOT:compile 

正如你可以看到,有一個循環:

PA > PC > PA 

使用Maven 2.2。 1:

mvn dependency:analyze 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Unnamed - myTest:PA:jar:0.0.2-SNAPSHOT 
[INFO] task-segment: [dependency:analyze] 
[INFO] ------------------------------------------------------------------------ 
... 
[INFO] No dependency problems found 

使用Maven 3.3.3:

mvn dependency:analyze 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building PA 0.0.2-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
... 
[INFO] --- maven-dependency-plugin:2.8:analyze (default-cli) @ PA --- 
[WARNING] Used undeclared dependencies found: 
[WARNING] myTest:PA:jar:0.0.1-SNAPSHOT:compile 

使用maven 3的分析需要我將PA作爲PA的依賴添加到自身。是否有可能具有maven 2使用maven 3的相同行爲?

+0

需要明確的是,沒有循環,導致最後的依賴有不同的版本。除此之外,你看起來有錯誤,你有兩個版本的相同工件「0.0.1-SNAPSHOT」和「0.0.2-SNAPSHOT」...... – khmarbaise

+0

你的設計出了問題。爲什麼一個神器取決於它自己? – Tunaki

+0

它不,PA取決於PC和PC取決於PA – jaypi

回答

0

下面是我用具有相同的結果作爲Maven 2的使用Maven 3解決方法:

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <configuration> 
        <ignoredDependencies> 
         <ignoredDependencie>${project.groupId}:${project.artifactId}::</ignoredDependencie> 
        </ignoredDependencies> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build>