buildr 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/Rakefile +58 -52
- data/lib/buildr.rb +7 -1
- data/lib/buildr/antlr.rb +52 -0
- data/lib/buildr/javacc.rb +5 -5
- data/lib/buildr/jetty.rb +4 -6
- data/lib/buildr/openjpa.rb +1 -1
- data/lib/buildr/scala.rb +2 -2
- data/lib/core/build.rb +5 -3
- data/lib/java/ant.rb +2 -2
- data/lib/java/artifact.rb +70 -1
- data/lib/java/java.rb +75 -48
- data/lib/java/packaging.rb +4 -3
- data/lib/java/pom.rb +1 -1
- data/lib/java/test.rb +4 -4
- data/lib/tasks/zip.rb +14 -7
- metadata +12 -11
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
1.2.7 (10/29/2007)
|
2
|
+
* Added: You can create an artifact from a given file using artifact(<spec>).from(<path>). You can then install it into the local repository or upload it to the release server using install(<artifacts>) and upload(<artifacts>). (Idea: Shane Witbeck and Tommy Mason).
|
3
|
+
* Added: ANTLR support.
|
4
|
+
* Changed: Speed boost to ZIP packaging.
|
5
|
+
* Changed: RjbWrapper is now JavaWrapper, and revised to nicely support JRuby. A few other minor tweaks to make JRuby support possible in the future. (Travis Tilley)
|
6
|
+
* Changed: JUnit now runs tests with clonevm false by default, you can change with test.using :clonevm=>true (Karel)
|
7
|
+
* Changed: JUnit now switches over to project's base directory.
|
8
|
+
* Changed: package(:war).with(:libs, :classes) uses only these specified libs and class directories, replacing any previous value.
|
9
|
+
* Fixed: Jetty task no longer sets "log4j.configuration" system property
|
10
|
+
* Fixed: release task didn't work
|
11
|
+
|
1
12
|
1.2.6 (9/26/2007)
|
2
13
|
* Added: Option for setting environment name (-e) and attribute accessor (Buildr.environment). Default taken from BUILDR_ENV environment variable.
|
3
14
|
* Added: AAR packaging for Axis2 service archives (Alex Boisvert)
|
data/Rakefile
CHANGED
@@ -5,38 +5,63 @@ require "spec/rake/spectask"
|
|
5
5
|
|
6
6
|
|
7
7
|
# Gem specification comes first, other tasks rely on it.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
8
|
+
def specify(platform)
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = "buildr"
|
11
|
+
spec.version = File.read(__FILE__.pathmap("%d/lib/buildr.rb")).scan(/VERSION\s*=\s*(['"])(.*)\1/)[0][1]
|
12
|
+
spec.author = "Assaf Arkin"
|
13
|
+
spec.email = "arkin@intalio.com"
|
14
|
+
spec.homepage = "http://#{spec.name}.rubyforge.org"
|
15
|
+
spec.summary = "A build system that doesn't suck"
|
16
|
+
spec.files = FileList["lib/**/*", "CHANGELOG", "README", "LICENSE", "Rakefile"].collect
|
17
|
+
spec.require_path = "lib"
|
18
|
+
spec.autorequire = "buildr.rb"
|
19
|
+
spec.has_rdoc = true
|
20
|
+
spec.extra_rdoc_files = ["README", "CHANGELOG", "LICENSE"]
|
21
|
+
spec.rdoc_options << "--title" << "Buildr -- #{spec.summary}" <<
|
22
|
+
"--main" << "README" << "--line-numbers" << "-inline-source"
|
23
|
+
spec.rubyforge_project = "buildr"
|
24
|
+
|
25
|
+
spec.bindir = "bin" # Use these for applications.
|
26
|
+
spec.executables = ["buildr"]
|
27
|
+
|
28
|
+
# Tested against these dependencies.
|
29
|
+
spec.add_dependency "rake", "= 0.7.3"
|
30
|
+
spec.add_dependency "facets", "= 1.8.54"
|
31
|
+
spec.add_dependency "builder", "= 2.1.2"
|
32
|
+
spec.add_dependency "net-ssh", "= 1.1.2"
|
33
|
+
spec.add_dependency "net-sftp", "= 1.1.0"
|
34
|
+
spec.add_dependency "rubyzip", "= 0.9.1"
|
35
|
+
spec.add_dependency "highline", "= 1.4.0"
|
36
|
+
spec.add_dependency "Antwrap", "= 0.6.0"
|
37
|
+
spec.add_dependency "rspec", "= 1.0.8"
|
38
|
+
spec.add_dependency "xml-simple", "= 1.0.11"
|
39
|
+
spec.add_dependency "archive-tar-minitar", "= 0.5.1"
|
40
|
+
|
41
|
+
spec.platform = platform
|
42
|
+
|
43
|
+
yield spec if block_given?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
spec = specify(Gem::Platform::RUBY) { |spec| spec.add_dependency "rjb", "= 1.0.6" }
|
48
|
+
jruby_spec = specify('java')
|
49
|
+
package = Rake::GemPackageTask.new(spec) do |pkg|
|
50
|
+
pkg.need_tar = true
|
51
|
+
pkg.need_zip = true
|
52
|
+
end
|
53
|
+
jruby_package = Rake::GemPackageTask.new(jruby_spec)
|
54
|
+
|
55
|
+
desc "Install the package locally"
|
56
|
+
task :install=>:package do |task|
|
57
|
+
install = RUBY_PLATFORM == 'java' ? jruby_package : package
|
58
|
+
system 'gem', 'install', File.expand_path(install.gem_file, install.package_dir)
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Uninstall previously installed packaged"
|
62
|
+
task :uninstall do |task|
|
63
|
+
install = RUBY_PLATFORM == 'java' ? jruby_package : package
|
64
|
+
system "gem", "uninstall", install.name, "-v", install.version.to_s
|
40
65
|
end
|
41
66
|
|
42
67
|
|
@@ -55,23 +80,6 @@ Spec::Rake::SpecTask.new(:rcov) do |task|
|
|
55
80
|
end
|
56
81
|
|
57
82
|
|
58
|
-
# Packaging and local installation.
|
59
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
60
|
-
pkg.need_tar = true
|
61
|
-
pkg.need_zip = true
|
62
|
-
end
|
63
|
-
|
64
|
-
desc "Install the package locally"
|
65
|
-
task :install=>:package do |task|
|
66
|
-
system "gem", "install", "pkg/#{spec.name}-#{spec.version}.gem"
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "Uninstall previously installed packaged"
|
70
|
-
task :uninstall do |task|
|
71
|
-
system "gem", "uninstall", spec.name, "-v", spec.version.to_s
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
83
|
# Documentation.
|
76
84
|
begin
|
77
85
|
require "rake/rdoctask"
|
@@ -124,7 +132,6 @@ rescue LoadError=>error
|
|
124
132
|
end
|
125
133
|
|
126
134
|
|
127
|
-
|
128
135
|
# Commit to SVN, upload and do the release cycle.
|
129
136
|
namespace :svn do
|
130
137
|
task :clean? do |task|
|
@@ -159,7 +166,7 @@ namespace :upload do
|
|
159
166
|
fail "No changeset found for version #{spec.version}" unless current
|
160
167
|
|
161
168
|
puts "Uploading #{spec.name} #{spec.version}"
|
162
|
-
files =
|
169
|
+
files = Dir.glob('pkg/*.{gem,tgz,zip}')
|
163
170
|
rubyforge = RubyForge.new
|
164
171
|
rubyforge.login
|
165
172
|
File.open(".changes", 'w'){|f| f.write(current)}
|
@@ -203,7 +210,6 @@ desc "Upload release to RubyForge including docs, tag SVN"
|
|
203
210
|
task :release=>[ "release:ready?", "release:meat", "release:post" ]
|
204
211
|
|
205
212
|
|
206
|
-
|
207
213
|
# Misc, may not survive so don't rely on these.
|
208
214
|
task :report do |task|
|
209
215
|
puts "#{spec.name} #{spec.version}"
|
data/lib/buildr.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# in order to work around a bug in jruby (1.0.1 and trunk as of oct11, 2007)
|
2
|
+
# needle and net/ssh need to be loaded before -anything- else. please see
|
3
|
+
# http://jira.codehaus.org/browse/JRUBY-1188 for more info.
|
4
|
+
require 'needle'
|
5
|
+
require 'net/ssh'
|
6
|
+
|
1
7
|
require "highline"
|
2
8
|
require "highline/import"
|
3
9
|
# &:symbol goodness.
|
@@ -24,7 +30,7 @@ require "builder"
|
|
24
30
|
|
25
31
|
|
26
32
|
module Buildr
|
27
|
-
VERSION = "1.2.
|
33
|
+
VERSION = "1.2.7".freeze # unless const_defined?(:VERSION)
|
28
34
|
end
|
29
35
|
|
30
36
|
|
data/lib/buildr/antlr.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "java/java"
|
2
|
+
|
3
|
+
module Buildr
|
4
|
+
# Provides ANTLR grammar generation tasks. Require explicitly using <code>require "buildr/antlr"</code>.
|
5
|
+
module ANTLR
|
6
|
+
REQUIRES = [ "org.antlr:antlr:jar:3.0", "antlr:antlr:jar:2.7.7", "org.antlr:stringtemplate:jar:3.0" ]
|
7
|
+
|
8
|
+
Java.wrapper.classpath << REQUIRES
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def antlr(*args)
|
12
|
+
options = Hash === args.last ? args.pop : {}
|
13
|
+
rake_check_options options, :output, :token
|
14
|
+
|
15
|
+
args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.g"] : f }.flatten
|
16
|
+
args = ["-o", options[:output]] + args if options[:output]
|
17
|
+
if options[:token]
|
18
|
+
# antlr expects the token directory to exist when it starts
|
19
|
+
mkdir_p options[:token]
|
20
|
+
args = ["-lib", options[:token]] + args
|
21
|
+
end
|
22
|
+
Java.wrapper do |wrapper|
|
23
|
+
antlr_class = wrapper.import("org.antlr.Tool")
|
24
|
+
antlr_tool = antlr_class.new_with_sig("[Ljava.lang.String;", args)
|
25
|
+
antlr_tool.process
|
26
|
+
#wrapper.import("org.antlr.Tool").main(args) == 0 or
|
27
|
+
# fail "Failed to run ANTLR, see errors above."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def antlr(*args)
|
33
|
+
if Hash === args.last
|
34
|
+
options = args.pop
|
35
|
+
in_package = options[:in_package].split(".")
|
36
|
+
token = options[:token].split(".") if options[:token]
|
37
|
+
else
|
38
|
+
in_package = []; token = nil
|
39
|
+
end
|
40
|
+
file(path_to(:target, "generated/antlr")=>args.flatten) do |task|
|
41
|
+
args = {:output=>File.join(task.name, in_package)}
|
42
|
+
args.merge!({:token=>File.join(task.name, token)}) if token
|
43
|
+
ANTLR.antlr task.prerequisites, args
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
class Project
|
50
|
+
include ANTLR
|
51
|
+
end
|
52
|
+
end
|
data/lib/buildr/javacc.rb
CHANGED
@@ -6,7 +6,7 @@ module Buildr
|
|
6
6
|
|
7
7
|
REQUIRES = [ "net.java.dev.javacc:javacc:jar:4.0", "net.java.dev.javacc:javacc:jar:4.0" ]
|
8
8
|
|
9
|
-
Java.
|
9
|
+
Java.wrapper.classpath << REQUIRES
|
10
10
|
|
11
11
|
class << self
|
12
12
|
|
@@ -16,8 +16,8 @@ module Buildr
|
|
16
16
|
|
17
17
|
args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
|
18
18
|
args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
|
19
|
-
Java.
|
20
|
-
|
19
|
+
Java.wrapper do |jw|
|
20
|
+
jw.import("org.javacc.parser.Main").mainProgram(args) == 0 or
|
21
21
|
fail "Failed to run JavaCC, see errors above."
|
22
22
|
end
|
23
23
|
end
|
@@ -29,8 +29,8 @@ module Buildr
|
|
29
29
|
args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "**/*.jjt"] : f }.flatten
|
30
30
|
args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
|
31
31
|
args.unshift "-BUILD_NODE_FILES=#{options[:build_node_files] || false}"
|
32
|
-
Java.
|
33
|
-
|
32
|
+
Java.wrapper do |jw|
|
33
|
+
jw.import("org.javacc.jjtree.JJTree").new.main(args) == 0 or
|
34
34
|
fail "Failed to run JJTree, see errors above."
|
35
35
|
end
|
36
36
|
end
|
data/lib/buildr/jetty.rb
CHANGED
@@ -36,7 +36,7 @@ module Buildr
|
|
36
36
|
"org.mortbay.jetty:servlet-api-2.5:jar:#{VERSION}", "org.slf4j:slf4j-api:jar:#{SLF4J_VERSION}",
|
37
37
|
"org.slf4j:slf4j-simple:jar:#{SLF4J_VERSION}", "org.slf4j:jcl104-over-slf4j:jar:#{SLF4J_VERSION}" ]
|
38
38
|
|
39
|
-
Java.
|
39
|
+
Java.wrapper.setup { |jw| jw.classpath << REQUIRES << File.join(__DIR__, "jetty") }
|
40
40
|
|
41
41
|
# Default URL for Jetty (change with options.jetty.url).
|
42
42
|
URL = "http://localhost:8080"
|
@@ -74,13 +74,11 @@ module Buildr
|
|
74
74
|
# invoke the #use task instead.
|
75
75
|
def start(sync = nil)
|
76
76
|
begin
|
77
|
-
Java.
|
78
|
-
puts "
|
79
|
-
props = Rjb::import('java.lang.System').getProperties
|
80
|
-
props.setProperty("log4j.configuration", "file:./log4j.properties")
|
77
|
+
Java.wrapper do |jw|
|
78
|
+
puts "classpath #{jw.classpath.inspect}"
|
81
79
|
port = URI.parse(url).port
|
82
80
|
puts "Starting Jetty at http://localhost:#{port}" if verbose
|
83
|
-
jetty =
|
81
|
+
jetty = jw.import("JettyWrapper").new(port)
|
84
82
|
sync << "Started" if sync
|
85
83
|
sleep # Forever
|
86
84
|
end
|
data/lib/buildr/openjpa.rb
CHANGED
data/lib/buildr/scala.rb
CHANGED
@@ -44,8 +44,8 @@ module Buildr
|
|
44
44
|
if use_fsc
|
45
45
|
system ([ENV["SCALA_HOME"]+"/bin/fsc"] + cmd_args).join(" ")
|
46
46
|
else
|
47
|
-
Java.
|
48
|
-
|
47
|
+
Java.wrapper do |jw|
|
48
|
+
jw.import("scala.tools.nsc.Main").main(cmd_args) == 0 or
|
49
49
|
fail "Failed to compile, see errors above"
|
50
50
|
end
|
51
51
|
end
|
data/lib/core/build.rb
CHANGED
@@ -113,9 +113,11 @@ module Buildr
|
|
113
113
|
# Make a release.
|
114
114
|
def make()
|
115
115
|
check
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
version = with_next_version do |filename, version|
|
117
|
+
options = ['--buildfile', filename, 'DEBUG=no']
|
118
|
+
options << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?
|
119
|
+
sh "#{command} clean upload #{options.join(' ')}"
|
120
|
+
end
|
119
121
|
tag version
|
120
122
|
commit version + "-SNAPSHOT"
|
121
123
|
end
|
data/lib/java/ant.rb
CHANGED
@@ -12,7 +12,7 @@ module Buildr
|
|
12
12
|
|
13
13
|
# Libraries used by Ant.
|
14
14
|
REQUIRES = [ "org.apache.ant:ant:jar:#{VERSION}", "org.apache.ant:ant-launcher:jar:#{VERSION}", "xerces:xercesImpl:jar:2.6.2" ]
|
15
|
-
Java.
|
15
|
+
Java.wrapper.setup { |jw| jw.classpath << REQUIRES }
|
16
16
|
|
17
17
|
class << self
|
18
18
|
|
@@ -49,7 +49,7 @@ module Buildr
|
|
49
49
|
warn_deprecated "Options are ignored." if options
|
50
50
|
options = { :name=>name, :basedir=>Dir.pwd, :declarative=>true }
|
51
51
|
options.merge!(:logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG) if Rake.application.options.trace
|
52
|
-
Java.
|
52
|
+
Java.wrapper do
|
53
53
|
AntProject.new(options).tap do |project|
|
54
54
|
# Set Ant logging level to debug (--trace), info (default) or error only (--quiet).
|
55
55
|
project.project.getBuildListeners().get(0).
|
data/lib/java/artifact.rb
CHANGED
@@ -6,7 +6,6 @@ module Buildr
|
|
6
6
|
|
7
7
|
desc "Download all artifacts"
|
8
8
|
task "artifacts"
|
9
|
-
task "artifacts:refresh"
|
10
9
|
|
11
10
|
# Mixin with a task to make it behave like an artifact. Implemented by the packaging tasks.
|
12
11
|
#
|
@@ -255,6 +254,34 @@ module Buildr
|
|
255
254
|
end
|
256
255
|
end
|
257
256
|
|
257
|
+
# :call-seq:
|
258
|
+
# from(path) => self
|
259
|
+
#
|
260
|
+
# Use this when you want to install or upload an artifact from a given file, for example:
|
261
|
+
# test = artifact('group:id:jar:1.0').from('test.jar')
|
262
|
+
# install test
|
263
|
+
# See also Buildr#install and Buildr#deploy.
|
264
|
+
def from(path)
|
265
|
+
path = File.expand_path(path.to_s)
|
266
|
+
enhance [path] do
|
267
|
+
verbose false do
|
268
|
+
mkpath File.dirname(name)
|
269
|
+
pom.invoke unless type == :pom
|
270
|
+
cp path, name
|
271
|
+
puts "Installed #{path} as #{to_spec}" if verbose
|
272
|
+
end
|
273
|
+
end
|
274
|
+
unless type == :pom
|
275
|
+
pom.enhance do
|
276
|
+
verbose false do
|
277
|
+
mkpath File.dirname(pom.name)
|
278
|
+
File.open(pom.name, 'w') { |file| file.write pom.pom_xml }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
self
|
283
|
+
end
|
284
|
+
|
258
285
|
protected
|
259
286
|
|
260
287
|
# :call-seq:
|
@@ -586,6 +613,48 @@ module Buildr
|
|
586
613
|
args.flatten.map { |id| artifact :group=>hash[:under], :version=>hash[:version], :id=>id }
|
587
614
|
end
|
588
615
|
|
616
|
+
# :call-seq:
|
617
|
+
# install(artifacts)
|
618
|
+
#
|
619
|
+
# Installs the specified artifacts in the local repository as part of the install task.
|
620
|
+
#
|
621
|
+
# You can use this to install various files in the local repository, for example:
|
622
|
+
# install artifact('group:id:jar:1.0').from('some_jar.jar')
|
623
|
+
# $ buildr install
|
624
|
+
def install(*args, &block)
|
625
|
+
artifacts = artifacts(args)
|
626
|
+
raise ArgumentError, 'This method can only install artifacts' unless artifacts.all? { |f| f.respond_to?(:to_spec) }
|
627
|
+
all = (artifacts + artifacts.map { |artifact| artifact.pom }).uniq
|
628
|
+
task('install').tap do |task|
|
629
|
+
task.enhance all, &block
|
630
|
+
task 'uninstall' do
|
631
|
+
verbose false do
|
632
|
+
all.map(&:to_s ).each { |file| rm file if File.exist?(file) }
|
633
|
+
end
|
634
|
+
end
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
# :call-seq:
|
639
|
+
# upload(artifacts)
|
640
|
+
#
|
641
|
+
# Uploads the specified artifacts to the release server as part of the upload task.
|
642
|
+
#
|
643
|
+
# You can use this to upload various files to the release server, for example:
|
644
|
+
# upload artifact('group:id:jar:1.0').from('some_jar.jar')
|
645
|
+
# $ buildr upload
|
646
|
+
def upload(*args, &block)
|
647
|
+
artifacts = artifacts(args)
|
648
|
+
raise ArgumentError, 'This method can only upload artifacts' unless artifacts.all? { |f| f.respond_to?(:to_spec) }
|
649
|
+
all = (artifacts + artifacts.map { |artifact| artifact.pom }).uniq
|
650
|
+
task('upload').tap do |task|
|
651
|
+
task.enhance &block if block
|
652
|
+
task.enhance all do
|
653
|
+
all.each { |artifact| artifact.upload }
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
589
658
|
# *Deprecated* For artifact, call it's upload method; for anything else, use URI.upload.
|
590
659
|
def deploy(*args)
|
591
660
|
warn_deprecated "If it's an artifact, call it's upload method directly. Otherwise, use URI.upload."
|
data/lib/java/java.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require "rjb"
|
1
|
+
require "rjb" if RUBY_PLATFORM != 'java'
|
2
|
+
require "java" if RUBY_PLATFORM == 'java'
|
2
3
|
require "core/project"
|
3
4
|
|
4
5
|
module Buildr
|
@@ -9,7 +10,7 @@ module Buildr
|
|
9
10
|
# Options accepted by #java and other methods here.
|
10
11
|
JAVA_OPTIONS = [ :verbose, :classpath, :name, :java_args, :properties ]
|
11
12
|
|
12
|
-
# Returned by Java#
|
13
|
+
# Returned by Java#wrapper, you can use this object to set the classpath, specify blocks to be invoked
|
13
14
|
# after loading RJB, and load RJB itself.
|
14
15
|
#
|
15
16
|
# RJB can be loaded exactly once, and once loaded, you cannot change its classpath. Of course you can
|
@@ -17,52 +18,77 @@ module Buildr
|
|
17
18
|
# classpath dependencies you need in advance, before loading it.
|
18
19
|
#
|
19
20
|
# For that reason, you should not load RJB until the moment you need it. You can call #load or call
|
20
|
-
# Java#
|
21
|
-
# (see #
|
22
|
-
|
21
|
+
# Java#wrapper with a block. For the same reason, you may need to specify code to execute when loading
|
22
|
+
# (see #setup).
|
23
|
+
#
|
24
|
+
# JRuby doesn't have the above limitation, but uses the same API regardless.
|
25
|
+
class JavaWrapper #:nodoc:
|
23
26
|
|
24
27
|
include Singleton
|
25
28
|
|
26
29
|
def initialize() #:nodoc:
|
27
30
|
@classpath = [Java.tools_jar].compact
|
28
|
-
@
|
29
|
-
|
30
|
-
|
31
|
-
classpath = Buildr.artifacts(@classpath).
|
32
|
-
|
31
|
+
@setup = []
|
32
|
+
setup do
|
33
|
+
setup do
|
34
|
+
classpath = Buildr.artifacts(@classpath).
|
35
|
+
each { |task| task.invoke if task.respond_to?(:invoke) }.
|
36
|
+
map(&:to_s)
|
37
|
+
|
38
|
+
if RUBY_PLATFORM != 'java'
|
39
|
+
::Rjb.load classpath.join(File::PATH_SEPARATOR),
|
40
|
+
Buildr.options.java_args.flatten
|
41
|
+
else
|
42
|
+
classpath.each do |jlib|
|
43
|
+
require jlib
|
44
|
+
end
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
37
|
-
|
38
|
-
|
50
|
+
def classpath
|
51
|
+
if RUBY_PLATFORM == 'java'
|
52
|
+
# in order to get a complete picture, we need to add a few jars to the
|
53
|
+
# list.
|
54
|
+
java.lang.System.getProperty('java.class.path').split(':') +
|
55
|
+
@classpath
|
56
|
+
else
|
57
|
+
@classpath
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
attr_writer :classpath
|
39
62
|
|
40
|
-
|
41
|
-
|
42
|
-
#
|
43
|
-
# Adds a block to call when loading RJB and returns self.
|
44
|
-
#
|
45
|
-
# You can only load RJB once, and you may need to do some tasks after the initial load.
|
46
|
-
# For example, the Ant module requires Antwrap which can only be loaded after RJB.
|
47
|
-
def onload(&block)
|
48
|
-
@onload << block
|
63
|
+
def setup(&block)
|
64
|
+
@setup << block
|
49
65
|
self
|
50
66
|
end
|
51
67
|
|
52
|
-
# :call-seq:
|
53
|
-
# load()
|
54
|
-
#
|
55
|
-
# Loads RJB. You can also call Java#ejb with a block to get the same effect.
|
56
68
|
def load()
|
57
|
-
@
|
58
|
-
@
|
69
|
+
@setup.each { |block| block.call self }
|
70
|
+
@setup.clear
|
71
|
+
end
|
72
|
+
|
73
|
+
def import(jlib)
|
74
|
+
if RUBY_PLATFORM == 'java'
|
75
|
+
Java.send(jlib)
|
76
|
+
else
|
77
|
+
::Rjb.import jlib
|
78
|
+
end
|
59
79
|
end
|
60
80
|
|
61
81
|
def method_missing(sym, *args, &block) #:nodoc:
|
62
|
-
|
82
|
+
# these aren't the same, but depending on method_missing while
|
83
|
+
# supporting two unrelated systems is asking for trouble anyways.
|
84
|
+
if RUBY_PLATFORM == 'java'
|
85
|
+
Java.send sym, *args, &block
|
86
|
+
else
|
87
|
+
::Rjb.send sym, *args, &block
|
88
|
+
end
|
63
89
|
end
|
64
90
|
end
|
65
|
-
|
91
|
+
|
66
92
|
class << self
|
67
93
|
|
68
94
|
# :call-seq:
|
@@ -74,7 +100,7 @@ module Buildr
|
|
74
100
|
# puts Java.version
|
75
101
|
# => 1.5.0_10
|
76
102
|
def version()
|
77
|
-
@version ||= Java.
|
103
|
+
@version ||= Java.wrapper { |jw| jw.import("java.lang.System").getProperty("java.version") }
|
78
104
|
end
|
79
105
|
|
80
106
|
# :call-seq:
|
@@ -160,8 +186,8 @@ module Buildr
|
|
160
186
|
unless Rake.application.options.dryrun
|
161
187
|
puts "Running apt" if verbose
|
162
188
|
puts (["apt"] + cmd_args).join(" ") if Rake.application.options.trace
|
163
|
-
Java.
|
164
|
-
|
189
|
+
Java.wrapper do |jw|
|
190
|
+
jw.import("com.sun.tools.apt.Main").process(cmd_args) == 0 or
|
165
191
|
fail "Failed to process annotations, see errors above"
|
166
192
|
end
|
167
193
|
end
|
@@ -197,8 +223,8 @@ module Buildr
|
|
197
223
|
unless Rake.application.options.dryrun
|
198
224
|
puts "Compiling #{files.size} source files in #{name}" if verbose
|
199
225
|
puts (["javac"] + cmd_args).join(" ") if Rake.application.options.trace
|
200
|
-
Java.
|
201
|
-
|
226
|
+
Java.wrapper do |jw|
|
227
|
+
jw.import("com.sun.tools.javac.Main").compile(cmd_args) == 0 or
|
202
228
|
fail "Failed to compile, see errors above"
|
203
229
|
end
|
204
230
|
end
|
@@ -248,8 +274,8 @@ module Buildr
|
|
248
274
|
unless Rake.application.options.dryrun
|
249
275
|
puts "Generating Javadoc for #{name}" if verbose
|
250
276
|
puts (["javadoc"] + cmd_args).join(" ") if Rake.application.options.trace
|
251
|
-
Java.
|
252
|
-
|
277
|
+
Java.wrapper do |jw|
|
278
|
+
jw.import("com.sun.tools.javadoc.Main").execute(cmd_args) == 0 or
|
253
279
|
fail "Failed to generate Javadocs, see errors above"
|
254
280
|
end
|
255
281
|
end
|
@@ -292,27 +318,28 @@ module Buildr
|
|
292
318
|
|
293
319
|
|
294
320
|
# :call-seq:
|
295
|
-
#
|
296
|
-
#
|
321
|
+
# wrapper() => JavaWrapper
|
322
|
+
# wrapper() { ... }
|
297
323
|
#
|
298
|
-
# This method can be used in two ways. Without a block, returns the
|
299
|
-
# object which you can use to configure the
|
300
|
-
# With a block, loads RJB
|
324
|
+
# This method can be used in two ways. Without a block, returns the
|
325
|
+
# JavaWrapper object which you can use to configure the classpath or call
|
326
|
+
# other methods. With a block, loads RJB or sets up JRuby and yields to
|
327
|
+
# the block, returning its result.
|
301
328
|
#
|
302
329
|
# For example:
|
303
|
-
# Java.
|
304
|
-
# Java.
|
330
|
+
# Java.wrapper.classpath << REQUIRES
|
331
|
+
# Java.wrapper.setup { require "antwrap" }
|
305
332
|
#
|
306
333
|
# def execute(name, options)
|
307
334
|
# options = options.merge(:name=>name, :base_dir=>Dir.pwd, :declarative=>true)
|
308
|
-
# Java.
|
335
|
+
# Java.wrapper { AntProject.new(options) }
|
309
336
|
# end
|
310
|
-
def
|
337
|
+
def wrapper()
|
311
338
|
if block_given?
|
312
|
-
|
313
|
-
yield
|
339
|
+
JavaWrapper.instance.load
|
340
|
+
yield JavaWrapper.instance
|
314
341
|
else
|
315
|
-
|
342
|
+
JavaWrapper.instance
|
316
343
|
end
|
317
344
|
end
|
318
345
|
|
data/lib/java/packaging.rb
CHANGED
@@ -21,7 +21,8 @@ module Buildr
|
|
21
21
|
module WithManifest
|
22
22
|
|
23
23
|
class << self
|
24
|
-
|
24
|
+
# jruby issue
|
25
|
+
#protected
|
25
26
|
def included(mod)
|
26
27
|
mod.alias_method_chain :initialize, :manifest
|
27
28
|
end
|
@@ -161,11 +162,11 @@ module Buildr
|
|
161
162
|
end
|
162
163
|
|
163
164
|
def libs=(value) #:nodoc:
|
164
|
-
@libs
|
165
|
+
@libs = Buildr.artifacts(value)
|
165
166
|
end
|
166
167
|
|
167
168
|
def classes=(value) #:nodoc:
|
168
|
-
@classes
|
169
|
+
@classes = [value].flatten.map { |dir| file(dir.to_s) }
|
169
170
|
end
|
170
171
|
|
171
172
|
end
|
data/lib/java/pom.rb
CHANGED
@@ -85,7 +85,7 @@ module Buildr
|
|
85
85
|
exclusions.find {|ex| dep.index("#{dep['groupdId'].first}:#{dep['artifactId'].first}:") == 0}
|
86
86
|
} if exclusions
|
87
87
|
|
88
|
-
[Artifact.to_spec(spec
|
88
|
+
[Artifact.to_spec(spec)] + transitive_deps
|
89
89
|
end
|
90
90
|
}.flatten.compact.uniq_by{|spec| art = spec.split(':'); "#{art[0]}:#{art[1]}"}
|
91
91
|
|
data/lib/java/test.rb
CHANGED
@@ -369,7 +369,7 @@ module Buildr
|
|
369
369
|
@failed_tests = send("#{framework}_run",
|
370
370
|
:classes => classes,
|
371
371
|
:classpath => @classpath + [compile.target],
|
372
|
-
:properties => {
|
372
|
+
:properties => { 'baseDir' => compile.target.to_s }.merge(options[:properties] || {}),
|
373
373
|
:environment=> options[:environment] || {},
|
374
374
|
:java_args => options[:java_args] || Buildr.options.java_args)
|
375
375
|
unless @failed_tests.empty?
|
@@ -395,7 +395,7 @@ module Buildr
|
|
395
395
|
class Report
|
396
396
|
|
397
397
|
# Ant-Trax required for running the JUnitReport task.
|
398
|
-
Java.
|
398
|
+
Java.wrapper.setup { |jw| jw.classpath << "org.apache.ant:ant-trax:jar:#{Ant::VERSION}" }
|
399
399
|
|
400
400
|
# Parameters passed to the Ant JUnitReport task.
|
401
401
|
attr_reader :params
|
@@ -447,7 +447,7 @@ module Buildr
|
|
447
447
|
JUNIT_TESTS_PATTERN = [ "Test*", "*Test" ]
|
448
448
|
|
449
449
|
# Ant-JUnit requires for JUnit and JUnit reports tasks.
|
450
|
-
Java.
|
450
|
+
Java.wrapper.setup { |jw| jw.classpath << "org.apache.ant:ant-junit:jar:#{Ant::VERSION}" }
|
451
451
|
|
452
452
|
class << self
|
453
453
|
|
@@ -485,7 +485,7 @@ module Buildr
|
|
485
485
|
else
|
486
486
|
fail "Option fork must be :once, :each or false."
|
487
487
|
end
|
488
|
-
ant.junit forking.merge(:clonevm=>
|
488
|
+
ant.junit forking.merge(:clonevm=>options[:clonevm] || false, :dir=>@project.path_to) do
|
489
489
|
ant.classpath :path=>args[:classpath].map(&:to_s).each { |path| file(path).invoke }.join(File::PATH_SEPARATOR)
|
490
490
|
args[:properties].each { |key, value| ant.sysproperty :key=>key, :value=>value }
|
491
491
|
args[:environment].each { |key, value| ant.env :key=>key, :value=>value }
|
data/lib/tasks/zip.rb
CHANGED
@@ -401,23 +401,30 @@ module Buildr
|
|
401
401
|
private
|
402
402
|
|
403
403
|
def create_from(file_map)
|
404
|
-
Zip::
|
405
|
-
|
404
|
+
Zip::ZipOutputStream.open name do |zip|
|
405
|
+
seen = {}
|
406
406
|
mkpath = lambda do |dir|
|
407
|
-
unless dir == "." ||
|
407
|
+
unless dir == "." || seen[dir]
|
408
408
|
mkpath.call File.dirname(dir)
|
409
|
-
zip.
|
409
|
+
zip.put_next_entry dir + '/'
|
410
|
+
seen[dir] = true
|
410
411
|
end
|
411
412
|
end
|
412
|
-
|
413
|
+
|
413
414
|
file_map.each do |path, content|
|
414
415
|
mkpath.call File.dirname(path)
|
415
416
|
if content.respond_to?(:call)
|
416
|
-
zip.
|
417
|
+
zip.put_next_entry path
|
418
|
+
content.call zip
|
417
419
|
elsif content.nil? || File.directory?(content.to_s)
|
418
420
|
mkpath.call path
|
419
421
|
else
|
420
|
-
zip.
|
422
|
+
zip.put_next_entry path
|
423
|
+
File.open content.to_s, "rb" do |is|
|
424
|
+
while data = is.read(4096)
|
425
|
+
zip << data
|
426
|
+
end
|
427
|
+
end
|
421
428
|
end
|
422
429
|
end
|
423
430
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: buildr
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.2.7
|
7
|
+
date: 2007-10-29 00:00:00 -07:00
|
8
8
|
summary: A build system that doesn't suck
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/buildr/cobertura.rb
|
54
54
|
- lib/buildr/jdepend.rb
|
55
55
|
- lib/buildr/openjpa.rb
|
56
|
+
- lib/buildr/antlr.rb
|
56
57
|
- lib/buildr/jetty
|
57
58
|
- lib/buildr/jetty/JettyWrapper.java
|
58
59
|
- lib/buildr/jetty/JettyWrapper$1.class
|
@@ -156,15 +157,6 @@ dependencies:
|
|
156
157
|
- !ruby/object:Gem::Version
|
157
158
|
version: 1.4.0
|
158
159
|
version:
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: rjb
|
161
|
-
version_requirement:
|
162
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 1.0.6
|
167
|
-
version:
|
168
160
|
- !ruby/object:Gem::Dependency
|
169
161
|
name: Antwrap
|
170
162
|
version_requirement:
|
@@ -201,3 +193,12 @@ dependencies:
|
|
201
193
|
- !ruby/object:Gem::Version
|
202
194
|
version: 0.5.1
|
203
195
|
version:
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: rjb
|
198
|
+
version_requirement:
|
199
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
200
|
+
requirements:
|
201
|
+
- - "="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: 1.0.6
|
204
|
+
version:
|