lib/buildr/jetty.rb in buildr-1.1.3 vs lib/buildr/jetty.rb in buildr-1.2.0
- old
+ new
@@ -2,10 +2,11 @@
require "net/http"
require "core/project"
require "java/artifact"
require "java/java"
require "thread"
+#require "struct"
module Buildr
# Provides a collection of tasks and methods for using Jetty, specifically as a server
# for testing your application.
@@ -14,45 +15,46 @@
# a prerequisite. This task will start Jetty once during the build, and shut it down
# when the build completes.
#
# If you want to keep Jetty running across builds, and look at error messages, you can
# start Jetty in a separate console with:
- # rake jetty:start
+ # buildr jetty:start
# To stop this instance of Jetty, simply kill the process (Ctrl-C) or run:
- # rake jetty:stop
+ # buildr jetty:stop
#
# If you start Jetty separately from the build, the #use task will connect to that
# existing server. Since you are using Jetty across several builds, you will want to
# cleanup any mess created by each build. You can use the #setup and #teardown tasks,
# which are called when Jetty is first used in the build, and when the build ends.
class Jetty
+ # Which version of Jetty we're using by default (change with options.jetty.version).
+ VERSION = "6.1.3"
+
+ # Libraries used by Jetty.
+ REQUIRES = [ "org.mortbay.jetty:jetty:jar:#{VERSION}", "org.mortbay.jetty:jetty-util:jar:#{VERSION}",
+ "org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "log4j:log4j:jar:1.2.13", "commons-logging:commons-logging:jar:1.1" ]
+ Java.rjb.onload { |rjb| rjb.classpath << REQUIRES << File.join(__DIR__, "jetty") }
+
+ # Default URL for Jetty (change with options.jetty.url).
+ URL = "http://localhost:8080"
+
class << self
# :call-seq:
# instance() => Jetty
#
# Returns an instance of Jetty.
def instance()
- @instance ||= Jetty.new
+ @instance ||= Jetty.new("jetty", URL)
end
end
- # Artifacts required to run Jetty.
- REQUIRES = [ "org.mortbay.jetty:jetty:jar:6.1.1", "org.mortbay.jetty:jetty-util:jar:6.1.1",
- "org.mortbay.jetty:servlet-api-2.5:jar:6.1.1", "log4j:log4j:jar:1.2.13",
- "commons-logging:commons-logging:jar:1.1" ]
-
- Java.rjb.classpath << REQUIRES << File.join(__DIR__, "jetty")
-
- # Default URL for Jetty.
- URL = "http://localhost:8080"
-
- def initialize() #:nodoc:
- @url = URL
- namespace "jetty" do
+ def initialize(name, url) #:nodoc:
+ @url = url
+ namespace name do
@setup = task("setup")
@teardown = task("teardown")
@use = task("use") { fire }
end
end
@@ -212,19 +214,15 @@
task("start") { Jetty.instance.start }
desc "Stop an instance of Jetty running in the background"
task("stop") { Jetty.instance.stop }
end
- class Project
-
- # :call-seq:
- # jetty() => Jetty
- #
- # Returns a Jetty object. You can use this to discover the Jetty#use task,
- # configure the Jetty#setup and Jetty#teardown tasks, deploy and undeploy to Jetty.
- def jetty()
- @jetty ||= Jetty.instance
- end
-
+ # :call-seq:
+ # jetty() => Jetty
+ #
+ # Returns a Jetty object. You can use this to discover the Jetty#use task,
+ # configure the Jetty#setup and Jetty#teardown tasks, deploy and undeploy to Jetty.
+ def jetty()
+ @jetty ||= Jetty.instance
end
-
+
end