buildr 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/lib/buildr.rb +4 -1
- data/lib/core/build.rb +117 -111
- data/lib/java/artifact.rb +1 -1
- data/lib/java/compile.rb +165 -0
- data/lib/java/java.rb +56 -0
- data/lib/java/packaging.rb +2 -5
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.20 (4/18/2007)
|
2
|
+
* Added: JavadocTask to generate Javadoc documentation for the project, javadoc method on the project itself to return its javadoc task, and Java.javadoc to do all the heavy lifting.
|
3
|
+
* Changed: Release code is now implemented as module instead of class. SVN copy made from working copy instead of double commit.
|
4
|
+
* Removed: package :file_name options. Does not work with deployed artifacts or POMs.
|
5
|
+
* Fixed: Packages not deployed in the right path (but POMs are).
|
6
|
+
* Fixed: JARs and WARs include redundant META-INF directory.
|
7
|
+
* Fixed: The local package task is now a dependency for install/deploy, and build is dependency for package.
|
8
|
+
|
1
9
|
0.19 (4/13/2007)
|
2
10
|
* Fixed: Eclipse task correctly handles FileTasks
|
3
11
|
* Fixed: Eclipse task output directory is "target/classes" (Project.compile.target) instead of "/target"
|
data/lib/buildr.rb
CHANGED
@@ -8,11 +8,14 @@ require "facet/string/blank"
|
|
8
8
|
require "facet/nilclass/blank"
|
9
9
|
# x.in?(y) is better than y.include?(x)
|
10
10
|
require "facet/kernel/in"
|
11
|
+
# Allows binding[]
|
12
|
+
require "facet/binding"
|
11
13
|
# What it says.
|
12
14
|
require "facet/kernel/__DIR__"
|
13
15
|
require "facet/kernel/instance_exec"
|
14
16
|
require "facet/module/alias_method_chain"
|
15
17
|
require "facet/module/memoize"
|
18
|
+
require "facet/array/head"
|
16
19
|
require "facet/string/starts_with"
|
17
20
|
require "facet/openobject"
|
18
21
|
require "facets/core/kernel/tap"
|
@@ -27,7 +30,7 @@ end
|
|
27
30
|
|
28
31
|
|
29
32
|
module Buildr
|
30
|
-
VERSION = "0.
|
33
|
+
VERSION = "0.20.0"
|
31
34
|
end
|
32
35
|
|
33
36
|
|
data/lib/core/build.rb
CHANGED
@@ -8,13 +8,13 @@ module Buildr
|
|
8
8
|
desc "Clean files generated during a build"
|
9
9
|
Project.local_task("clean") { |name| "Cleaning #{name}" }
|
10
10
|
desc "Create packages"
|
11
|
-
Project.local_task("package") { |name| "Packaging #{name}" }
|
11
|
+
Project.local_task("package"=>"build") { |name| "Packaging #{name}" }
|
12
12
|
desc "Install packages created by the project"
|
13
|
-
Project.local_task("install") { |name| "Installing packages from #{name}" }
|
13
|
+
Project.local_task("install"=>"package") { |name| "Installing packages from #{name}" }
|
14
14
|
desc "Remove previously installed packages"
|
15
15
|
Project.local_task("uninstall") { |name| "Uninstalling packages from #{name}" }
|
16
16
|
desc "Deploy packages created by the project"
|
17
|
-
Project.local_task("deploy") { |name| "Deploying packages from #{name}" }
|
17
|
+
Project.local_task("deploy"=>"package") { |name| "Deploying packages from #{name}" }
|
18
18
|
|
19
19
|
[ :build, :clean, :package, :install, :uninstall, :deploy ].each do |name|
|
20
20
|
Project.on_define { |project| project.recursive_task name }
|
@@ -45,129 +45,135 @@ module Buildr
|
|
45
45
|
desc "The default task it build"
|
46
46
|
task "default"=>"build"
|
47
47
|
|
48
|
-
class Release #:nodoc:
|
49
48
|
|
50
|
-
|
51
|
-
NEXT_VERSION_PATTERN = /NEXT_VERSION\s*=\s*(["'])(.*)\1/
|
49
|
+
class Release
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
@ignores = (@ignores || []).map { |pat| pat.is_a?(Regexp) ? pat : Regexp.new("^.*\s+#{Regexp.escape pat}$") }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def initialize(rakefile = nil)
|
60
|
-
@rakefile = rakefile || Rake.application.rakefile
|
61
|
-
end
|
62
|
-
|
63
|
-
attr_reader :rakefile
|
64
|
-
|
65
|
-
def invoke()
|
66
|
-
# Make sure we don't have anything uncommitted in SVN.
|
67
|
-
check_status
|
68
|
-
# Update current version to next version before deploying.
|
69
|
-
next_ver = update_version
|
70
|
-
# Run the deployment externally using the new version number
|
71
|
-
# (from the modified Rakefile).
|
72
|
-
sh "rake deploy"
|
73
|
-
# Update the next version as well to the next increment and commit.
|
74
|
-
update_next_version next_ver
|
75
|
-
# Tag the repository for this release.
|
76
|
-
tag_repository next_ver
|
77
|
-
# Update the next version to end with -SNAPSHOT.
|
78
|
-
update_version_to_snapshot next_ver
|
79
|
-
end
|
51
|
+
THIS_VERSION_PATTERN = /THIS_VERSION|VERSION_NUMBER\s*=\s*(["'])(.*)\1/
|
52
|
+
NEXT_VERSION_PATTERN = /NEXT_VERSION\s*=\s*(["'])(.*)\1/
|
80
53
|
|
81
|
-
|
82
|
-
ignores = Release.svn_ignores
|
83
|
-
status = svn("status", "--ignore-externals", :verbose=>false).
|
84
|
-
reject { |line| line =~ /^X\s/ || ignores.any? { |pat| line =~ pat } }
|
85
|
-
fail "Uncommitted SVN files violate the First Principle Of Release!\n#{status}" unless
|
86
|
-
status.empty?
|
87
|
-
end
|
54
|
+
class << self
|
88
55
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
if verbose
|
99
|
-
puts "Current version: #{version}"
|
100
|
-
puts "Next version: #{next_ver}"
|
56
|
+
# :call-seq:
|
57
|
+
# make()
|
58
|
+
#
|
59
|
+
# Make a release.
|
60
|
+
def make()
|
61
|
+
check
|
62
|
+
version = with_next_version { |filename, version| sh "rake deploy --rakefile #{filename}" }
|
63
|
+
tag version
|
64
|
+
commit version + "-SNAPSHOT"
|
101
65
|
end
|
102
|
-
# Switch version numbers.
|
103
|
-
write_rakefile rakefile.gsub(VERSION_NUMBER_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_ver}"}) }
|
104
|
-
next_ver
|
105
|
-
end
|
106
|
-
|
107
|
-
# Change the Rakefile and update the next version number to one after
|
108
|
-
# (NEXT_VERSION = NEXT_VERSION + 1). We do this to automatically increment
|
109
|
-
# future version number after each successful release.
|
110
|
-
def update_next_version(version)
|
111
|
-
# Update to new version number.
|
112
|
-
nums = version.split(".")
|
113
|
-
nums[-1] = nums[-1].to_i + 1
|
114
|
-
next_ver = nums.join(".")
|
115
|
-
write_rakefile read_rakefile.gsub(NEXT_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_ver}"}) }
|
116
|
-
# Commit new version number.
|
117
|
-
svn "commit", "-m", "Changed version number to #{version}", rakefile
|
118
|
-
end
|
119
|
-
|
120
|
-
# Create a tag in the SVN repository.
|
121
|
-
def tag_repository(version)
|
122
|
-
# Copy to tag.
|
123
|
-
cur_url = svn("info").scan(/URL: (.*)/)[0][0]
|
124
|
-
new_url = cur_url.sub(/trunk$/, "tags/#{version}")
|
125
|
-
svn "remove", new_url, "-m", "Removing old copy" rescue nil
|
126
|
-
svn "copy", cur_url, new_url, "-m", "Release #{version}"
|
127
|
-
end
|
128
|
-
|
129
|
-
def update_version_to_snapshot(version)
|
130
|
-
version += "-SNAPSHOT"
|
131
|
-
write_rakefile read_rakefile.gsub(VERSION_NUMBER_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{version}"}) }
|
132
|
-
# Commit new version number.
|
133
|
-
svn "commit", "-m", "Changed version number to #{version}", rakefile
|
134
|
-
end
|
135
66
|
|
136
|
-
|
67
|
+
protected
|
68
|
+
|
69
|
+
# :call-seq:
|
70
|
+
# check()
|
71
|
+
#
|
72
|
+
# Check that we don't have any local changes in the working copy. Fails if it finds anything
|
73
|
+
# in the working copy that is not checked into source control.
|
74
|
+
def check()
|
75
|
+
# Status check reveals modified file, but also SVN externals which we can safely ignore.
|
76
|
+
status = svn("status", "--ignore-externals").reject { |line| line =~ /^X\s/ }
|
77
|
+
fail "Uncommitted SVN files violate the First Principle Of Release!\n#{status}" unless
|
78
|
+
status.empty?
|
79
|
+
end
|
80
|
+
|
81
|
+
# :call-seq:
|
82
|
+
# with_next_version() { |filename| ... } => version
|
83
|
+
#
|
84
|
+
# Yields to block with upgraded version number, before committing to use it. Returns the *new*
|
85
|
+
# current version number.
|
86
|
+
#
|
87
|
+
# We need a Rakefile with upgraded version numbers to run the build, but we don't want the
|
88
|
+
# Rakefile modified unless the build succeeds. So this method updates the version numbers in
|
89
|
+
# a separate (Rakefile.next) file, yields to the block with that filename, and if successful
|
90
|
+
# copies the new file over the existing one.
|
91
|
+
#
|
92
|
+
# Version numbers are updated as follows. The next release version becomes the current one,
|
93
|
+
# and the next version is upgraded by one to become the new next version. So:
|
94
|
+
# THIS_VERSION = 1.1.0
|
95
|
+
# NEXT_VERSION = 1.2.0
|
96
|
+
# becomes:
|
97
|
+
# THIS_VERSION = 1.2.0
|
98
|
+
# NEXT_VERSION = 1.2.1
|
99
|
+
# and the method will return 1.2.0.
|
100
|
+
def with_next_version()
|
101
|
+
new_filename = Rake.application.rakefile + ".next"
|
102
|
+
modified = change_version do |this_version, next_version|
|
103
|
+
one_after = next_version.split(".")
|
104
|
+
one_after[-1] = one_after[-1].to_i + 1
|
105
|
+
[ next_version, one_after.join(".") ]
|
106
|
+
end
|
107
|
+
File.open(new_filename, "w") { |file| file.write modified }
|
108
|
+
begin
|
109
|
+
yield new_filename
|
110
|
+
mv new_filename, Rake.application.rakefile
|
111
|
+
ensure
|
112
|
+
rm new_filename rescue nil
|
113
|
+
end
|
114
|
+
File.read(Rake.application.rakefile).scan(THIS_VERSION_PATTERN)[0][1]
|
115
|
+
end
|
137
116
|
|
138
|
-
|
139
|
-
|
140
|
-
|
117
|
+
# :call-seq:
|
118
|
+
# change_version() { |this, next| ... } => rakefile
|
119
|
+
#
|
120
|
+
# Change version numbers in the current Rakefile, but without writing a new file (yet).
|
121
|
+
# Returns the contents of the Rakefile with the modified version numbers.
|
122
|
+
#
|
123
|
+
# This method yields to the block with the current (this) and next version numbers and expects
|
124
|
+
# an array with the new this and next version numbers.
|
125
|
+
def change_version()
|
126
|
+
rakefile = File.read(Rake.application.rakefile)
|
127
|
+
this_version = rakefile.scan(THIS_VERSION_PATTERN)[0][1] or
|
128
|
+
fail "Looking for THIS_VERSION = \"...\" in your Rakefile, none found"
|
129
|
+
next_version = rakefile.scan(NEXT_VERSION_PATTERN)[0][1] or
|
130
|
+
fail "Looking for NEXT_VERSION = \"...\" in your Rakefile, none found"
|
131
|
+
this_version, next_version = yield(this_version, next_version)
|
132
|
+
if verbose
|
133
|
+
puts "Upgrading version numbers:"
|
134
|
+
puts " This: #{this_version}"
|
135
|
+
puts " Next: #{next_version}"
|
136
|
+
end
|
137
|
+
rakefile.gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{this_version}"}) }.
|
138
|
+
gsub(NEXT_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_version}"}) }
|
139
|
+
end
|
141
140
|
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
# :call-seq:
|
142
|
+
# tag(version)
|
143
|
+
#
|
144
|
+
# Tags the current working copy with the release version number.
|
145
|
+
def tag(version)
|
146
|
+
url = svn("info").scan(/URL: (.*)/)[0][0].sub(/trunk$/, "tags/#{version}")
|
147
|
+
svn "remove", url, "-m", "Removing old copy" rescue nil
|
148
|
+
svn "copy", Dir.pwd, url, "-m", "Release #{version}"
|
149
|
+
end
|
145
150
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
+
# :call-seq:
|
152
|
+
# commit(version)
|
153
|
+
#
|
154
|
+
# Last, we commit what we currently have in the working copy.
|
155
|
+
def commit(version)
|
156
|
+
rakefile = File.read(Rake.application.rakefile).
|
157
|
+
gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{version}"}) }.
|
158
|
+
File.open(Rake.application.rakefile, "w") { |file| file.write rakefile }
|
159
|
+
svn "commit", "-m", "Changed version number to #{version}", Rake.application.rakefile
|
151
160
|
end
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
161
|
+
|
162
|
+
# :call-seq:
|
163
|
+
# svn(*args)
|
164
|
+
#
|
165
|
+
# Executes SVN command and returns the output.
|
166
|
+
def svn(*args)
|
167
|
+
cmd = "svn " + args.map { |arg| arg[" "] ? %Q{"#{arg}"} : arg }.join(" ")
|
168
|
+
puts cmd if verbose
|
169
|
+
`#{cmd}`.tap { fail "SVN command failed" unless $?.exitstatus == 0 }
|
158
170
|
end
|
159
171
|
end
|
160
172
|
|
161
173
|
end
|
162
174
|
|
163
|
-
|
164
175
|
desc "Make a release"
|
165
|
-
task
|
166
|
-
|
167
|
-
def release()
|
168
|
-
@release ||= Release.new
|
169
|
-
end
|
170
|
-
end
|
171
|
-
task.enhance { task.release.invoke }
|
176
|
+
task "release" do |task|
|
177
|
+
Release.make
|
172
178
|
end
|
173
179
|
end
|
data/lib/java/artifact.rb
CHANGED
data/lib/java/compile.rb
CHANGED
@@ -281,6 +281,144 @@ module Buildr
|
|
281
281
|
|
282
282
|
end
|
283
283
|
|
284
|
+
|
285
|
+
# A convenient task for creating Javadocs from the project's compile task. Minimizes all
|
286
|
+
# the hard work to calling #from and #using.
|
287
|
+
#
|
288
|
+
# For example:
|
289
|
+
# javadoc.from(projects("myapp:foo", "myapp:bar")).using(:windowtitle=>"My App")
|
290
|
+
# Or, short and sweet:
|
291
|
+
# desc "My App"
|
292
|
+
# define "myapp" do
|
293
|
+
# . . .
|
294
|
+
# javadoc projects("myapp:foo", "myapp:bar")
|
295
|
+
# end
|
296
|
+
class JavadocTask < Rake::Task
|
297
|
+
|
298
|
+
def initialize(*args) #:nodoc:
|
299
|
+
super
|
300
|
+
@options = {}
|
301
|
+
@classpath = []
|
302
|
+
@sourcepath = []
|
303
|
+
@files = FileList[]
|
304
|
+
enhance do |task|
|
305
|
+
rm_rf target.to_s, :verbose=>false
|
306
|
+
Java.javadoc source_files, options.merge(:classpath=>classpath, :sourcepath=>sourcepath, :name=>name, :output=>target.to_s)
|
307
|
+
touch target.to_s, :verbose=>false
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# The target directory for the generated Javadoc files.
|
312
|
+
attr_reader :target
|
313
|
+
|
314
|
+
# :call-seq:
|
315
|
+
# into(path) => self
|
316
|
+
#
|
317
|
+
# Sets the target directory and returns self. This will also set the Javadoc task
|
318
|
+
# as a prerequisite to a file task on the target directory.
|
319
|
+
#
|
320
|
+
# For example:
|
321
|
+
# package :zip, :classifier=>"docs", :include=>javadoc.target
|
322
|
+
def into(path)
|
323
|
+
path = File.expand_path(path.to_s)
|
324
|
+
@target = file(path).enhance([self]) unless @target && @target.to_s == path
|
325
|
+
self
|
326
|
+
end
|
327
|
+
|
328
|
+
# :call-seq:
|
329
|
+
# include(*files) => self
|
330
|
+
#
|
331
|
+
# Includes additional source files and directories when generating the documentation
|
332
|
+
# and returns self. When specifying a directory, includes all .java files in that directory.
|
333
|
+
def include(*files)
|
334
|
+
@files.include *files
|
335
|
+
self
|
336
|
+
end
|
337
|
+
|
338
|
+
# :call-seq:
|
339
|
+
# exclude(*files) => self
|
340
|
+
#
|
341
|
+
# Excludes source files and directories from generating the documentation.
|
342
|
+
def exclude(*files)
|
343
|
+
@files.exclude *files
|
344
|
+
self
|
345
|
+
end
|
346
|
+
|
347
|
+
# Classpath dependencies.
|
348
|
+
attr_accessor :classpath
|
349
|
+
|
350
|
+
# :call-seq:
|
351
|
+
# with(*artifacts) => self
|
352
|
+
#
|
353
|
+
# Adds files and artifacts as classpath dependencies, and returns self.
|
354
|
+
def with(*specs)
|
355
|
+
@classpath |= artifacts(specs.flatten).uniq
|
356
|
+
self
|
357
|
+
end
|
358
|
+
|
359
|
+
# Additional sourcepaths that are not part of the documented files.
|
360
|
+
attr_accessor :sourcepath
|
361
|
+
|
362
|
+
# Returns the Javadoc options.
|
363
|
+
attr_reader :options
|
364
|
+
|
365
|
+
# :call-seq:
|
366
|
+
# using(options) => self
|
367
|
+
#
|
368
|
+
# Sets the Javadoc options from a hash and returns self.
|
369
|
+
#
|
370
|
+
# For example:
|
371
|
+
# javadoc.using :windowtitle=>"My application"
|
372
|
+
def using(options)
|
373
|
+
options.each { |key, value| @options[key] = value }
|
374
|
+
self
|
375
|
+
end
|
376
|
+
|
377
|
+
# :call-seq:
|
378
|
+
# from(*sources) => self
|
379
|
+
#
|
380
|
+
# Includes files, directories and projects in the Javadoc documentation and returns self.
|
381
|
+
#
|
382
|
+
# You can call this method with Java source files and directories containing Java source files
|
383
|
+
# to include these files in the Javadoc documentation, similar to #include. You can also call
|
384
|
+
# this method with projects. When called with a project, it includes all the source files compiled
|
385
|
+
# by that project and classpath dependencies used when compiling.
|
386
|
+
#
|
387
|
+
# For example:
|
388
|
+
# javadoc.from projects("myapp:foo", "myapp:bar")
|
389
|
+
def from(*sources)
|
390
|
+
sources.flatten.each do |source|
|
391
|
+
case source
|
392
|
+
when Project
|
393
|
+
self.include source.compile.sources
|
394
|
+
self.with source.compile.classpath
|
395
|
+
when Rake::Task, String
|
396
|
+
self.include source
|
397
|
+
else
|
398
|
+
fail "Don't know how to generate Javadocs from #{source || 'nil'}"
|
399
|
+
end
|
400
|
+
end
|
401
|
+
self
|
402
|
+
end
|
403
|
+
|
404
|
+
def prerequisites() #:nodoc:
|
405
|
+
super + @files + classpath + sourcepath
|
406
|
+
end
|
407
|
+
|
408
|
+
def source_files() #:nodoc:
|
409
|
+
@source_files ||= @files.map(&:to_s).
|
410
|
+
map { |file| File.directory?(file) ? FileList[File.join(file, "**/*.java")] : file }.
|
411
|
+
flatten.reject { |file| @files.exclude?(file) }
|
412
|
+
end
|
413
|
+
|
414
|
+
def needed?() #:nodoc:
|
415
|
+
return false if source_files.empty?
|
416
|
+
return true unless File.exist?(target.to_s)
|
417
|
+
source_files.map { |src| File.stat(src.to_s).mtime }.max > File.stat(target.to_s).mtime
|
418
|
+
end
|
419
|
+
|
420
|
+
end
|
421
|
+
|
284
422
|
end
|
285
423
|
|
286
424
|
|
@@ -289,6 +427,9 @@ module Buildr
|
|
289
427
|
desc "Compile all projects"
|
290
428
|
Project.local_task("compile") { |name| "Compiling #{name}" }
|
291
429
|
|
430
|
+
desc "Create the Javadocs for this project"
|
431
|
+
Project.local_task("javadoc")
|
432
|
+
|
292
433
|
class Project
|
293
434
|
|
294
435
|
# :call-seq:
|
@@ -356,6 +497,23 @@ module Buildr
|
|
356
497
|
task("resources").enhance prereqs, &block
|
357
498
|
end
|
358
499
|
|
500
|
+
# :call-seq:
|
501
|
+
# javadoc(*sources) => JavadocTask
|
502
|
+
#
|
503
|
+
# This method returns the project's Javadoc task. It also accepts a list of source files,
|
504
|
+
# directories and projects to include when generating the Javadocs.
|
505
|
+
#
|
506
|
+
# By default the Javadoc task uses all the source directories from compile.sources and generates
|
507
|
+
# Javadocs in the target/javadoc directory. This method accepts sources and adds them by calling
|
508
|
+
# JavadocsTask#from.
|
509
|
+
#
|
510
|
+
# For example, if you want to generate Javadocs for a given project that includes all source files
|
511
|
+
# in two of its sub-projects:
|
512
|
+
# javadoc projects("myapp:foo", "myapp:bar").using(:windowtitle=>"Docs for foo and bar")
|
513
|
+
def javadoc(*sources, &block)
|
514
|
+
task("javadoc").from(*sources).enhance &block
|
515
|
+
end
|
516
|
+
|
359
517
|
end
|
360
518
|
|
361
519
|
Project.on_define do |project|
|
@@ -368,11 +526,18 @@ module Buildr
|
|
368
526
|
project.path_to("src/main/java").tap { |dir| compile.from dir if File.exist?(dir) }
|
369
527
|
compile.into project.path_to("target/classes")
|
370
528
|
resources.filter.into project.compile.target
|
529
|
+
Java::JavadocTask.define_task("javadoc"=>prepare).tap do |javadoc|
|
530
|
+
javadoc.into project.path_to("target/javadoc")
|
531
|
+
javadoc.using :windowtitle=>project.comment || project.name
|
532
|
+
end
|
371
533
|
project.recursive_task("compile")
|
372
534
|
project.clean { verbose(false) { rm_rf project.path_to("target") } }
|
373
535
|
|
374
536
|
project.enhance do |project|
|
537
|
+
# This comes last because the target path may change.
|
375
538
|
project.build project.compile.target
|
539
|
+
# This comes last so we can determine all the source paths and classpath dependencies.
|
540
|
+
project.javadoc.from project
|
376
541
|
end
|
377
542
|
end
|
378
543
|
|
data/lib/java/java.rb
CHANGED
@@ -194,6 +194,62 @@ module Buildr
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
+
# :call-seq:
|
198
|
+
# javadoc(*files, options)
|
199
|
+
#
|
200
|
+
# Runs Javadocs with the specified files and options.
|
201
|
+
#
|
202
|
+
# This method accepts the following special options:
|
203
|
+
# * :output -- The output directory
|
204
|
+
# * :classpath -- Array of classpath dependencies.
|
205
|
+
# * :sourcepath -- Array of sourcepaths (paths or tasks).
|
206
|
+
# * :name -- Shows this name, otherwise shows the working directory.
|
207
|
+
# * :verbose -- If you want an overload of details.
|
208
|
+
#
|
209
|
+
# All other options are passed to Javadoc as following:
|
210
|
+
# * true -- As is, for example, :author=>true becomes -author
|
211
|
+
# * false -- Prefixed, for example, :index=>false becomes -noindex
|
212
|
+
# * string -- Option with value, for example, :windowtitle=>"My project" becomes -windowtitle "My project"
|
213
|
+
# * array -- Option with set of values separated by spaces.
|
214
|
+
def javadoc(*args)
|
215
|
+
options = Hash === args.last ? args.pop : {}
|
216
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
217
|
+
|
218
|
+
Tempfile.open("javadoc") do |opt_file|
|
219
|
+
options.reject { |key, value| [:output, :verbose, :name, :sourcepath, :classpath].include?(key) }.
|
220
|
+
each { |key, value| value.invoke if value.respond_to?(:invoke) }.
|
221
|
+
each do |key, value|
|
222
|
+
case value
|
223
|
+
when true, nil
|
224
|
+
opt_file.puts "-#{key}"
|
225
|
+
when false
|
226
|
+
opt_file.puts "-no#{key}"
|
227
|
+
when Array
|
228
|
+
opt_file.puts "-#{key} " << value.map { |val| %q{"#{val}"} }.join(" ")
|
229
|
+
when Hash
|
230
|
+
value.each { |k,v| opt_file.puts "-#{key} #{k} #{v}" }
|
231
|
+
else
|
232
|
+
opt_file.puts "-#{key} \"#{value}\""
|
233
|
+
end
|
234
|
+
end
|
235
|
+
[:sourcepath, :classpath].each do |option|
|
236
|
+
options[option].to_a.flatten.tap do |paths|
|
237
|
+
opt_file.puts "-#{option} " << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
|
238
|
+
end
|
239
|
+
end
|
240
|
+
opt_file.puts args.flatten.uniq.join(" ")
|
241
|
+
opt_file.flush
|
242
|
+
cmd_args = [ "-d", options[:output], options[:verbose] ? "-verbose" : "-quiet", "@#{opt_file.path}"]
|
243
|
+
cmd_args << { :verbose=>options[:verbose] }
|
244
|
+
name = options[:name] || Dir.pwd
|
245
|
+
unless Rake.application.options.dryrun
|
246
|
+
puts "Generating Javadoc for #{name}" if verbose
|
247
|
+
puts File.read(opt_file.path) if options[:verbose]
|
248
|
+
sh(path_to_bin("javadoc"), *cmd_args) { |ok, res| fail "Failed to generate Javadocs, see errors above" unless ok }
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
197
253
|
# :call-seq:
|
198
254
|
# junit(*classes, options) => [ passed, failed ]
|
199
255
|
#
|
data/lib/java/packaging.rb
CHANGED
@@ -65,7 +65,6 @@ module Buildr
|
|
65
65
|
protected
|
66
66
|
|
67
67
|
def create(zip) #:nodoc:
|
68
|
-
zip.mkdir "META-INF"
|
69
68
|
meta_inf.map(&:to_s).uniq.each { |file| zip.add "META-INF/#{File.basename(file)}", file }
|
70
69
|
unless manifest == false
|
71
70
|
zip.file.open("META-INF/MANIFEST.MF", "w") do |output|
|
@@ -164,8 +163,6 @@ module Buildr
|
|
164
163
|
# The second argument provides additional options used when defining the package.
|
165
164
|
#
|
166
165
|
# The following options are supported by all package types:
|
167
|
-
# * :file_name -- The package file name. By default it uses the artifact identifier,
|
168
|
-
# version number and file type to create a file name (id-version.type).
|
169
166
|
# * :id -- The artifact identifier. By default, uses the project's #id property.
|
170
167
|
# * :group -- The group identifier. By default, uses the project's #group property.
|
171
168
|
# * :version -- The version number. By default, uses the project's #version property.
|
@@ -230,7 +227,7 @@ module Buildr
|
|
230
227
|
options[:group] ||= self.group
|
231
228
|
options[:version] ||= self.version
|
232
229
|
options[:type] = type
|
233
|
-
file_name =
|
230
|
+
file_name = path_to("target", Artifact.hash_to_file_name(options))
|
234
231
|
|
235
232
|
packager = method("package_as_#{type}") rescue
|
236
233
|
fail("Do not know how to create a package of type #{:type}")
|
@@ -274,7 +271,7 @@ module Buildr
|
|
274
271
|
[ installed, package.pom ].map(&:to_s).each { |file| rm file if File.exist?(file) }
|
275
272
|
end
|
276
273
|
end
|
277
|
-
task("deploy") { deploy(
|
274
|
+
task("deploy") { deploy(package, package.pom) }
|
278
275
|
|
279
276
|
# Add the package to the list of packages created by this project, and
|
280
277
|
# register it as an artifact. The later is required so if we look up the spec
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: buildr
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-04-
|
6
|
+
version: 0.20.0
|
7
|
+
date: 2007-04-18 00:00:00 -07:00
|
8
8
|
summary: A build system that doesn't suck
|
9
9
|
require_paths:
|
10
10
|
- lib
|