buildr 1.5.3-x86-mswin32 → 1.5.4-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +25 -1
  3. data/addon/buildr/bnd.rb +8 -2
  4. data/addon/buildr/findbugs.rb +2 -2
  5. data/addon/buildr/gpg.rb +7 -1
  6. data/addon/buildr/gwt.rb +41 -1
  7. data/addon/buildr/jacoco.rb +18 -18
  8. data/addon/buildr/jetty.rb +14 -5
  9. data/addon/buildr/jetty6.rb +243 -0
  10. data/addon/buildr/org/apache/buildr/Jetty6Wrapper$1.class +0 -0
  11. data/addon/buildr/org/apache/buildr/Jetty6Wrapper$BuildrHandler.class +0 -0
  12. data/addon/buildr/org/apache/buildr/Jetty6Wrapper.class +0 -0
  13. data/addon/buildr/org/apache/buildr/Jetty6Wrapper.java +144 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  15. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper.java +13 -13
  17. data/buildr.buildfile +7 -1
  18. data/doc/contributing.textile +0 -19
  19. data/doc/download.textile +18 -6
  20. data/doc/index.textile +20 -12
  21. data/doc/languages.textile +23 -1
  22. data/doc/packaging.textile +21 -0
  23. data/lib/buildr/ide/idea.rb +4 -2
  24. data/lib/buildr/java/commands.rb +1 -1
  25. data/lib/buildr/kotlin.rb +17 -0
  26. data/lib/buildr/kotlin/compiler.rb +282 -0
  27. data/lib/buildr/kotlin/org/apache/buildr/KotlinMessageCollector$1.class +0 -0
  28. data/lib/buildr/kotlin/org/apache/buildr/KotlinMessageCollector.class +0 -0
  29. data/lib/buildr/kotlin/org/apache/buildr/KotlinMessageCollector.java +46 -0
  30. data/lib/buildr/packaging/archive.rb +47 -11
  31. data/lib/buildr/packaging/package.rb +3 -2
  32. data/lib/buildr/packaging/tar.rb +51 -16
  33. data/lib/buildr/packaging/ziptask.rb +45 -17
  34. data/lib/buildr/version.rb +1 -1
  35. data/spec/addon/bnd_spec.rb +80 -20
  36. data/spec/kotlin/compiler_spec.rb +274 -0
  37. data/spec/packaging/archive_spec.rb +30 -0
  38. data/spec/sandbox.rb +1 -0
  39. metadata +13 -3
  40. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d30858dd6f577fd87d406b73df5febca172787ba
4
- data.tar.gz: 43ce49c0bd10b9c408360e1c6883f6f36e3a475d
3
+ metadata.gz: ac5e3f8ba0f3128efadd90c51ab9fbc786a66aec
4
+ data.tar.gz: 395bb3c11efaed1ae9d80c88c02a89c0f07b0697
5
5
  SHA512:
6
- metadata.gz: 186c23b382fc34d1237694ee013528f5801c57f974cd1e2eb563562b0f16f779dea5c0a96ce2b8638fc40522cad8ce3215b84b3667058fe36c7080fc02026690
7
- data.tar.gz: 6fb9dd78b3e8c03d129b9d340d8aab16e79ea214ba03086077517098daab73833ca6a1c4a856139e84e06aea4039975c13fa92a0c16d42b0221352aa0b41f073
6
+ metadata.gz: 8d8c9caeb3884c3b052b2ef0353f8822cb7217be59ca93ffeb770bef0b438a1bb6b433f928e7a63e04a00bf9b507a28e8bbff5741c8d80bc4530b9ce642a4fee
7
+ data.tar.gz: 90e0461c245d903f602c902080be000136fc56e9b4e14e44cf2a951b6009a9055b151933c9378203257dfe0af64b59f74e91729ed91b7f0d2f623abf9c8710c3
data/CHANGELOG CHANGED
@@ -1,3 +1,27 @@
1
+ 1.5.4 (2017-11-29)
2
+ * Added: Findbugs Addon: Upgrade to version 3.0.1 of findbugs.
3
+ * Added: GPG Addon: Add boolean configuration setting `project.gpg` that can be set to false via
4
+ `project.gpg = false` to avoid signing and uploading packages. This is useful when some
5
+ projects are not intended for publishing.
6
+ * Fixed: JaCoCo Addon: Projects that have jacoco disabled will no longer appear in the JaCoCo reports.
7
+ * Change: JaCoCo Addon: Update JaCoCo version to 0.7.9.
8
+ * Fixed: BUILDR-733 - Escape classpath entries in the pathing jar manifest. Submitted by Glenn Croes.
9
+ * Fixed: Ensure that the pom is attached to the jar artifact with empty classifier rather than the last
10
+ artifact of a type defined. Otherwise a project that defines multiple artifacts of the same type
11
+ (i.e. `package(:jar)` and `package(:jar, :classifier => :gwt)`) could have the pom named after
12
+ the package with the classifier rather than the package without a classifer. (i.e. the pom could
13
+ be incorrectly defined as `mypackage-1.0.0-gwt.pom` rather than `mypackage-1.0.0.pom`).
14
+ * Added: GWT Addon: Add support for GWT 2.8.2 release and make it the default version unless otherwise specified.
15
+ * Added: GWT Addon: Added support for `:js_exports` boolean to enable "JsInteropExports".
16
+ * Added: IDEA Extension: Added support for `:open_in_browser` boolean passed to `ipr.add_gwt_configuration`
17
+ * Added: BUILDR-732 - Support bnd version 2.1.0 or more. Submitted By Eric Bruneton.
18
+ * Added: Support to compiling Kotlin
19
+ * Fixed: Remove section on development builds in the Contributing section.
20
+ * Added: New way to concatenate file contents when merging several archives together.
21
+ * Added: New way to transform file contents when merging several archives together.
22
+ * Fixed: Removed .class files from being checked in.
23
+ * Added: Support both Jetty 6 and Jetty 9 as addons. Added integration tests to cover their use.
24
+
1
25
  1.5.3 (2017-05-17)
2
26
  * Change: Add support for gwt 2.8.1 to gwt addon.
3
27
  * Fixed: Avoid error "undefined local variable or method `pom'" when invoking the `JarTask` without it being
@@ -10,7 +34,7 @@
10
34
 
11
35
  1.5.1 (2017-03-11)
12
36
  * Change: In the 'buildr/git_auto_version' addon strip out any versions that start with a 'v' character as
13
- most projects on git repositories prefix version tags with a "v" to avoid collisions with any branchs
37
+ most projects on git repositories prefix version tags with a "v" to avoid collisions with any branches
14
38
  named after the version which are typically without the "v" character.
15
39
  * Fixed: GWT Addon: The GWT project publishes invalid jars that can not be included on source path when
16
40
  the javadoc tool is executing. Work around this issue in GWT by removing them from the documentation
@@ -27,7 +27,13 @@ module Buildr
27
27
 
28
28
  # The specs for requirements
29
29
  def dependencies
30
- ["biz.aQute:bnd:jar:#{version}"]
30
+ if Gem::Version.new(version) <= Gem::Version.new('1.50.0')
31
+ ["biz.aQute:bnd:jar:#{version}"]
32
+ elsif Gem::Version.new(version) <= Gem::Version.new('2.4.0')
33
+ ["biz.aQute.bnd:bnd:jar:#{version}"]
34
+ else
35
+ ["biz.aQute.bnd:biz.aQute.bnd:jar:#{version}"]
36
+ end
31
37
  end
32
38
 
33
39
  def bnd_main(*args)
@@ -110,7 +116,7 @@ module Buildr
110
116
 
111
117
  Buildr::Bnd.bnd_main( bnd_filename )
112
118
  begin
113
- Buildr::Bnd.bnd_main('print', '-verify', filename )
119
+ Buildr::Bnd.bnd_main('print', '-v', filename )
114
120
  rescue => e
115
121
  rm filename
116
122
  raise e
@@ -23,10 +23,10 @@ module Buildr
23
23
  # The specs for requirements
24
24
  def dependencies
25
25
  %w(
26
- com.google.code.findbugs:findbugs:jar:3.0.0
26
+ com.google.code.findbugs:findbugs:jar:3.0.1
27
27
  com.google.code.findbugs:jFormatString:jar:3.0.0
28
28
  com.google.code.findbugs:bcel-findbugs:jar:6.0
29
- com.google.code.findbugs:annotations:jar:3.0.0
29
+ com.google.code.findbugs:annotations:jar:3.0.1
30
30
  org.ow2.asm:asm-debug-all:jar:5.0.2
31
31
  commons-lang:commons-lang:jar:2.6
32
32
  dom4j:dom4j:jar:1.6.1
@@ -72,8 +72,14 @@ module Buildr
72
72
  module ProjectExtension
73
73
  include Extension
74
74
 
75
+ attr_writer :gpg
76
+
77
+ def gpg?
78
+ @gpg.nil? ? true : !!@gpg
79
+ end
80
+
75
81
  after_define do |project|
76
- Buildr::GPG.sign_and_upload_all_packages(project)
82
+ Buildr::GPG.sign_and_upload_all_packages(project) if project.gpg?
77
83
  end
78
84
  end
79
85
  end
@@ -22,7 +22,7 @@ module Buildr
22
22
  end
23
23
 
24
24
  def version
25
- @version || Buildr.settings.build['gwt'] || '2.8.1'
25
+ @version || Buildr.settings.build['gwt'] || '2.8.2'
26
26
  end
27
27
 
28
28
  # The specs for requirements
@@ -93,6 +93,42 @@ module Buildr
93
93
  com.ibm.icu:icu4j:jar:50.1.1
94
94
  tapestry:tapestry:jar:4.0.2
95
95
 
96
+ javax.annotation:javax.annotation-api:jar:1.2
97
+ javax.servlet:javax.servlet-api:jar:3.1.0
98
+ org.eclipse.jetty:jetty-annotations:jar:9.2.14.v20151106
99
+ org.eclipse.jetty:jetty-continuation:jar:9.2.14.v20151106
100
+ org.eclipse.jetty:jetty-http:jar:9.2.14.v20151106
101
+ org.eclipse.jetty:jetty-io:jar:9.2.14.v20151106
102
+ org.eclipse.jetty:jetty-jndi:jar:9.2.14.v20151106
103
+ org.eclipse.jetty:jetty-plus:jar:9.2.14.v20151106
104
+ org.eclipse.jetty:jetty-security:jar:9.2.14.v20151106
105
+ org.eclipse.jetty:jetty-server:jar:9.2.14.v20151106
106
+ org.eclipse.jetty:jetty-servlet:jar:9.2.14.v20151106
107
+ org.eclipse.jetty:jetty-servlets:jar:9.2.14.v20151106
108
+ org.eclipse.jetty:jetty-util:jar:9.2.14.v20151106
109
+ org.eclipse.jetty:jetty-webapp:jar:9.2.14.v20151106
110
+ org.eclipse.jetty:jetty-xml:jar:9.2.14.v20151106
111
+ org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1.M0
112
+ ) + validation_deps
113
+ elsif v == '2.8.2'
114
+ %w(
115
+ com.google.jsinterop:jsinterop-annotations:jar:1.0.1
116
+ com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.1
117
+ org.w3c.css:sac:jar:1.3
118
+ com.google.gwt:gwt-dev:jar:2.8.2
119
+ com.google.gwt:gwt-user:jar:2.8.2
120
+ com.google.code.gson:gson:jar:2.6.2
121
+ org.ow2.asm:asm:jar:5.0.3
122
+ org.ow2.asm:asm-util:jar:5.0.3
123
+ org.ow2.asm:asm-tree:jar:5.0.3
124
+ org.ow2.asm:asm-commons:jar:5.0.3
125
+ colt:colt:jar:1.2.0
126
+ ant:ant:jar:1.6.5
127
+ commons-collections:commons-collections:jar:3.2.2
128
+ commons-io:commons-io:jar:2.4
129
+ com.ibm.icu:icu4j:jar:50.1.1
130
+ tapestry:tapestry:jar:4.0.2
131
+
96
132
  javax.annotation:javax.annotation-api:jar:1.2
97
133
  javax.servlet:javax.servlet-api:jar:3.1.0
98
134
  org.eclipse.jetty:jetty-annotations:jar:9.2.14.v20151106
@@ -150,6 +186,10 @@ module Buildr
150
186
  args << '-XenableClosureCompiler'
151
187
  end
152
188
 
189
+ if options[:js_exports]
190
+ args << '-generateJsInteropExports'
191
+ end
192
+
153
193
  args += modules
154
194
 
155
195
  properties = options[:properties] ? options[:properties].dup : {}
@@ -18,7 +18,7 @@ module Buildr
18
18
  # WARNING: Experimental and may change radically.
19
19
  module JaCoCo
20
20
  class << self
21
- VERSION = '0.7.2.201409121644'
21
+ VERSION = '0.7.9'
22
22
 
23
23
  def version
24
24
  @version || Buildr.settings.build['jacoco'] || VERSION
@@ -37,7 +37,7 @@ module Buildr
37
37
  "org.jacoco:org.jacoco.report:jar:#{version}",
38
38
  "org.jacoco:org.jacoco.core:jar:#{version}",
39
39
  "org.jacoco:org.jacoco.ant:jar:#{version}",
40
- 'org.ow2.asm:asm-debug-all:jar:5.0.1'
40
+ 'org.ow2.asm:asm-debug-all:jar:5.2'
41
41
  ]
42
42
  end
43
43
  end
@@ -146,21 +146,21 @@ module Buildr
146
146
  desc 'Generate JaCoCo reports.'
147
147
  task 'reports' do
148
148
  Buildr.ant 'jacoco' do |ant|
149
- ant.taskdef(:resource => 'org/jacoco/ant/antlib.xml') do |ant|
149
+ ant.taskdef(:resource => 'org/jacoco/ant/antlib.xml') do
150
150
  ant.classpath :path => Buildr.artifacts(Buildr::JaCoCo.ant_spec).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
151
151
  end
152
- ant.report do |ant|
153
- ant.executiondata do |ant|
152
+ ant.report do
153
+ ant.executiondata do
154
154
  ant.file :file => project.jacoco.destfile
155
155
  end
156
156
 
157
- ant.structure(:name => project.name) do |ant|
157
+ ant.structure(:name => project.name) do
158
158
  if project.compile.target
159
- ant.classfiles do |ant|
159
+ ant.classfiles do
160
160
  ant.fileset :dir => project.compile.target
161
161
  end
162
162
  end
163
- ant.sourcefiles(:encoding => 'UTF-8') do |ant|
163
+ ant.sourcefiles(:encoding => 'UTF-8') do
164
164
  project.compile.sources.each do |path|
165
165
  ant.fileset :dir => path.to_s
166
166
  end
@@ -179,25 +179,25 @@ module Buildr
179
179
  namespace 'jacoco' do
180
180
  desc 'Generate JaCoCo reports.'
181
181
  task 'report' do
182
- Buildr.ant 'jacoco' do |ant|
183
- ant.taskdef(:resource => 'org/jacoco/ant/antlib.xml') do |ant|
182
+ Buildr.ant('jacoco') do |ant|
183
+ ant.taskdef(:resource => 'org/jacoco/ant/antlib.xml') do
184
184
  ant.classpath :path => Buildr.artifacts(Buildr::JaCoCo.ant_spec).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
185
185
  end
186
- ant.report do |ant|
187
- ant.executiondata do |ant|
188
- Buildr.projects.each do |project|
186
+ ant.report do
187
+ ant.executiondata do
188
+ Buildr.projects.select{|p|p.jacoco.enabled?}.each do |project|
189
189
  ant.fileset :file=>project.jacoco.destfile if File.exist?(project.jacoco.destfile)
190
190
  end
191
191
  end
192
192
 
193
- ant.structure(:name => 'Jacoco Report') do |ant|
194
- ant.classfiles do |ant|
195
- Buildr.projects.map(&:compile).map(&:target).flatten.map(&:to_s).each do |src|
193
+ ant.structure(:name => 'Jacoco Report') do
194
+ ant.classfiles do
195
+ Buildr.projects.select{|p|p.jacoco.enabled?}.map(&:compile).map(&:target).flatten.map(&:to_s).each do |src|
196
196
  ant.fileset :dir=>src.to_s if File.exist?(src)
197
197
  end
198
198
  end
199
- ant.sourcefiles(:encoding => 'UTF-8') do |ant|
200
- Buildr.projects.map(&:compile).map(&:sources).flatten.map(&:to_s).each do |src|
199
+ ant.sourcefiles(:encoding => 'UTF-8') do
200
+ Buildr.projects.select{|p|p.jacoco.enabled?}.map(&:compile).map(&:sources).flatten.map(&:to_s).each do |src|
201
201
  ant.fileset :dir=>src.to_s if File.exist?(src)
202
202
  end
203
203
  end
@@ -39,13 +39,22 @@ module Buildr
39
39
  class Jetty
40
40
 
41
41
  # Which version of Jetty we're using by default (change with options.jetty.version).
42
- VERSION = "6.1.3"
43
- SLF4J_VERSION = "1.4.3"
42
+ VERSION = '9.4.6.v20170531'
43
+ SLF4J_VERSION = '1.7.25'
44
44
 
45
45
  # Libraries used by Jetty.
46
- REQUIRES = [ "org.mortbay.jetty:jetty:jar:#{VERSION}", "org.mortbay.jetty:jetty-util:jar:#{VERSION}",
47
- "org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
48
- "org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}", "org.slf4j:jcl104-over-slf4j:jar:#{SLF4J_VERSION}" ]
46
+ REQUIRES = [ "org.eclipse.jetty:jetty-server:jar:#{VERSION}",
47
+ "org.eclipse.jetty:jetty-webapp:jar:#{VERSION}",
48
+ "org.eclipse.jetty:jetty-http:jar:#{VERSION}",
49
+ "org.eclipse.jetty:jetty-util:jar:#{VERSION}",
50
+ "org.eclipse.jetty:jetty-io:jar:#{VERSION}",
51
+ "org.eclipse.jetty:jetty-servlet:jar:#{VERSION}",
52
+ "org.eclipse.jetty:jetty-security:jar:#{VERSION}",
53
+ "org.eclipse.jetty:jetty-xml:jar:#{VERSION}",
54
+ "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
55
+ "org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}",
56
+ "org.slf4j:jcl-over-slf4j:jar:#{SLF4J_VERSION}",
57
+ 'javax.servlet:javax.servlet-api:jar:3.1.0' ]
49
58
 
50
59
  Java.classpath << REQUIRES
51
60
  Java.classpath << File.dirname(__FILE__)
@@ -0,0 +1,243 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ require 'uri'
17
+ require 'net/http'
18
+ require 'thread'
19
+
20
+ module Buildr
21
+
22
+ # Provides a collection of tasks and methods for using Jetty, specifically as a server
23
+ # for testing your application.
24
+ #
25
+ # Build files should always start Jetty by invoking the #use task, typically as
26
+ # a prerequisite. This task will start Jetty once during the build, and shut it down
27
+ # when the build completes.
28
+ #
29
+ # If you want to keep Jetty running across builds, and look at error messages, you can
30
+ # start Jetty in a separate console with:
31
+ # buildr jetty:start
32
+ # To stop this instance of Jetty, simply kill the process (Ctrl-C) or run:
33
+ # buildr jetty:stop
34
+ #
35
+ # If you start Jetty separately from the build, the #use task will connect to that
36
+ # existing server. Since you are using Jetty across several builds, you will want to
37
+ # cleanup any mess created by each build. You can use the #setup and #teardown tasks,
38
+ # which are called when Jetty is first used in the build, and when the build ends.
39
+ class Jetty6
40
+
41
+ # Which version of Jetty we're using by default (change with options.jetty.version).
42
+ VERSION = "6.1.3"
43
+ SLF4J_VERSION = "1.4.3"
44
+
45
+ # Libraries used by Jetty.
46
+ REQUIRES = [ "org.mortbay.jetty:jetty:jar:#{VERSION}", "org.mortbay.jetty:jetty-util:jar:#{VERSION}",
47
+ "org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
48
+ "org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}", "org.slf4j:jcl104-over-slf4j:jar:#{SLF4J_VERSION}" ]
49
+
50
+ Java.classpath << REQUIRES
51
+ Java.classpath << File.dirname(__FILE__)
52
+
53
+ # Default URL for Jetty (change with options.jetty.url).
54
+ URL = "http://localhost:8080"
55
+
56
+ class << self
57
+
58
+ # :call-seq:
59
+ # instance() => Jetty
60
+ #
61
+ # Returns an instance of Jetty.
62
+ def instance()
63
+ @instance ||= Jetty6.new("jetty", URL)
64
+ end
65
+
66
+ end
67
+
68
+ def initialize(name, url) #:nodoc:
69
+ @url = url
70
+ namespace name do
71
+ @setup = task("setup")
72
+ @teardown = task("teardown")
73
+ @use = task("use") { fire }
74
+ end
75
+ end
76
+
77
+ # The URL for the Jetty server. Leave as is if you want to use the default server
78
+ # (http://localhost:8080).
79
+ attr_accessor :url
80
+
81
+ # :call-seq:
82
+ # start(pipe?)
83
+ #
84
+ # Starts Jetty. This method does not return, it keeps the thread running until
85
+ # Jetty is stopped. If you want to run Jetty parallel with other tasks in the build,
86
+ # invoke the #use task instead.
87
+ def start(sync = nil)
88
+ begin
89
+ puts "classpath #{Java.classpath.inspect}"
90
+ port = URI.parse(url).port
91
+ puts "Starting Jetty at http://localhost:#{port}" if verbose
92
+ Java.load
93
+ jetty = Java.org.apache.buildr.Jetty6Wrapper.new(port)
94
+ sync << "Started" if sync
95
+ sleep # Forever
96
+ rescue Interrupt # Stopped from console
97
+ rescue Exception=>error
98
+ puts "#{error.class}: #{error.message}"
99
+ end
100
+ exit! # No at_exit
101
+ end
102
+
103
+ # :call-seq:
104
+ # stop()
105
+ #
106
+ # Stops Jetty. Stops a server running in a separate process.
107
+ def stop()
108
+ uri = URI.parse(url)
109
+ begin
110
+ Net::HTTP.start(uri.host, uri.port) do |http|
111
+ http.request_post "/buildr/stop", ""
112
+ end
113
+ rescue Errno::ECONNREFUSED
114
+ # Expected if Jetty server not running.
115
+ rescue EOFError
116
+ # We get EOFError because Jetty is brutally killed.
117
+ end
118
+ puts "Jetty server stopped"
119
+ end
120
+
121
+ # :call-seq:
122
+ # running?() => boolean
123
+ #
124
+ # Returns true if it finds a running Jetty server that supports the Buildr
125
+ # requests for deploying, stopping, etc.
126
+ def running?()
127
+ uri = URI.parse(url)
128
+ begin
129
+ Net::HTTP.start(uri.host, uri.port) do |http|
130
+ response = http.request_get("/buildr/")
131
+ response.is_a?(Net::HTTPSuccess) && response.body =~ /Alive/
132
+ end
133
+ rescue Errno::ECONNREFUSED, Errno::EBADF
134
+ false
135
+ end
136
+ end
137
+
138
+ # :call-seq:
139
+ # deploy(url, webapp) => path
140
+ #
141
+ # Deploy a WAR in the specified URL.
142
+ def deploy(url, webapp)
143
+ use.invoke
144
+ uri = URI.parse(url)
145
+ Net::HTTP.start(uri.host, uri.port) do |http|
146
+ response = http.request_post("/buildr/deploy", "webapp=#{webapp}&path=#{uri.path}")
147
+ if Net::HTTPOK === response && response.body =~ /Deployed/
148
+ path = response.body.split[1]
149
+ puts "Deployed #{webapp}, context path #{uri.path}" if trace?
150
+ path
151
+ else
152
+ fail "Deployment failed: #{response}"
153
+ end
154
+ end
155
+ end
156
+
157
+ # :call-seq:
158
+ # undeploy(url) => boolean
159
+ #
160
+ # Undeploys a WAR from the specified URL.
161
+ def undeploy(url)
162
+ use.invoke
163
+ uri = URI.parse(url)
164
+ Net::HTTP.start(uri.host, uri.port) do |http|
165
+ response = http.request_post("/buildr/undeploy", "path=#{uri.path}")
166
+ if Net::HTTPOK === response && response.body =~ /Undeployed/
167
+ true
168
+ else
169
+ fail "Deployment failed: #{response}"
170
+ end
171
+ end
172
+ end
173
+
174
+ # :call-seq:
175
+ # setup(*prereqs) => task
176
+ # setup(*prereqs) { |task| .. } => task
177
+ #
178
+ # This task executes when Jetty is first used in the build. You can use it to
179
+ # deploy artifacts into Jetty.
180
+ def setup(*prereqs, &block)
181
+ @setup.enhance prereqs, &block
182
+ end
183
+
184
+ # :call-seq:
185
+ # teardown(*prereqs) => task
186
+ # teardown(*prereqs) { |task| .. } => task
187
+ #
188
+ # This task executes when the build is done. You can use it to undeploy artifacts
189
+ # previously deployed into Jetty.
190
+ def teardown(*prereqs, &block)
191
+ @teardown.enhance prereqs, &block
192
+ end
193
+
194
+ # :call-seq:
195
+ # use(*prereqs) => task
196
+ # use(*prereqs) { |task| .. } => task
197
+ #
198
+ # If you intend to use Jetty, invoke this task. It will start a new instance of
199
+ # Jetty and close it when the build is done. However, if you already have a server
200
+ # running in the background (e.g. jetty:start), it will use that server and will
201
+ # not close it down.
202
+ def use(*prereqs, &block)
203
+ @use.enhance prereqs, &block
204
+ end
205
+
206
+ protected
207
+
208
+ # If you want to start Jetty inside the build, call this method instead of #start.
209
+ # It will spawn a separate process that will run Jetty, and will stop Jetty when
210
+ # the build ends. However, if you already started Jetty from the console (with
211
+ # take jetty:start), it will use the existing instance without shutting it down.
212
+ def fire()
213
+ unless running?
214
+ sync = Queue.new
215
+ Thread.new { start sync }
216
+ # Wait for Jetty to fire up before doing anything else.
217
+ sync.pop == "Started" or fail "Jetty not started"
218
+ puts "Jetty started" if verbose
219
+ at_exit { stop }
220
+ end
221
+ @setup.invoke
222
+ at_exit { @teardown.invoke }
223
+ end
224
+
225
+ end
226
+
227
+ namespace "jetty" do
228
+ desc "Start an instance of Jetty running in the background"
229
+ task("start") { Jetty6.instance.start }
230
+ desc "Stop an instance of Jetty running in the background"
231
+ task("stop") { Jetty6.instance.stop }
232
+ end
233
+
234
+ # :call-seq:
235
+ # jetty() => Jetty
236
+ #
237
+ # Returns a Jetty object. You can use this to discover the Jetty#use task,
238
+ # configure the Jetty#setup and Jetty#teardown tasks, deploy and undeploy to Jetty.
239
+ def jetty()
240
+ @jetty ||= Jetty6.instance
241
+ end
242
+
243
+ end