3

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?

oberlies
  • 11,503
  • 4
  • 63
  • 110
lembas
  • 377
  • 1
  • 7
  • 21

2 Answers2

2

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.

Thomas
  • 1,085
  • 9
  • 14
  • Thank you. I placed into the . Now I can copy transitive-dependencies to my local lib. But together with the org.eclipse.*.jar. Is there a way to exclude them? I chose validate step because I want to copy dependencies to my local lib folder manually. I will try to cancel validate step later – lembas Jul 25 '11 at 12:34
  • For example I tried org.eclipse.core to exclude org.eclipse.core.jobs.jar but it does not work. It still copies org.eclipse.core.jobs.jar to my local lib folder. – lembas Jul 25 '11 at 14:31
  • I am sorry lembas, I had to edit my answer as it was completely wrong. If the configuration is outside the execution tag it simply means that this configuration is used by all executions, so your setup was right. Hope my new answer will help you, even if it only give you a hint that you are on the right way. Sadly I can not answer why it does not work in your circumstance. – Thomas Jul 25 '11 at 19:28
1

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

oberlies
  • 11,503
  • 4
  • 63
  • 110