Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355947 - Optional dependencies broken in recent Tycho build
Summary: Optional dependencies broken in recent Tycho build
Status: RESOLVED DUPLICATE of bug 351842
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-26 09:13 EDT by Markus Kuppe CLA
Modified: 2021-04-28 16:54 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Kuppe CLA 2011-08-26 09:13:42 EDT
With commit https://github.com/sonatype/sonatype-tycho/commit/048054f214925d79ad376f7ec452893d424d7e19 Tycho does not resolve optional dependencies anymore, which causes builds to fail.

[INFO] --- tycho-compiler-plugin:0.13.0-SNAPSHOT:compile (default-compile) @ org.lamport.tlatools ---
[INFO] Using compile source roots from build.properties
[INFO] Compiling 385 source files to /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/target/classes
----------
1. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/util/SimpleFilenameToStreamTest.java (at line 5)
	import junit.framework.TestCase;
	       ^^^^^
The import junit cannot be resolved
----------
2. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/util/SimpleFilenameToStreamTest.java (at line 7)
	public class SimpleFilenameToStreamTest extends TestCase {
	                                                ^^^^^^^^
TestCase cannot be resolved to a type
----------
3. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/util/SimpleFilenameToStreamTest.java (at line 16)
	assertNotNull(file);
	^^^^^^^^^^^^^
The method assertNotNull(File) is undefined for the type SimpleFilenameToStreamTest
----------
4. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/util/SimpleFilenameToStreamTest.java (at line 17)
	assertTrue(file.getAbsolutePath() + " does not exist!", file.exists());
	^^^^^^^^^^
The method assertTrue(String, boolean) is undefined for the type SimpleFilenameToStreamTest
----------
----------
5. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/util/ByteUtilsTest.java (at line 11)
	import junit.framework.TestCase;
	       ^^^^^
The import junit cannot be resolved
----------
6. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/util/ByteUtilsTest.java (at line 19)
	public class ByteUtilsTest extends TestCase
	                                   ^^^^^^^^
TestCase cannot be resolved to a type
----------
7. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/util/ByteUtilsTest.java (at line 37)
	super.setUp();
	^^^^^
TestCase cannot be resolved to a type
----------
----------
8. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/tool/distributed/TLCWorkerSmartProxyTest.java (at line 9)
	import junit.framework.TestCase;
	       ^^^^^
The import junit cannot be resolved
----------
9. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/tool/distributed/TLCWorkerSmartProxyTest.java (at line 11)
	public class TLCWorkerSmartProxyTest extends TestCase {
	                                             ^^^^^^^^
TestCase cannot be resolved to a type
----------
10. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/tool/distributed/TLCWorkerSmartProxyTest.java (at line 19)
	assertTrue(doTest(calculationDuration, new DummyTLCState[ONE]) > 0);
	^^^^^^^^^^
The method assertTrue(boolean) is undefined for the type TLCWorkerSmartProxyTest
----------
11. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/tool/distributed/TLCWorkerSmartProxyTest.java (at line 24)
	assertTrue(doTest(calculationDuration, new DummyTLCState[ONE]) > 0);
	^^^^^^^^^^
The method assertTrue(boolean) is undefined for the type TLCWorkerSmartProxyTest
----------
12. ERROR in /usr/local/src/tla/tla/trunk/tla2-inria/tlatools/test/tlc2/tool/distributed/TLCWorkerSmartProxyTest.java (at line 29)
	assertTrue(doTest(calculationDuration, new DummyTLCState[ONE]) > 0);
	^^^^^^^^^^
...

Manifest.mf:

Require-Bundle: org.aspectj.runtime;bundle-version="1.6.0";resolution:=optional,
 org.junit;bundle-version="3.8.0";resolution:=optional
Comment 1 Igor Fedorenko CLA 2011-08-26 10:26:57 EDT
Can you confirm the problem was not present at https://github.com/sonatype/sonatype-tycho/commit/4393caf41c9e1968d2711b97fda4cdea021814d2 ?

In case, jars.extra.classpath can be used to force compile-only dependencies.
Comment 2 Markus Kuppe CLA 2011-08-26 10:29:57 EDT
(In reply to comment #1)
> Can you confirm the problem was not present at
> https://github.com/sonatype/sonatype-tycho/commit/4393caf41c9e1968d2711b97fda4cdea021814d2
> ?

I will check, but it will take a while.

> In case, jars.extra.classpath can be used to force compile-only dependencies.

In pom.xml?
Comment 3 Igor Fedorenko CLA 2011-08-26 10:44:25 EDT
(In reply to comment #2)
> 
> > In case, jars.extra.classpath can be used to force compile-only dependencies.
> 
> In pom.xml?

No, in build.properties http://help.eclipse.org/indigo/topic/org.eclipse.pde.doc.user/reference/pde_feature_generating_build.htm
Comment 4 Kai Kreuzer CLA 2011-08-26 17:09:08 EDT
> > Can you confirm the problem was not present at
> > https://github.com/sonatype/sonatype-tycho/commit/4393caf41c9e1968d2711b97fda4cdea021814d2
> > ?

I can confirm, my build was still working with the 0.13.0-SNAPSHOT from August 25.

The problem seems to be that Equinox p2 Juno treats optional dependencies non-greedy now, on indigo it was by default a greedy behaviour (see bug 247099). Unfortunately, this change now also impacts the scope during compile time, which was most likely not intended.

I have created a very simple project to easily reproduce the problem: https://github.com/openhab/tycho-testing

Note that you can work around it by defining the optional dependency as greedy. This is done by specifying "resolution:=optional;x-installation:=greedy" in the manifest for the dependency in question.

Hope this helps!
Kai
Comment 5 Tobias Oberlies CLA 2011-08-30 07:39:38 EDT
(In reply to comment #4)
> The problem seems to be that Equinox p2 Juno treats optional dependencies
> non-greedy now, on indigo it was by default a greedy behaviour (see bug 247099).
> Unfortunately, this change now also impacts the scope during compile time, which
> was most likely not intended.
This is correct. Greedy should only affect installation, but not compilation. Unfortunately this is an open issue in Tycho: bug 351842.

> Note that you can work around it by defining the optional dependency as greedy.
> This is done by specifying "resolution:=optional;x-installation:=greedy" in the
> manifest for the dependency in question.
This is a very bad idea, because this has an impact on your users: if the optionally required bundle is common (e.g. part of Indigo), it will be installed whenever your users install your bundle. If it is however truely optional, you should give your users the choice to install it by creating two features: one with just your bundle(s) and one with your bundles and requirements to the optional stuff.

*** This bug has been marked as a duplicate of bug 351842 ***