buildr 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +45 -0
- data/README +4 -0
- data/lib/buildr.rb +15 -3
- data/lib/core/artifact.rb +22 -23
- data/lib/core/build.rb +52 -41
- data/lib/core/core.rb +119 -4
- data/lib/core/project.rb +213 -187
- data/lib/java/compile.rb +152 -174
- data/lib/java/eclipse.rb +79 -0
- data/lib/java/java.rb +39 -1
- data/lib/java/jetty.rb +123 -0
- data/lib/java/jetty/JettyWrapper$1.class +0 -0
- data/lib/java/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/java/jetty/JettyWrapper.class +0 -0
- data/lib/java/jetty/JettyWrapper.java +107 -0
- data/lib/java/openjpa.rb +8 -10
- data/lib/java/packaging.rb +65 -32
- data/lib/java/test.rb +121 -51
- data/lib/java/xmlbeans.rb +6 -4
- data/lib/tasks/filter.rb +15 -4
- data/lib/tasks/zip.rb +10 -36
- metadata +9 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,48 @@
|
|
1
|
+
0.18 (3/26/2007)
|
2
|
+
* Added: manifest attribute on project, used by default when packaging JAR/WAR.
|
3
|
+
* Added: default manifest includes build-by, build-jdk and implementation-title.
|
4
|
+
* Added: compile.from(sources) in the same vein as compile.with(classpath)
|
5
|
+
* Added: load all *.rake files form the tasks directory (if exists) for use in the
|
6
|
+
main Rakefile.
|
7
|
+
* Added: Java.tools returns a reference to tools.jar on JDKs that include it.
|
8
|
+
* Added: brought back experimental test tasks.
|
9
|
+
* Added: artifacts task to download all artifacts referenced by project (using
|
10
|
+
either artifact or artifacts method).
|
11
|
+
* Changed: back to old behavior, compile task only executes if there are any files
|
12
|
+
to compile, and compile? method removed.
|
13
|
+
* Changed: repositories.remote is now an array instead of a hash, and repositories
|
14
|
+
are searched in the order in which they appear.
|
15
|
+
* Changed: release task is now a regular task, using the Release object instead
|
16
|
+
of being a ReleaseTask.
|
17
|
+
* Changed: eclipse task executes artifacts task.
|
18
|
+
* Fixed: inherited attributes now cache default value, useful when working with
|
19
|
+
arrays/hashes.
|
20
|
+
* Fixed: manifest file generated even if manifest attribute is false.
|
21
|
+
* Fixed: compile task now properly detects when not all files compiled.
|
22
|
+
* Fixed: bug that caused project file tasks to execute twice.
|
23
|
+
|
24
|
+
0.17 (3/14/2007)
|
25
|
+
* Added: project.task acts like Rake's task but can also fetch a task from
|
26
|
+
a project using the project's namespace.
|
27
|
+
* Added: project.file acts like Rake's file but resolve relative paths
|
28
|
+
based on the project base directory.
|
29
|
+
* Added: Rake tasks execute in the directory in which they were defined.
|
30
|
+
* Added: enhanced Rake with circular dependency, and you can find all circular
|
31
|
+
dependencies by running rake check.
|
32
|
+
* Added: enhanced Rake in_namespace, if the namespace starts with colon,
|
33
|
+
creates a namespace relative to the root instead of the current namespace.
|
34
|
+
* Changed: a project definition is now a task definition.
|
35
|
+
* Changed: use enhance to extend the project definition instead of after_define.
|
36
|
+
* Changed: LocalDirectoryTask replaced with Project.local_task.
|
37
|
+
* Changed: projects method accepts multiple names, returning only these project
|
38
|
+
definitions, returns all of them with no arguments.
|
39
|
+
* Changed: package only defines the essentials once, so you can call package
|
40
|
+
on a project to retrieve a specific package by type/id.
|
41
|
+
* Changed: zip task (and jar/war) no longer resolve artifacts for you,
|
42
|
+
must call artifacts directly.
|
43
|
+
* Changed: cannot access a project before it's defined, but can do that with
|
44
|
+
sub-projects to establish dependencies.
|
45
|
+
|
1
46
|
0.16 (3/7/2007)
|
2
47
|
* Added: zip.include :as=> to include file under specified name.
|
3
48
|
* Added: zip.merge to include the (expanded) contents of one zip file in another.
|
data/README
CHANGED
data/lib/buildr.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
|
-
# returning(obj)
|
1
|
+
# returning(obj)
|
2
2
|
require "facet/kernel/with"
|
3
3
|
# &:symbol goodness.
|
4
4
|
require "facet/symbol/to_proc"
|
5
5
|
# blank? on string and nil
|
6
6
|
require "facet/string/blank"
|
7
7
|
require "facet/nilclass/blank"
|
8
|
+
# x.in?(y) is better than y.include?(x)
|
9
|
+
require "facet/kernel/in"
|
8
10
|
# What it says.
|
11
|
+
require "facet/kernel/__DIR__"
|
12
|
+
require "facet/kernel/instance_exec"
|
9
13
|
require "facet/module/alias_method_chain"
|
14
|
+
require "facet/module/memoize"
|
10
15
|
require "facet/string/starts_with"
|
16
|
+
require "facet/openobject"
|
17
|
+
require "facets/core/kernel/tap"
|
11
18
|
|
12
19
|
|
13
20
|
module Buildr
|
14
|
-
VERSION = "0.
|
21
|
+
VERSION = "0.18.0"
|
15
22
|
end
|
16
23
|
|
17
|
-
$LOAD_PATH.unshift File.join(
|
24
|
+
$LOAD_PATH.unshift File.join(__DIR__)
|
18
25
|
require "core/core.rb"
|
19
26
|
require "core/project.rb"
|
20
27
|
require "core/artifact.rb"
|
@@ -26,7 +33,9 @@ require "tasks/filter"
|
|
26
33
|
require "tasks/zip"
|
27
34
|
|
28
35
|
require "java/java"
|
36
|
+
require "java/jetty"
|
29
37
|
require "java/compile"
|
38
|
+
require "java/eclipse"
|
30
39
|
require "java/test"
|
31
40
|
require "java/javacc"
|
32
41
|
require "java/openjpa"
|
@@ -46,3 +55,6 @@ end
|
|
46
55
|
if File.exist?(File.join(Rake.application.original_dir, "buildr.rb"))
|
47
56
|
load File.join(Rake.application.original_dir, "buildr.rb")
|
48
57
|
end
|
58
|
+
|
59
|
+
#Load local tasks that can be used in the Rakefile.
|
60
|
+
Dir["#{Dir.pwd}/tasks/*.rake"].each { |ext| load ext }
|
data/lib/core/artifact.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Buildr
|
2
2
|
|
3
|
+
desc "Download all artifacts"
|
4
|
+
task "artifacts"
|
5
|
+
|
3
6
|
# This module gives you a way to access the individual properties of an
|
4
7
|
# artifact: id, group, type, classifier and version. It also provides other
|
5
8
|
# methods commonly used on an artifact, specifically #to_hash and #to_spec.
|
@@ -183,32 +186,27 @@ module Buildr
|
|
183
186
|
File.join(local, spec[:group].split("."), spec[:id], spec[:version], Artifact.hash_to_file_name(spec))
|
184
187
|
end
|
185
188
|
|
186
|
-
# Returns
|
187
|
-
#
|
189
|
+
# Returns an array of all the remote repositories. When downloading an artifact,
|
190
|
+
# the default behavior is to try repositories in the order in which they show in
|
191
|
+
# the array.
|
188
192
|
def remote()
|
189
|
-
@remote ||=
|
193
|
+
@remote ||= []
|
190
194
|
end
|
191
195
|
|
192
|
-
#
|
193
|
-
|
194
|
-
|
196
|
+
# With a string argument, sets the remote repository (only one) to this URL.
|
197
|
+
# With an array argument, sets the remote repository to that set of URLs.
|
198
|
+
# Passing nil is equivalent to an empty array.
|
199
|
+
def remote=(urls)
|
200
|
+
case urls
|
195
201
|
when nil
|
196
|
-
@remote =
|
197
|
-
when
|
198
|
-
@remote =
|
202
|
+
@remote = nil
|
203
|
+
when Array
|
204
|
+
@remote = urls.dup
|
199
205
|
else
|
200
|
-
|
206
|
+
@remote = [urls.to_s]
|
201
207
|
end
|
202
208
|
end
|
203
209
|
|
204
|
-
# Adds more remote repositories from a hash. See #remote.
|
205
|
-
#
|
206
|
-
# For example:
|
207
|
-
# repositories.remote.add :ibiblio=>"http://www.ibiblio.org/maven2"
|
208
|
-
def add(hash)
|
209
|
-
remote.merge!(hash)
|
210
|
-
end
|
211
|
-
|
212
210
|
# Attempts to download the artifact from one of the remote repositories
|
213
211
|
# and store it in the local repository. Returns the path if downloaded,
|
214
212
|
# otherwise raises an exception.
|
@@ -217,7 +215,7 @@ module Buildr
|
|
217
215
|
path = locate(spec)
|
218
216
|
|
219
217
|
puts "Downloading #{Artifact.to_spec(spec)}" if Rake.application.options.trace
|
220
|
-
return path if remote.any? do |
|
218
|
+
return path if remote.any? do |repo_url|
|
221
219
|
begin
|
222
220
|
rel_path = spec[:group].gsub(".", "/") +
|
223
221
|
"/#{spec[:id]}/#{spec[:version]}/#{Artifact.hash_to_file_name(spec)}"
|
@@ -235,7 +233,7 @@ module Buildr
|
|
235
233
|
false
|
236
234
|
end
|
237
235
|
end
|
238
|
-
fail "Failed to download #{Artifact.to_spec(spec)}, tried the following repositories:\n#{repositories.remote.
|
236
|
+
fail "Failed to download #{Artifact.to_spec(spec)}, tried the following repositories:\n#{repositories.remote.join("\n")}"
|
239
237
|
end
|
240
238
|
|
241
239
|
# Specifies the deployment repository. Accepts a hash with the different
|
@@ -293,6 +291,7 @@ module Buildr
|
|
293
291
|
spec = Artifact.to_hash(spec)
|
294
292
|
unless task = Artifact.lookup(spec)
|
295
293
|
task = Artifact.define_task(repositories.locate(spec))
|
294
|
+
Rake::Task["rake:artifacts"].enhance [ task ]
|
296
295
|
Artifact.register(task)
|
297
296
|
end
|
298
297
|
task.apply_spec spec
|
@@ -336,11 +335,11 @@ module Buildr
|
|
336
335
|
when /:/
|
337
336
|
set |= [artifact(spec)]
|
338
337
|
when String
|
339
|
-
set |= [
|
340
|
-
when Rake::Task
|
341
|
-
set |= [spec]
|
338
|
+
set |= [File.expand_path(spec)]
|
342
339
|
when Project
|
343
340
|
set |= artifacts(spec.packages)
|
341
|
+
when Rake::Task
|
342
|
+
set |= [spec]
|
344
343
|
when Array
|
345
344
|
set |= artifacts(*spec)
|
346
345
|
else
|
data/lib/core/build.rb
CHANGED
@@ -13,7 +13,7 @@ module Buildr
|
|
13
13
|
}
|
14
14
|
|
15
15
|
# Handles the build and clean tasks.
|
16
|
-
BUILD_TASKS.each { |name, comment|
|
16
|
+
BUILD_TASKS.each { |name, comment| Project.local_task(task(name)).add_comment(comment) }
|
17
17
|
|
18
18
|
Project.on_define do |project|
|
19
19
|
BUILD_TASKS.each { |name, comment| project.recursive_task name }
|
@@ -21,25 +21,22 @@ module Buildr
|
|
21
21
|
|
22
22
|
class Project
|
23
23
|
def build(*args, &block)
|
24
|
-
|
25
|
-
task.enhance args, &block
|
26
|
-
end
|
24
|
+
task("build").enhance args, &block
|
27
25
|
end
|
28
26
|
|
29
27
|
def clean(*args, &block)
|
30
|
-
|
31
|
-
task.enhance args, &block
|
32
|
-
end
|
28
|
+
task("clean").enhance args, &block
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
36
32
|
Project.on_define do |project|
|
33
|
+
# Make sure these tasks are defined in the project.
|
37
34
|
project.build
|
38
35
|
project.clean
|
39
36
|
end
|
40
37
|
|
41
38
|
|
42
|
-
class
|
39
|
+
class Release
|
43
40
|
|
44
41
|
VERSION_NUMBER_PATTERN = /VERSION_NUMBER\s*=\s*(["'])(.*)\1/
|
45
42
|
NEXT_VERSION_PATTERN = /NEXT_VERSION\s*=\s*(["'])(.*)\1/
|
@@ -50,27 +47,30 @@ module Buildr
|
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
def initialize(
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
50
|
+
def initialize(rakefile = nil)
|
51
|
+
@rakefile = rakefile || File.read(Rake.application.rakefile)
|
52
|
+
end
|
53
|
+
|
54
|
+
attr_reader :rakefile
|
55
|
+
|
56
|
+
def invoke()
|
57
|
+
# Make sure we don't have anything uncommitted in SVN.
|
58
|
+
check_status
|
59
|
+
# Update current version to next version before deploying.
|
60
|
+
next_ver = update_version
|
61
|
+
# Run the deployment externally using the new version number
|
62
|
+
# (from the modified Rakefile).
|
63
|
+
sh "rake deploy"
|
64
|
+
# Update the next version as well to the next increment and commit.
|
65
|
+
update_next_version next_ver
|
66
|
+
# Tag the repository for this release.
|
67
|
+
tag_repository next_ver
|
68
|
+
# Update the next version to end with -SNAPSHOT.
|
69
|
+
update_version_to_snapshot next_ver
|
70
70
|
end
|
71
71
|
|
72
72
|
def check_status()
|
73
|
-
ignores =
|
73
|
+
ignores = Release.svn_ignores
|
74
74
|
status = svn("status", "--ignore-externals", :verbose=>false).
|
75
75
|
reject { |line| line =~ /^X\s/ || ignores.any? { |pat| line =~ pat } }
|
76
76
|
fail "Uncommitted SVN files violate the First Principle Of Release!\n#{status}" unless
|
@@ -81,7 +81,7 @@ module Buildr
|
|
81
81
|
# next version number (VERSION_NUMBER = NEXT_VERSION). We need this
|
82
82
|
# before making a release with the next version. Return the next version.
|
83
83
|
def update_version()
|
84
|
-
rakefile =
|
84
|
+
rakefile = read_rakefile
|
85
85
|
version = rakefile.scan(VERSION_NUMBER_PATTERN)[0][1] or
|
86
86
|
fail "Looking for VERSION_NUMBER = \"...\" in your Rakefile, none found"
|
87
87
|
next_ver = rakefile.scan(NEXT_VERSION_PATTERN)[0][1] or
|
@@ -90,11 +90,8 @@ module Buildr
|
|
90
90
|
puts "Current version: #{version}"
|
91
91
|
puts "Next version: #{next_ver}"
|
92
92
|
end
|
93
|
-
|
94
93
|
# Switch version numbers.
|
95
|
-
rakefile.gsub
|
96
|
-
File.open(Rake.application.rakefile, "w") { |file| file.write rakefile }
|
97
|
-
|
94
|
+
write_rakefile rakefile.gsub(VERSION_NUMBER_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_ver}"}) }
|
98
95
|
next_ver
|
99
96
|
end
|
100
97
|
|
@@ -106,12 +103,9 @@ module Buildr
|
|
106
103
|
nums = version.split(".")
|
107
104
|
nums[-1] = nums[-1].to_i + 1
|
108
105
|
next_ver = nums.join(".")
|
109
|
-
|
110
|
-
rakefile.gsub!(NEXT_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_ver}"}) }
|
111
|
-
File.open(Rake.application.rakefile, "w") { |file| file.write rakefile }
|
112
|
-
|
106
|
+
write_rakefile read_rakefile.gsub(NEXT_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_ver}"}) }
|
113
107
|
# Commit new version number.
|
114
|
-
svn "commit", "-m", "Changed version number to #{version}",
|
108
|
+
svn "commit", "-m", "Changed version number to #{version}", rakefile
|
115
109
|
end
|
116
110
|
|
117
111
|
# Create a tag in the SVN repository.
|
@@ -125,11 +119,19 @@ module Buildr
|
|
125
119
|
|
126
120
|
def update_version_to_snapshot(version)
|
127
121
|
version += "-SNAPSHOT"
|
128
|
-
|
129
|
-
rakefile.gsub!(VERSION_NUMBER_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{version}"}) }
|
130
|
-
File.open(Rake.application.rakefile, "w") { |file| file.write rakefile }
|
122
|
+
write_rakefile read_rakefile.gsub(VERSION_NUMBER_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{version}"}) }
|
131
123
|
# Commit new version number.
|
132
|
-
svn "commit", "-m", "Changed version number to #{version}",
|
124
|
+
svn "commit", "-m", "Changed version number to #{version}", rakefile
|
125
|
+
end
|
126
|
+
|
127
|
+
protected
|
128
|
+
|
129
|
+
def read_rakefile()
|
130
|
+
File.read(rakefile)
|
131
|
+
end
|
132
|
+
|
133
|
+
def write_rakefile(contents)
|
134
|
+
File.open(rakefile, "w") { |file| file.write contents }
|
133
135
|
end
|
134
136
|
|
135
137
|
def svn(*args)
|
@@ -146,8 +148,17 @@ module Buildr
|
|
146
148
|
returning(stdout.read) { |output| puts output if Rake.application.options.trace }
|
147
149
|
end
|
148
150
|
end
|
151
|
+
|
149
152
|
end
|
150
153
|
|
154
|
+
|
151
155
|
desc "Make a release"
|
152
|
-
|
156
|
+
task("release").tap do |release|
|
157
|
+
class << release
|
158
|
+
def release()
|
159
|
+
@release ||= Release.new
|
160
|
+
end
|
161
|
+
end
|
162
|
+
release.enhance { release.invoke }
|
163
|
+
end
|
153
164
|
end
|
data/lib/core/core.rb
CHANGED
@@ -28,13 +28,128 @@ module Buildr
|
|
28
28
|
# inherited_attr :java_src_dir do src_dir + "/main/java"
|
29
29
|
def inherited_attr(symbol, default = nil, &block)
|
30
30
|
block ||= proc { default }
|
31
|
-
|
32
|
-
|
31
|
+
attr_accessor symbol
|
32
|
+
define_method "#{symbol}_with_inheritence" do
|
33
|
+
unless value = send("#{symbol}_without_inheritence")
|
34
|
+
value = parent ? parent.send(symbol) : self.instance_eval(&block)
|
35
|
+
send "#{symbol}=", value
|
36
|
+
end
|
37
|
+
value
|
33
38
|
end
|
34
|
-
|
35
|
-
|
39
|
+
alias_method_chain symbol, :inheritence
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class Rake::Task
|
46
|
+
def invoke
|
47
|
+
tasks = (Thread.current[:tasks] || [])
|
48
|
+
if tasks.include?(name)
|
49
|
+
fail "Circular dependency " + (tasks + [name]).join("=>")
|
50
|
+
end
|
51
|
+
@lock.synchronize do
|
52
|
+
if application.options.trace
|
53
|
+
puts "** Invoke #{name} #{format_trace_flags}"
|
54
|
+
end
|
55
|
+
return if @already_invoked
|
56
|
+
begin
|
57
|
+
Thread.current[:tasks] = tasks + [name]
|
58
|
+
@already_invoked = true
|
59
|
+
invoke_prerequisites
|
60
|
+
execute if needed?
|
61
|
+
ensure
|
62
|
+
Thread.current[:tasks] = tasks
|
36
63
|
end
|
37
64
|
end
|
38
65
|
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Rake::Task
|
39
69
|
|
70
|
+
# Access the base directory. The base directory is set when the class
|
71
|
+
# is defined from the current directory. The current directory is set
|
72
|
+
# to the base directory when the class is executed.
|
73
|
+
attr_accessor :base_dir
|
74
|
+
|
75
|
+
# :nodoc:
|
76
|
+
def invoke_with_base_dir()
|
77
|
+
Dir.chdir(@base_dir || Dir.pwd) { invoke_without_base_dir }
|
78
|
+
end
|
79
|
+
alias_method_chain :invoke, :base_dir
|
80
|
+
|
81
|
+
# :nodoc:
|
82
|
+
def initialize_with_base_dir(*args)
|
83
|
+
@base_dir = Dir.pwd
|
84
|
+
initialize_without_base_dir *args
|
85
|
+
end
|
86
|
+
alias_method_chain :initialize, :base_dir
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
class Rake::Application
|
92
|
+
|
93
|
+
def in_namespace_with_global_scope(name, &block)
|
94
|
+
if name =~ /^:/
|
95
|
+
begin
|
96
|
+
scope, @scope = @scope, name.split(":")[1...-1]
|
97
|
+
in_namespace_without_global_scope name.split(":").last, &block
|
98
|
+
ensure
|
99
|
+
@scope = scope
|
100
|
+
end
|
101
|
+
else
|
102
|
+
in_namespace_without_global_scope name, &block
|
103
|
+
end
|
104
|
+
end
|
105
|
+
alias_method_chain :in_namespace, :global_scope
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
class CheckTask < Rake::Task
|
111
|
+
|
112
|
+
def execute()
|
113
|
+
@warnings = []
|
114
|
+
super
|
115
|
+
report if verbose
|
116
|
+
end
|
117
|
+
|
118
|
+
def note(*msg)
|
119
|
+
@warnings += msg
|
120
|
+
end
|
121
|
+
|
122
|
+
def report()
|
123
|
+
if @warnings.empty?
|
124
|
+
puts HighLine.new.color("No warnings", :green)
|
125
|
+
else
|
126
|
+
warn "These are possible problems with your Rakefile"
|
127
|
+
@warnings.each { |msg| warn " #{msg}" }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
desc "Check your Rakefile for common errors"
|
135
|
+
CheckTask.define_task "check"
|
136
|
+
|
137
|
+
# Check for circular dependencies
|
138
|
+
task "check" do
|
139
|
+
depends = {}
|
140
|
+
expand = lambda do |stack, checking|
|
141
|
+
if depends[checking]
|
142
|
+
if stack.include?(checking)
|
143
|
+
fail "Circular " + (stack + [checking]).join("=>")
|
144
|
+
end
|
145
|
+
else
|
146
|
+
depends[checking] = []
|
147
|
+
depends[checking] |= Rake.application[checking].prerequisites.
|
148
|
+
map { |prereq| expand[stack + [checking.to_s], prereq.to_s] }.flatten.map(&:to_s)
|
149
|
+
end
|
150
|
+
depends[checking]
|
151
|
+
end
|
152
|
+
Rake.application.tasks.each do |checking|
|
153
|
+
expand[ [], checking.to_s ]
|
154
|
+
end
|
40
155
|
end
|