我们正在开发一个 Eclipse RCP 应用程序。我们决定使用SVN作为版本控制系统。我们可以在 eclipse 环境中导出 eclipse 产品。一切正常。
但是,
我们的一些插件依赖于在其manifest.mf中使用bundle-classpath的常规java jar。到目前为止,我们正在将这些 jar 提交到 SVN 存储库中。我们“听说”将 jar 提交到 svn 是错误的,我们应该使用 maven-tycho 并将这些 jar 放入 Maven 存储库中以实现此目的。
因此,我们将 jar 从 SVN 存储库移至 Maven 存储库。然后我们想设置一个新的开发环境,我们从 svn 检查了项目,他们有编译错误,因为我们没有 jars!
我们使用m2eclipse并在我新创建的pom.xml文件中定义所有依赖项。 maven-dependency-plugin 的复制目标并列出所有 jar,然后运行 mvn validate 将 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。我只需要将常规 jar 复制到本地库即可。我的其他插件已经作为插件项目与其所有源代码并排存在。我不需要他们的 jar 。我可以过滤掉那些吗?我尝试过但没有成功:
<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>
谢谢
最佳答案
您需要决定是否要复制传递依赖项。
maven-dependency-plugin [1] 允许复制传递依赖项(“复制依赖项”目标,需要仅在 pom 中将依赖项添加到依赖项部分)或仅复制某些没有传递依赖项的 Artifact (“复制”目标,需要仅将 Artifact 添加到插件的配置部分)。 使用复制依赖项时,您还可以在传递依赖项链中包含/排除某些artifactId,请参阅[2]。
--
[1] http://maven.apache.org/plugins/maven-dependency-plugin/
[2] http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html
关于maven - 如何将 Bundle-classpath jar 及其依赖项从 Maven 存储库复制到我的本地 lib 文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6607805/