Jnlp Ruby Gem version 0.7.0

A Ruby gem for encapsulating the content and resources referenced by Java Web Start jnlps and interacting with jnlp repositories managed by the maven-jnlp Eclipse plugin.

Complete rdoc available here: rdoc.info/projects/stepheneb/jnlp

Release History

For more information about the structure of Java Web Start see Sun's documentation

Examples:

Creating a new Jnlp::Jnlp object from a local Java Web Start jnlp file.

j = Jnlp::Jnlp.new("authoring.jnlp")

Creating a new Jnlp::Jnlp object from a Java Web Start jnlp referenced with a url.

j = Jnlp::Jnlp.new("http://jnlp.concord.org/dev/org/concord/maven-jnlp/otrunk-sensor/otrunk-sensor.jnlp")

Once the Jnlp::Jnlp object is created you can call Jnlp::Jnlp#cache_resources to create a local cache of all the jar and nativelib resources.

The structure of the cache directory and the naming using for the jar and nativelib files is the same as that used by the Java Web Start Download Servlet, see Sun's servlet guide.

Creating Jnlp::MavenJnlp objects that represent the resources deployed by a maven jnlp servlet.

Creating a Jnlp::MavenJnlp object that represents the all the resources deployed by a maven jnlp servlet.

require 'jnlp'
mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/')

This takes about 90s on a 3Mbps connection processing Concord's Maven Jnlp Web Start server.

You can now do this:

mj.maven_jnlp_families.length                        # => 26
mj.maven_jnlp_families[0].name                       # => "all-otrunk-snapshot"
mj.maven_jnlp_families[0].versions.length            # => 1568
mj.maven_jnlp_families[0].versions.first.version     # => "0.1.0-20070420.131610"
mj.maven_jnlp_families[0].snapshot_version           # => "0.1.0-20090327.222627"

mj.maven_jnlp_families[0].versions.last.url

# => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20090327.222627.jnlp"

mj.maven_jnlp_families[0].snapshot.url

# => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20090327.222627.jnlp"

mj.maven_jnlp_families[0].versions.first.url

# => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20070420.131610.jnlp"

Creating Jnlp::MavenJnlp objects that represent some all the resources deployed by a maven jnlp servlet.

You can pass in an options hash to limit the number of maven jnlp families parsed:

Example: passing in an optional array of maven jnlp families This will get all versions of each family.

mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/', 
     { :families => ['all-otrunk-snapshot', 'gui-testing'] })

mj.maven_jnlp_families.length

# => 2

Example: passing in an optional hash of maven jnlp families This will get all versions of each family.

mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/', 
     { :families => { 'all-otrunk-snapshot' => nil, 'gui-testing' => nil } })

mj.maven_jnlp_families.length

# => 2

Example: passing in an optional hash of maven jnlp families and specifying the versions of the jnlp urls to get for one family.

mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
     { :families => { 
       'all-otrunk-snapshot' => { :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] },
       'gui-testing' => nil }
     })
mjfs = mj.maven_jnlp_families
[mjfs.length, mjfs[0].versions.length, mjfs[1].versions.length]

# => [2, 2, 50]

Building the gem

The source code

The source code for the jnlp gem is on github.

git clone git://github.com/stepheneb/jnlp.git

Runtime dependencies

nokogiri '~> 1.4.0'

Development dependencies

rspec        '~> 2.5.0'
ci_reporter  '~> 1.6.4'

rake tasks

$ rake -T
rake doc:clobber_rdoc  # Remove RDoc HTML files
rake doc:rdoc          # Build RDoc HTML files
rake doc:rerdoc        # Rebuild RDoc HTML files
rake doc:yard          # Generate YARD Documentation
rake hudson:spec       # run the spec tests and generate JUnit XML reports (for integrating with a Hudson CIS server)
rake package           # generate the gem package: pkg/jnlp-0.7.0.gem
rake release           # push the packaged gem: jnlp-0.7.0.gem to rubygems.org
rake spec              # run spec tests (the default task)

Running the tests

JRuby:

jruby -S rake spec

MRI:

rake spec

Generating JUnit XML output for integrating with the Hudson CIS server:

rake hudson:spec

Running adhoc tests using the source code directly

Run an adhoc test in the file sample.rb in the same top-level directory as this source code by telling ruby to first add 'lib/' to the load path.

ruby -Ilib sample.rb

Building and installing the gem locally

rake package
gem install pkg/jnlp-<version>.gem

Releasing a new version to rubygems.org/

rake package
gem push pkg/jnlp-<version>.gem

TODO

Add tests for:

  • MavenJnlp features.

  • downloading and caching jars

  • re-generating original and local jnlps