Bug 20119

Summary: Run-time libraries exported through more than 2 plugins not in classpath
Product: [Eclipse Project] PDE Reporter: Antonin Pokorny <ap>
Component: BuildAssignee: Rodrigo Peretti <rodrigo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: ahunter
Version: 2.0Keywords: readme
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
example none

Description Antonin Pokorny CLA 2002-06-13 03:32:13 EDT
The operation "Create feature JAR" generates build.xml's
in plugins directories with missing runtime libraries
which are reexported through more than 2 plugins.

EXAMPLE:
   samplePluginA 
	lib/a.jar (exported)


   samplePluginB (depends on samplePluginA, dep. reexported)
	lib/b.jar (exported)


   samplePluginC (depends on samplePluginB, dep. reexported)

   samplePluginD (depends on samplePluginC, dep. reexported)

   sampleFeature (contains plugins A,B,C,D)

The action "Create Feature JAR" generates build.xml in pluginD
with the following contents:

	<target name="samplePluginD.jar" depends="init" 
unless="samplePluginD.jar">
		<property name="destdir" 
value="${temp.folder}/samplePluginD.jar.bin"/>
		<delete dir="${temp.folder}/samplePluginD.jar.bin"/>
		<mkdir dir="${temp.folder}/samplePluginD.jar.bin"/>
		<!-- compile the source code -->
		<javac destdir="${temp.folder}/samplePluginD.jar.bin" 
failonerror="false" verbose="true" debug="on" includeAntRuntime="no" 
bootclasspath="${bootclasspath}" 
classpath="../samplePluginC/samplePluginC.jar;../samplePluginB/lib/b.jar;../../p
lugins/org.eclipse.core.runtime_2.0.0/bin;../samplePluginB/bin;../samplePluginC/
bin;../../plugins/org.eclipse.core.boot_2.0.0/bin;../../plugins/org.eclipse.core
.runtime_2.0.0/runtime.jar;../../plugins/org.eclipse.core.boot_2.0.0/boot.jar;..
/samplePluginB/samplePluginB.jar">
			<src path="src/"/>
		</javac>
		<!-- copy necessary resources -->
		<copy todir="${temp.folder}/samplePluginD.jar.bin">
			<fileset dir="src/" excludes="**/*.java"/>
		</copy>
		<mkdir dir="${build.result.folder}"/>
		<jar jarfile="${build.result.folder}/samplePluginD.jar" 
basedir="${temp.folder}/samplePluginD.jar.bin"/>
		<delete dir="${temp.folder}/samplePluginD.jar.bin"/>
	</target>
	
I can find "../samplePluginB/lib/b.jar" in classpath, which is good, 
but "../samplePluginA/lib/a.jar"
which I would expect to be there is missing.

The whole example is attached.
Comment 1 Antonin Pokorny CLA 2002-06-13 03:33:10 EDT
Created attachment 1387 [details]
example
Comment 2 Rodrigo Peretti CLA 2002-06-13 11:19:27 EDT
Seems like a bug. Needs further investigation.
Comment 3 Rodrigo Peretti CLA 2002-06-14 14:54:46 EDT
Yes, it is a bug in AbstractBuildScriptGenerator.addPrerequisiteLibraries(). 
When a plug-in exports a pre-requisite, instead of calling the same method ( 
AbstractBuildScriptGenerator.addPrerequisiteLibraries() ) for its pre-
requisite, we only add its libraries (calling addLibraries()). So, if the pre-
requisite plug-in also exports another plug-in, it won't be added to the 
compile path.

The fix is trivial. We only need to call addPrerequisiteLibraries() instead of 
addLibraries(). Since addPrerequisiteLibraries() calls addLibraries() there is 
no major change in the algorithm.

Recommend fixing.
Comment 4 Nick Edgar CLA 2002-06-16 22:11:20 EDT
Is there any risk of encountering a project cycle in the proposed fix?
If so this could hang Eclipse.

Comment 5 Rodrigo Peretti CLA 2002-06-17 14:06:37 EDT
Yes, it could happen. Just tried and got a StackOverflowError (runtime-
workbench).
Comment 6 Rodrigo Peretti CLA 2002-06-17 14:26:44 EDT
Handling the project cycle would be a major change. Since the workaround is 
simple (writing a custom build.xml) we will defer the fix to after 2.0.

Workaround:

1) Generate a build.xml using PDE Build (Create Plug-in JARs)
2) Edit the build.properties with the following line:
   custom = true
3) Add the missing JARs to the build.xml (javac task)
4) Release the new build.properties and build.xml to the repository
Comment 7 DJ Houghton CLA 2002-06-17 14:44:55 EDT
Add to readme.
Comment 8 Rodrigo Peretti CLA 2002-07-09 14:42:33 EDT
Reopening.
Comment 9 Rodrigo Peretti CLA 2002-07-09 14:43:24 EDT
*** Bug 21405 has been marked as a duplicate of this bug. ***
Comment 10 Rodrigo Peretti CLA 2002-07-10 10:50:37 EDT
Fixed and released to HEAD. The cycle issue has also been handled. If a cycle 
is found a CoreException will be thrown.