Community
Participate
Working Groups
Create an blank plugin "plugin1", then a second plugin "plugin2" that depends on "plugin1" (plugin dependence). In some class in plugin1 (say, Activator) create a method public static void sayHi() { System.out.println("plugin1 says hi"); } Create a class in plugin2 that calls that method : public class Class1 { @Test public void mytest() { plugin1.Activator.sayHi(); } public static void main(String[] args) { (new Class1()).mytest(); } } Test that it runs ok, as Java app and as Junit test Then generate a ANT build.xml for plugin2: plugin2 -> Export -> General -> Ant BuildFiles Open the generated build.xml and try to run the Class1 target (either as Java app, or a Junit test). It fails java.lang.NoClassDefFoundError: plugin1/Activator Looking inside the build.xml I see <path id="Plug-in Dependencies.libraryclasspath"> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui_3.105.0.v20130522-1122.jar"/> .... <pathelement location="../../../../plugin1"/> </path> That last entry looks wrong; it misses the "bin/" and it can't imagine what's it's being relative to... If I manually change it to <pathelement location="../..plugin1/bin"/> then it works.
I think there is another related (but more fundamental issue). The classpath built in as <path id="Plug-in Dependencies.libraryclasspath"> element only gathers the dependent plugins as declared in the plugin. But this totally misses the transitive dependencies. Say plugin2 depends on plugin1. Some plugin2.Class2 class instances a plugin1.Class1 (exported by plugin1), and plugin1.Class1 instances/references a class exported from another plugin, from say, org.eclipse.emf.ecore*.jar . If plugin1 has included org.eclipse.emf.ecore*.jar among its dependencies, all compiles and runs ok (as it should). Specifically, I can see in the Eclipse debugger that when I run plugin2.Class2 the passed classpath includes org.eclipse.emf.ecore*.jar (because, I guess, it was computed as a transitive dependence). However, if I want to run plugin2.Class2 from some Ant task, and I use the classpath exported by Eclipse in build.xml, I will fail, because, as mentioned, org.eclipse.emf.ecore*.jar will not be included.
Created attachment 258437 [details] Example projects demonstrating this problem I've experienced the same issue with unit tests. They would run perfectly fine in command line with Tycho, but fail as soon as you try to run them in Eclipse PDE. However, importing one of project dependencies into Eclipse workspace has fixed the tests. Debugging has shown that Eclipse launch configuration lacks transitive dependencies from jar dependencies. To reproduce this problem - download and unzip projects - import them into a new workspace running Eclipse 4.5.1 - export `plugin1` as a deployable plug-in and add it to your target platform - run `plugin2` as an Eclipse application and witness that it works - close `plugin1` project and rerun `plugin2` to witness that it fails with unresolved dependencies I have expected Eclipse PDE to add transitive dependencies to the classpath.
Mass change for PDE Build bugs tagged with "helpwanted". PDE build is not actively enhanced, hence I close these bugs as wontfix. Please reopen if you want to contribute a patch.