lembas
lembas

Reputation: 487

How to exclude eclipse-plugin dependencies when copy-dependencies?

This is my second question in StackOverflow. First one was a bit long. I hope this time I can cut right to the point :)

Say Eclipse plugin project P depends on plugin R via Require-Bundle. So we have 2 projects in our Eclipse workspace.

And again, Eclipse plugin project P depends on a regular A.jar via Bundle-Classpath.

Finally, A.jar is in a maven repo with its POM and depends on B.jar.

I need to copy A.jar and B.jar to the local lib folder of P, but NOT R.jar.

In POM files GroupId of P and R is G. GroupIds of A and B is different but NOT G.

I don't understand why but copy-dependencies goal is searching for R.jar, fails when it cannot find it and does not copy A.jar or B.jar. I try to use excludeGroupIds but cannot succeed:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <configuration>
        <excludeGroupIds>G</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>
<dependencies>
    <dependency>
        <groupId>X</groupId>
        <artifactId>A</artifactId>
        <version>SNAPSHOT</version>
    </dependency>
</dependencies>

Is there a way to exclude eclipse-plugin dependencies?

Upvotes: 3

Views: 4403

Answers (2)

oberlies
oberlies

Reputation: 11723

Add <excludeScope>provided</excludeScope> to the maven-dependency-plugin configuration to exclude the dependencies generated by Tycho.

Upvotes: 1

Thomas
Thomas

Reputation: 1095

Did you try to invoke the copy-dependencies goal by hand?

mvn dependency:copy-dependencies

I have created a small maven jar project with your configuration. My project has org.eclipse.core.jobs as dependency. If I use <excludeGroupIds>org.eclipse.core</excludeGroupIds> the org.eclipse.core.jobs.jar is not copied but the transitive dependencies like org.eclipse.equinox.common.jar or org.eclipse.osgi.jar ore copied.

When I use <excludeGroupIds>org.eclipse.equinox</excludeGroupIds> only the org.eclipse.equinox.common.jar is not copied. So if I understood your problem right the <excludeGroupIds> should do what you want. Maybe you have a type error in your groupId?

I had one problem when I tried this: my first try went wrong because I only pasted your <excludeGroupIds>G</excludeGroupIds>. My second try did run as expected, but I misremembered that a mvn clean does not delete the lib folder so I first thought it went wrong.

Upvotes: 2

Related Questions