This project is dead. I enjoyed pursuing the idea, but it turns out to be a dead-end.
A command line tool for creating a Ruby Gem from a Java package including all of its dependencies.
Required command line arguments:
- -g, --group Maven group identifier of Java library
- -n, --name Name of Java library
- -v, --version Version of Java library
- -u, --uber-gem Create a single gem containing all of the Java dependencies. (Building skinny gems has issues.)
Optional command line arguments:
- -h, --help Show help
- -o, --output Directory to write the Ruby Gem into (defaults to current working directory)
- -r, --repository Extra Maven repository URL to read from
Example run:
$ lein run --uber-gem --group org.apache.poi --name poi-ooxml --version 3.8
The output is two files:
-
org.apache.poi,poi-ooxml-3.8-java.gem
-
poi-ooxml.gemspec
Gem::Specification.new do |s| s.date = "2013-03-04" s.require_paths = ["lib"] s.name = "org.apache.poi,poi-ooxml" s.version = "3.8" s.homepage = "https://github.com/bruceadams/java-gem" s.files = ["lib/stax-api-1.0.1.jar", "lib/poi-ooxml-schemas-3.8.jar", "lib/xmlbeans-2.3.0.jar", "lib/xml-apis-1.0.b2.jar", "lib/dom4j-1.6.1.jar", "lib/poi-3.8.jar", "lib/commons-codec-1.5.jar", "lib/poi-ooxml-3.8.jar", "lib/poi-ooxml.rb"] s.authors = ["unknown"] s.summary = "RubyGem wrapper for Java package poi-ooxml" s.description = "Autogenerated RubyGem wrapper for org.apache.poi/poi-ooxml-3.8" s.platform = "java" end
and a lib
directory containing the Java jar
files and a generated
Ruby file that does a require
of each jar
file, lib/poi-ooxml.rb
require 'xml-apis-1.0.b2.jar'
require 'dom4j-1.6.1.jar'
require 'stax-api-1.0.1.jar'
require 'xmlbeans-2.3.0.jar'
require 'poi-ooxml-schemas-3.8.jar'
require 'commons-codec-1.5.jar'
require 'poi-3.8.jar'
require 'poi-ooxml-3.8.jar'
Alternate run mechanism:
-
Compile a standalone Java jar:
$ lein uberjar
-
Run the executable jar:
$ java -jar target/java-gem-1.0.0-SNAPSHOT-standalone.jar --uber-gem --group org.apache.poi --name poi-ooxml --version 3.8
Right now, this tool is a working proof of concept. The code needs to be cleaned up for legibility, with tests and error handling.
As a public demonstration, I have run this tool for several thousand artifacts in Maven Central and have the gems publically available here: http://javagems.org
http://javagems.org is just a static web site, with all the gems themselves in this directory http://javagems.org/gems/ and the rubygems specs, Marshal and related files as generated by:
gem generate_index
The list of Maven artifacts for which I generated gems for comes from
a quick (read: sloppy) attempt to grab the latest release version of
every jar
package in Maven Central.
Instead of generating a uber-gem, as it does now, generate a gem for each individual Java library with gem dependencies that match the Java dependencies.
Enhance this tool so it can run as a Ruby Gems server which will create gems on request. It could act as a Ruby Gem front-end server for a Maven server.
Copyright © 2012, 2013 Bruce Adams. Distributed under the Eclipse Public License, see LICENSE for details.