Forum: JRuby Jetty in 2 lines

Posted by Michael Guymon (Guest)
on 2012-04-17 00:42
(Received via mailing list)
So I built a wrapper for Maven's Aether library (Naether) and then a
helper to access Jars (LockJar) and thought other JRubist might get a
kick out it.

To run the demo, you just need to gem install lock_jar and create a
index.html for Jetty in the dir you run IRB from.

Running Jetty in 2 lines In IRB (ok ok, 4 lines with requires):

   require 'rubygems'
   require 'lock_jar'
   LockJar.load(nil) { jar
'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308' }
   org.eclipse.jetty.embedded.FileServer.main([])

All the transitive dependencies will be downloaded from the Maven repos
and loaded into the classpath. The first time it runs Naether will chirp
about downloading the dependencies. Just have to start the demo Jetty
using FileServer and hit http://localhost:8080 to see the index.html you
created.

https://github.com/mguymon/naether
https://github.com/mguymon/lock_jar

--M
Posted by Don Werve (Guest)
on 2012-04-17 01:00
(Received via mailing list)
That looks seriously cool -- a jar equivalent of the Gemfile would go a 
long way towards making my life a lot happier.
Posted by kristian (Guest)
on 2012-04-17 04:04
(Received via mailing list)
https://github.com/mkristian/jbundler

I am about to push a gem

-Kristian
Posted by kristian (Guest)
on 2012-04-17 04:09
(Received via mailing list)
where do I find you libs ? maybe we can share things between jbundler
- somehow !

- Kristian
Posted by Michael Guymon (Guest)
on 2012-04-17 16:46
(Received via mailing list)
Naether provides a wrapper for Maven's Aether framework in Java and 
Ruby.

https://github.com/mguymon/naether

LockJar is built on top of Naether to provide functionality to freeze
resolved jars and load them into the classpath

https://github.com/mguymon/lock_jar
Posted by Michael Guymon (Guest)
on 2012-04-19 04:39
(Received via mailing list)
So taking a look at jbundler inspired me to add Bundler support to
lock_jar. I went a more direct route, adding shims directly into Bundler
so that LockJar would shadow Bundler calls. You just have to set jar
dependencies using a lock_jar block in a Gemfile. Running bundle install
will create a Gemfile.lock and a Jarfile.lock (with transitive
dependencies). When Bundle.require is called, the Jarfile.lock will be
loaded to the classpath.

Gemfile:

   # This is what modifies Bundler to trigger LockJar
   require 'lock_jar/bundler'

   gem "naether"

   group :development do
     gem "rspec", "~> 2.9.0"
   end

   # lockjar dsl that is used to create Jarfile.lock
   lock_jar do
     scope :test do
       jar 'junit:junit:jar:4.10'
     end

     pom 'spec/pom.xml', :scope => :compile
   end

Will produce a Gemfile.lock and Jarfile.lock for

   bundle install

and to load the classpath when Bundler loads gems

   require 'rubygems'
   require 'bundler'

   # This is what modifies Bundler to trigger LockJar
   require 'lock_jar/bundler'

   Bundler.require


The downside of this, all the shimming makes it brittle. It works for
the latest version of Bundler and future changes could break it.

--M

https://github.com/mguymon/lock_jar
Posted by kristian (Guest)
on 2012-04-19 15:50
(Received via mailing list)
On Thu, Apr 19, 2012 at 8:02 AM, Michael Guymon
<michael.guymon@gmail.com> wrote:
> require 'lock_jar/bundler'

where is this coming from ? it is not a "gem 'lock_jar'" in Gemfile !

- Kristian
Posted by Michael Guymon (Guest)
on 2012-04-19 16:00
(Received via mailing list)
The lock_jar gem needs to be installed before you could use it with 
Bundler
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.