Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368059

Summary: In an eclipse-plugin project that wraps another jar, Maven->Update Project Configuration breaks the build path
Product: z_Archived Reporter: T Smith <thgsmith>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED NOT_ECLIPSE QA Contact:
Severity: normal    
Priority: P3 CC: igor, thgsmith
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Demo project which exhibits the bug none

Description T Smith CLA 2012-01-06 16:11:12 EST
Build Identifier: Version: Indigo Service Release 1.  Build id: 20110916-0149

I'm using Tycho 0.13.0 with "Apache Maven 3.0.2 (r1056850; 2011-01-08 19:58:10-0500)" (I think it's an Eclipse internal version), and m2e 1.0.100.20110804-1717.

I have lots of bundles that are merely wrappers of other, non-OSGi Java jars.  So for instance if I'm wrapping Google Guava, in the MANIFEST.MF, I'll have:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: google_guava
Bundle-SymbolicName: google_guava
Bundle-Version: 0.8.0
Bundle-ClassPath: guava-r08.jar
Export-Package: com.google.common.annotations;version="8.0.0",
 com.google.common.base;version="8.0.0",
 com.google.common.base.internal;version="8.0.0",
 com.google.common.collect;version="8.0.0",
 com.google.common.io;version="8.0.0",
 com.google.common.net;version="8.0.0",
 com.google.common.primitives;version="8.0.0",
 com.google.common.util.concurrent;version="8.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5

And build.properties is:

bin.includes = META-INF/,\
               guava-r08.jar

When I right-click on the project and select Maven->Update Project Configuration, I get the error "guava-r08.jar is not on its project's build path".  The project becomes broken in Eclipse, with an X on the MANIFEST file.  The error messages are like "Package 'com.google.common.annotations' does not exist in this plug-in".  When I run Update Project Configuration a second time, it fixes the problem again!

I investigated a bit, and found that running Update Project Configuration toggles the presence of these 3 lines in the project's .classpath:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="guava-r08.jar"/>

This is the only difference in the project directory between its broken and working states, according to diff.

So, to be clear, if I do something that will require an "update project configuration" run, I have to do it twice because the first time only breaks the project.  I can run it as many times as I want, and it always alternates broken and fixed.

Reproducible: Always

Steps to Reproduce:
Create a plug-in project in Eclipse, put a .jar in it, add it to the class path, re-export the packages from the .jar, create a minimal Tycho pom, run Configuration->Change to maven project.
Comment 1 T Smith CLA 2012-01-06 16:20:37 EST
Created attachment 209153 [details]
Demo project which exhibits the bug

Here is a wrapper-library version of Google Guava, which exhibits this bug for me.
Comment 2 Igor Fedorenko CLA 2012-01-06 16:24:43 EST
We've looked at this some time ago and came to the conclusion it was a bug in PDE. As you already found, running configuration update for the second time is the workaround. We do not plan to investigate this any further, but if you feel strongly enough about this problem, please provide a quality patch and we'll review and apply it.
Comment 3 T Smith CLA 2012-01-06 16:26:33 EST
*sigh* ok
Comment 4 Tobias Oberlies CLA 2012-01-07 05:07:06 EST
Should this bug be tracked in Tycho or m2e? Is the Tycho connector part of m2e@Eclipse, or is this still a Sonatype project?
Comment 5 Igor Fedorenko CLA 2012-01-07 06:07:20 EST
(In reply to comment #4)
> Should this bug be tracked in Tycho or m2e? Is the Tycho connector part of
> m2e@Eclipse, or is this still a Sonatype project?

This requires further investigation to determine the root cause of the problem and develop a workaround/solution. Whoever works on this investigation will need to decide what components needs fixes (pde, m2e/tycho or m2e) and either reclassify this bug accordingly or create secondary bug report or more then one component needs to be fixed/changed. 

I do not believe the problem is related to tycho itself.

m2e/tycho is not an eclipse project.
Comment 6 Igor Fedorenko CLA 2013-09-29 09:55:13 EDT
This has been fixed recently in m2e-tycho integration, which is not NOT_ECLIPSE project.
Comment 7 Denis Roy CLA 2021-04-19 13:27:24 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/