views:

222

answers:

4

Are there any ways to make javac use an existing OSGi-environment for the resolution of build-time dependencies instead of setting the classpath explicitely? I know I could write an OSGi-component that uses the Compiler-API of the JDK, but I think there should be a more straightforward solution.

Alternatively, if no such extension is available for javac, does ejc allow such a thing (usable from the command line; I'd be willing to accept an Equinox-only solution with ejc)?

+1  A: 

Have you considered using Maven to manage dependencies? There are plugins available for IDEs like Eclipse. You just need to map the resource servers, and the needed libraries in a pom.xml, and that is pretty much it.

-Jay

Jay
Maven won't handle hiding packages that aren't imported; they implicitly make all packages available from a dependency rather than the required subset.
AlBlue
A: 

I'm developing in the Lotus Expeditor Toolkit and Eclipse Plugin - It's a no-charge download. My build time and runtime classpaths are managed very easily by entries in the Manifests.

[disclaimer: I am an IBM employee.]

djna
+2  A: 

ant task to compile using osgi.

http://www.ohloh.net/p/osgijc

or here now I guess?

http://code.google.com/p/eclipseosgitools/

+1  A: 

You're missing out on the one obvious Java compiler that follows OSGi rules - Eclipse.

You can use Eclipse's compiler to do a headless build, but be warned, it's not for the faint-hearted.

Here's a simple tutorial on building with Eclipse and ant.

If you go down this path, I'd suggest looking at Tycho (the Maven sub-project for building OSGi stuff) and Buckminster, an Eclipse project.

hbunny