开发者

How to Copy Bundle-classpath jars and their dependencies from maven repo to my local lib folder?

We are developing an Eclipse RCP application. We decided to use SVN for revision control system. We could export an eclipse product in the eclipse environment. Everything worked fine.

But,

Some of our plugins have dependencies to regular java jars using bundle-classpath in their manifest.mf. Up to now we were committing those jars into SVN repository. We "heard" that it is wrong to commit jars into svn and we should use maven-tycho and put those jars into a maven repository for this purpose.

So we moved the jars from SVN repository to Maven repository. Then we wanted to setup a fresh dev environment, we checked out projects from svn and they had compilation errors because we do not have jars!

We used m2eclipse and define all dependencies in my freshly created pom.xml files. maven-dependency-plugin's copy goal and list all the jars and then we run mvn validate to get the jars into our lib folder. It worked but it seems to me a bit ugly. Because my plugin's pom.xml looks like defining every dependency twice:

<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>

Is there a way to get rid of this?

Besides if MyJar.pom has other dependencies I need them too in my local lib. Is there a way to copy those transitive dependencies to my local lib folder?

I tried copy-dependencies goal but it tries to find my other plugins' jars that my plugin depends on. I just need the regular jars to be copied to my local lib. My other plugins are already there side by side with all their source code as a plugin project. I do not need their jars. Can I filter those out? I tried this without success:

        <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>
                &l开发者_Go百科t;stripVersion>true</stripVersion>
            </configuration>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Thanks


you need to decide whether you want transitive dependencies copied or not.

maven-dependency-plugin [1] allows to copy either transitive dependencies ("copy-dependencies" goal, need to add dependencies to dependencies section only in pom) or just certain artifacts without transitive dependencies ("copy" goal, need to add artifacts to plugin's configuration section only). When using copy-dependencies, you can also include/exclude certain artifactIds from the transitive dependency chain, see [2].

--

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜