如何将Bundle-classpath jar及其依赖项从maven repo复制到我的本地lib文件夹?

时间:2011-07-07 08:30:23

标签: maven eclipse-rcp tycho maven-dependency-plugin

我们正在开发 Eclipse RCP 应用程序。我们决定使用 SVN 作为修订控制系统。我们可以在eclipse环境中导出eclipse产品。一切都很好。

但是,

我们的一些插件依赖于manifest.mf中使用 bundle-classpath 的常规Java jar。到目前为止,我们将这些罐子提交到SVN存储库。我们“听说”将jar提交到svn是错误的,我们应该使用 maven-tycho 并将这些jar放入maven存储库中。

因此我们将jar从SVN存储库移动到Maven存储库。然后我们想要设置一个新的开发环境,我们检查了svn的项目,他们有编译错误,因为我们没有罐子!

我们使用 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中也需要它们。有没有办法将这些传递依赖项复制到我的本地lib文件夹

我尝试了 copy-dependencies目标,但它试图找到我的插件所依赖的其他插件的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>

由于

1 个答案:

答案 0 :(得分:1)

您需要决定是否要复制传递依赖项。

maven-dependency-plugin [1]允许复制传递依赖(“复制依赖”目标,只需要在pom中添加依赖部分的依赖)或者只是某些没有传递依赖的工件(“复制”目标,需要仅在插件的配置部分添加工件。 使用复制依赖项时,您还可以在传递依赖关系链中包含/排除某些artifactIds,请参阅[2]。

-

[1] http://maven.apache.org/plugins/maven-dependency-plugin/

[2] http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

相关问题