sam / doubleshot

Build and Dependency Management for mixed Java/Ruby projects.
MIT License
19 stars 22 forks source link

Need to add compiled classes to the $CLASSPATH of packaged gems #29

Closed sam closed 11 years ago

sam commented 11 years ago

Even though Java sources are compiled, and the target folder is added to your packaged Gem, the folder is not on the default $CLASSPATH, so your Gem can't use it.

Doubleshot#setup! and Doubleshot::Compiler#build! both do that, but since you don't require Doubleshot in your packaged Gem you're not calling those methods (and you shouldn't be, so that's correct).

Still, we need to somehow inject something into the Gem that will make the appropriate modification for you. Perhaps using Gem::Specification#autorequire.

sam commented 11 years ago

Here's what we've decided: Create an "überjar" containing your compiled sources, and the unpacked versions of any JAR dependencies. The developer/user will then be required to require "hello_world.jar" somewhere in their Ruby source, where the JAR name is determined by your project-name.

Since your packaged gems don't have a runtime dependency on Doubleshot, you'd need to require your JAR dependencies anyway. This way instead of requiring 20 JARs, you can just require one, and as a bonus, it also includes your compiled Java so you don't have to futz with putting folders containing .class files onto your $CLASSPATH.

As a side-effect, implementing this means we'll have also implemented packaging an überjar containing everything but your Ruby source, which will be an easy addition for later when we implement doubleshot jar.

sam commented 11 years ago

This was resolved in 7d72dbd90b386361e6e0fbbe115b1792f63da5e3.