Skip to Content

Problems to compile a bundle with an import from a split bundle/package

Posted in

Hi,
consider the following example:
OSGI bundle with one source file wdg.java:

package wdg;
import org.eclipse.core.runtime.Path;
public class wdg {
	public Path p = new Path("filePath");
}

MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Wdg
Bundle-SymbolicName: wdg
Bundle-Version: 1.0.0
Import-Package: org.eclipse.core.runtime;version="3.4.0"

This compiles fine under eclipse.

Using a4e to build with the following build.xml

<?xml version="1.0"?>
<project name="wdg"
         basedir="."
         default="build"
         xmlns:antcontrib="antlib:net.sf.antcontrib"
	     xmlns:ant4eclipse="antlib:org.ant4eclipse">
 
	<taskdef resource="net/sf/antcontrib/antlib.xml" />
    <taskdef uri="antlib:org.ant4eclipse"
	           resource="org/ant4eclipse/ant/antlib.xml" />
	<import file="${basedir}/a4e-pde-macros.xml" />
	<property name="workspaceDirectory" value="${basedir}/.." />
 
	<target name="build" >
		<ant4eclipse:installedJREs>
			<jre id="jdk1.6.0_18" location="C:/Programme/Java/jdk1.6.0_18" />
		</ant4eclipse:installedJREs>
 
		<ant4eclipse:targetPlatform id="eclipse">
			<location dir="D:\TargetPlatforms\eclipse-SDK-3.5.2-win32\eclipse" />
		</ant4eclipse:targetPlatform>
 
		<buildPlugin 
			workspaceDirectory="${workspaceDirectory}"
			projectname="wdg"
			targetPlatformId="eclipse"
			destination="${basedir}/destination"
		/>
	</target>
</project>

yields to an error:
Buildfile: D:\workspaces\a4e_hellorcp\wdg\build.xml
build:
[ant4eclipse:executeJdtProject] Trying to read bundles and feature from 'workspace'.
[ant4eclipse:executeJdtProject] Needed 0 ms to read 2 bundles and 1 features from bundle set.
[ant4eclipse:executeJdtProject] Trying to read bundles and feature from 'target platform location 'D:\TargetPlatforms\eclipse-SDK-3.5.2-win32\eclipse''.
[ant4eclipse:executeJdtProject] Needed 734 ms to read 366 bundles and 15 features from bundle set.
     [echo] Scrubbing directory 'D:\workspaces\a4e_hellorcp\wdg\bin'
   [delete] Deleting directory D:\workspaces\a4e_hellorcp\wdg\bin
    [mkdir] Created dir: D:\workspaces\a4e_hellorcp\wdg\bin
     [echo] Compiling pde project 'wdg'
     [echo]   - source directories -> D:\workspaces\a4e_hellorcp\wdg\src
     [echo]   - output directories -> D:\workspaces\a4e_hellorcp\wdg\bin
     [echo]   - bootclasspath      -> C:\Programme\Java\jdk1.6.0_18\jre\lib\resources.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\rt.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\jsse.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\jce.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\charsets.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\ext\dnsns.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\ext\localedata.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\ext\sunjce_provider.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\ext\sunmscapi.jar;C:\Programme\Java\jdk1.6.0_18\jre\lib\ext\sunpkcs11.jar
     [echo]   - classpath          -> D:\TargetPlatforms\eclipse-SDK-3.5.2-win32\eclipse\plugins\org.eclipse.core.runtime_3.5.0.v20090525.jar;D:\workspaces\a4e_hellorcp\wdg\bin
[ant4eclipse:jdtCompiler] Compiling 1 source file 'D:\workspaces\a4e_hellorcp\wdg\src\wdg\wdg.java' to 'D:\workspaces\a4e_hellorcp\wdg\bin' !
[ant4eclipse:jdtCompiler] ----------
[ant4eclipse:jdtCompiler] 1. ERROR in D:\workspaces\a4e_hellorcp\wdg\src\wdg\wdg.java (at line 2)
[ant4eclipse:jdtCompiler] import org.eclipse.core.runtime.Path;
[ant4eclipse:jdtCompiler]        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ant4eclipse:jdtCompiler] The import org.eclipse.core.runtime.Path cannot be resolved
[ant4eclipse:jdtCompiler] ----------
[ant4eclipse:jdtCompiler] 2. ERROR in D:\workspaces\a4e_hellorcp\wdg\src\wdg\wdg.java (at line 4)
[ant4eclipse:jdtCompiler] 	public Path p = new Path("filePath");
[ant4eclipse:jdtCompiler] 	       ^^^^
[ant4eclipse:jdtCompiler] Path cannot be resolved to a type
[ant4eclipse:jdtCompiler] ----------
[ant4eclipse:jdtCompiler] 3. ERROR in D:\workspaces\a4e_hellorcp\wdg\src\wdg\wdg.java (at line 4)
[ant4eclipse:jdtCompiler] 	public Path p = new Path("filePath");
[ant4eclipse:jdtCompiler] 	                    ^^^^
[ant4eclipse:jdtCompiler] Path cannot be resolved to a type
[ant4eclipse:jdtCompiler] ----------
 
BUILD FAILED
D:\workspaces\a4e_hellorcp\wdg\build.xml:28: The following error occurred while executing this line:
D:\workspaces\a4e_hellorcp\wdg\a4e-pde-macros.xml:141: The following error occurred while executing this line:
D:\workspaces\a4e_hellorcp\wdg\a4e-pde-macros.xml:165: org.ant4eclipse.lib.core.exception.Ant4EclipseException: Compilation was not successful.
 
Total time: 2 seconds

This might have to do with split bundle/packages. "org.eclipse.core.runtime.Path" is not in the bundle
"org.eclipse.core.runtime", but in "org.eclipse.equinox.common" where parts of the package "org.eclipse.core.runtime"
are, see the MANIFEST.MF of "org.eclipse.equinox.common".

I get the bundle to compile fine with a4e, if I add "org.eclipse.runtime" as required bundle and not as imported package.
MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Wdg
Bundle-SymbolicName: wdg
Bundle-Version: 1.0.0
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0"

Is this a bug? Shall I open a jira?

Best regards,
Georg.

Take a look

Hi Georg,

it already has been reported: http://www.ant4eclipse.org/node/115

It's not fixed yet, but I hope I will have some time to fix this one in the next two weeks...

Regards,Gerd