我們正在開發一個Eclipse RCP應用程序。我們決定使用SVN作爲版本控制系統。我們可以在eclipse環境中導出一個eclipse產品。一切正常。如何將Bundle-classpath jar及其從maven repo的依賴項複製到我的本地lib文件夾中?
但是,
我們的一些插件有依賴於使用捆的classpath在他們的MANIFEST.MF普通的Java罐子。到目前爲止,我們正在將這些jar提交到SVN倉庫。我們「聽說」將sar放入svn是錯誤的,我們應該使用maven-tycho,並將這些jar放入maven倉庫中以達到此目的。
所以我們把jar從SVN倉庫移到Maven倉庫。然後我們想要建立一個新的開發環境,我們檢查了svn的項目,並且因爲我們沒有罐子而出現編譯錯誤!
我們使用了m2eclipse並定義了我剛創建的pom.xml文件中的所有依賴關係。 maven-dependency-plugin的副本目標並列出所有jar文件,然後運行mvn驗證以將jar文件導入到我們的lib文件夾中。它的工作,但在我看來有點醜陋。因爲我的插件的pom.xml看起來像定義兩次每個依賴:
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-bundle-classpath-libs</id>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>MyGroup</groupId>
<artifactId>MyJar</artifactId>
<version>SNAPSHOT</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>MyGroup</groupId>
<artifactId>MyJar</artifactId>
<version>SNAPSHOT</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
</dependencies>
有沒有擺脫這樣的方式?
此外,如果MyJar.pom有其他依賴我也需要他們在我的本地庫。有沒有辦法將這些傳遞性依賴項複製到我的本地lib文件夾?
我試過複製依賴目標,但它試圖找到我的插件依賴的其他插件的罐子。我只需要將常規的jar複製到我的本地lib中。我的其他插件已經與其所有源代碼並肩作爲插件項目。我不需要他們的罐子。我可以過濾掉嗎?我想這沒有成功:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<excludeGroupIds>MyGroup</excludeGroupIds>
<outputDirectory>lib</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<stripVersion>true</stripVersion>
</configuration>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>validate</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
感謝
我想複製依賴的目標是我想要的。我絕對想要傳遞依賴。但我不希望插件依賴項,因爲我將它們作爲一個項目。 – lembas
我試過了excludeArtifactIds或者excludeGroupIds,但它仍然給出了同樣的錯誤:無法執行項目目標XYZPlugin:無法解析項目MyGroup的依賴關係:XYZPlugin:eclipse-plugin:1.0.0-SNAPSHOT:無法解析以下工件:MyGroup:ABCPlugin:jar:1.0.0-SNAPSHOT,在http:// myrepo/public中緩存在本地存儲庫中,直到my-public的更新間隔過去或強制更新後纔會重新解析分辨率。 – lembas