buildr 1.2.10 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
data/lib/java/idea.rb
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
require "core/project"
|
3
|
-
require "java/artifact"
|
4
|
-
require 'stringio'
|
5
|
-
require 'rexml/document'
|
6
|
-
|
7
|
-
module Buildr
|
8
|
-
|
9
|
-
# Global task "idea" generates artifacts for all projects.
|
10
|
-
desc "Generate Idea artifacts for all projects"
|
11
|
-
Project.local_task "idea"=>"artifacts"
|
12
|
-
|
13
|
-
Project.on_define do |project|
|
14
|
-
idea = project.recursive_task("idea")
|
15
|
-
|
16
|
-
project.enhance do |project|
|
17
|
-
|
18
|
-
# We need paths relative to the top project's base directory.
|
19
|
-
root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir } ; f[p] }[project]
|
20
|
-
# We want the Eclipse files changed every time the Buildfile changes, but also anything loaded by
|
21
|
-
# the Buildfile (buildr.rb, separate file listing dependencies, etc), so we add anything required
|
22
|
-
# after the Buildfile. So which don't know where Buildr shows up exactly, ignore files that show
|
23
|
-
# in $LOADED_FEATURES that we cannot resolve.
|
24
|
-
sources = Buildr.build_files.map { |file| File.expand_path(file) }.select { |file| File.exist?(file) }
|
25
|
-
sources << File.expand_path(Rake.application.rakefile, root_path) if Rake.application.rakefile
|
26
|
-
|
27
|
-
# Find a path relative to the project's root directory.
|
28
|
-
relative = lambda do |path|
|
29
|
-
msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
|
30
|
-
path = path.__send__(msg)
|
31
|
-
Pathname.new(path).relative_path_from(Pathname.new(project.path_to)).to_s
|
32
|
-
end
|
33
|
-
|
34
|
-
m2repo = Buildr::Repositories.instance.local
|
35
|
-
excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
36
|
-
|
37
|
-
# Only for projects that are packageable.
|
38
|
-
task_name = project.path_to("#{project.name.gsub(':', '-')}.iml")
|
39
|
-
idea.enhance [ file(task_name) ]
|
40
|
-
|
41
|
-
# The only thing we need to look for is a change in the Buildfile.
|
42
|
-
file(task_name=>sources) do |task|
|
43
|
-
puts "Writing #{task.name}" if verbose
|
44
|
-
|
45
|
-
# Idea handles modules slightly differently if they're WARs
|
46
|
-
idea_types = Hash.new("JAVA_MODULE")
|
47
|
-
idea_types["war"] = "J2EE_WEB_MODULE"
|
48
|
-
|
49
|
-
# Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
|
50
|
-
cp = project.test.compile.classpath.map(&:to_s) - [ project.compile.target.to_s ]
|
51
|
-
|
52
|
-
# Convert classpath elements into applicable Project objects
|
53
|
-
cp.collect! { |path| projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
|
54
|
-
|
55
|
-
# project_libs: artifacts created by other projects
|
56
|
-
project_libs, others = cp.partition { |path| path.is_a?(Project) }
|
57
|
-
|
58
|
-
# Separate artifacts from Maven2 repository
|
59
|
-
m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
|
60
|
-
|
61
|
-
# Generated: classpath elements in the project are assumed to be generated
|
62
|
-
generated, libs = others.partition { |path| path.to_s.index(project.path_to.to_s) == 0 }
|
63
|
-
|
64
|
-
File.open(task.name, "w") do |file|
|
65
|
-
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
66
|
-
# Project type is going to be the first package type
|
67
|
-
xml.module(:version=>"4", :relativePaths=>"false", :type=>idea_types[project.packages.first.type.to_s]) do
|
68
|
-
|
69
|
-
xml.component :name=>"ModuleRootManager"
|
70
|
-
xml.component "name"=>"NewModuleRootManager", "inherit-compiler-output"=>"false" do
|
71
|
-
xml.output :url=>"file://$MODULE_DIR$/#{relative[project.compile.target]}"
|
72
|
-
xml.tag! "exclude-output"
|
73
|
-
|
74
|
-
# TODO project.test.target isn't recognized, what's the proper way to get the test compile path?
|
75
|
-
xml.tag! "output-test", :url=>"file://$MODULE_DIR$/target/test-classes"
|
76
|
-
|
77
|
-
xml.content(:url=>"file://$MODULE_DIR$") do
|
78
|
-
srcs = project.compile.sources.map { |src| relative[src] } + generated.map { |src| relative[src] }
|
79
|
-
srcs.sort.uniq.each do |path|
|
80
|
-
xml.sourceFolder :url=>"file://$MODULE_DIR$/#{path}", :isTestSource=>"false"
|
81
|
-
end
|
82
|
-
test_sources = project.test.compile.sources.map { |src| relative[src] }
|
83
|
-
test_sources.each do |paths|
|
84
|
-
paths.sort.uniq.each do |path|
|
85
|
-
xml.sourceFolder :url=>"file://$MODULE_DIR$/#{path}", :isTestSource=>"true"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
{"src/main/resources"=>false, "src/test/resources"=>true}.each do |key, value|
|
89
|
-
xml.sourceFolder :url=>"file://$MODULE_DIR$/#{key}", :isTestSource=>"#{value}" if File.exist?(project.path_to(key))
|
90
|
-
end
|
91
|
-
xml.excludeFolder :url=>"file://$MODULE_DIR$/#{relative[project.compile.target]}"
|
92
|
-
end
|
93
|
-
|
94
|
-
xml.orderEntry :type=>"sourceFolder", :forTests=>"false"
|
95
|
-
xml.orderEntry :type=>"inheritedJdk"
|
96
|
-
|
97
|
-
# Classpath elements from other projects
|
98
|
-
project_libs.map(&:id).sort.uniq.each do |project_id|
|
99
|
-
xml.orderEntry :type=>'module', "module-name"=>project_id
|
100
|
-
end
|
101
|
-
|
102
|
-
# Libraries
|
103
|
-
ext_libs = libs.map {|path| "$MODULE_DIR$/#{path.to_s}" } +
|
104
|
-
m2_libs.map { |path| path.to_s.sub(m2repo, "$M2_REPO$") }
|
105
|
-
ext_libs.each do |path|
|
106
|
-
xml.orderEntry :type=>"module-library" do
|
107
|
-
xml.library do
|
108
|
-
xml.CLASSES do
|
109
|
-
xml.root :url=>"jar://#{path}!/"
|
110
|
-
end
|
111
|
-
xml.JAVADOC
|
112
|
-
xml.SOURCES
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
xml.orderEntryProperties
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
# Root project aggregates all the subprojects.
|
124
|
-
if project.parent == nil
|
125
|
-
task_name = project.path_to("#{project.name.gsub(':', '-')}.ipr")
|
126
|
-
idea.enhance [ file(task_name) ]
|
127
|
-
|
128
|
-
file(task_name=>sources) do |task|
|
129
|
-
puts "Writing #{task.name}" if verbose
|
130
|
-
|
131
|
-
# Generating just the little stanza that chanages from one project to another
|
132
|
-
partial = StringIO.new
|
133
|
-
xml = Builder::XmlMarkup.new(:target=>partial, :indent=>2)
|
134
|
-
xml.component(:name=>"ProjectModuleManager") do
|
135
|
-
xml.modules do
|
136
|
-
project.projects.each do |subp|
|
137
|
-
module_name = subp.name.gsub(":", "-")
|
138
|
-
module_path = subp.name.split(":"); module_path.shift
|
139
|
-
module_path = module_path.join("/")
|
140
|
-
path = "#{module_path}/#{module_name}.iml"
|
141
|
-
xml.module :fileurl=>"file://$PROJECT_DIR$/#{path}", :filepath=>"$PROJECT_DIR$/#{path}"
|
142
|
-
end
|
143
|
-
xml.module :fileurl=>"file://$PROJECT_DIR$/#{project.name}.iml", :filepath=>"$PROJECT_DIR$/#{project.name}.iml"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# Loading the whole fairly constant crap
|
148
|
-
template_xml = REXML::Document.new(File.open(File.dirname(__FILE__)+"/idea.ipr.template"))
|
149
|
-
include_xml = REXML::Document.new(partial.string)
|
150
|
-
template_xml.root.add_element(include_xml.root)
|
151
|
-
template_xml.write(File.new(task.name, "w"))
|
152
|
-
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
end # module Buildr
|
data/lib/java/java.rb
DELETED
@@ -1,432 +0,0 @@
|
|
1
|
-
require "rjb" if RUBY_PLATFORM != 'java'
|
2
|
-
require "java" if RUBY_PLATFORM == 'java'
|
3
|
-
require "core/project"
|
4
|
-
|
5
|
-
module Buildr
|
6
|
-
|
7
|
-
# Base module for all things Java.
|
8
|
-
module Java
|
9
|
-
|
10
|
-
# Options accepted by #java and other methods here.
|
11
|
-
JAVA_OPTIONS = [ :verbose, :classpath, :name, :java_args, :properties ]
|
12
|
-
|
13
|
-
# Returned by Java#wrapper, you can use this object to set the classpath, specify blocks to be invoked
|
14
|
-
# after loading RJB, and load RJB itself.
|
15
|
-
#
|
16
|
-
# RJB can be loaded exactly once, and once loaded, you cannot change its classpath. Of course you can
|
17
|
-
# call libraries that manage their own classpath, but the lazy way is to just tell RJB of all the
|
18
|
-
# classpath dependencies you need in advance, before loading it.
|
19
|
-
#
|
20
|
-
# For that reason, you should not load RJB until the moment you need it. You can call #load or call
|
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:
|
26
|
-
|
27
|
-
include Singleton
|
28
|
-
|
29
|
-
def initialize() #:nodoc:
|
30
|
-
@classpath = [Java.tools_jar].compact
|
31
|
-
if RUBY_PLATFORM == 'java'
|
32
|
-
# in order to get a complete picture, we need to add a few jars to the list.
|
33
|
-
@classpath += java.lang.System.getProperty('java.class.path').split(':').compact
|
34
|
-
end
|
35
|
-
@setup = []
|
36
|
-
|
37
|
-
setup do
|
38
|
-
setup do
|
39
|
-
cp = Buildr.artifacts(@classpath).map(&:to_s)
|
40
|
-
cp.each { |path| file(path).invoke }
|
41
|
-
|
42
|
-
if RUBY_PLATFORM == 'java'
|
43
|
-
cp.each do |jlib|
|
44
|
-
require jlib
|
45
|
-
end
|
46
|
-
else
|
47
|
-
::Rjb.load cp.join(File::PATH_SEPARATOR), Buildr.options.java_args.flatten
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
attr_accessor :classpath
|
54
|
-
|
55
|
-
def setup(&block)
|
56
|
-
@setup << block
|
57
|
-
self
|
58
|
-
end
|
59
|
-
|
60
|
-
def onload(&block)
|
61
|
-
warn_deprecated "use setup { |wrapper| ... } instead"
|
62
|
-
setup &block
|
63
|
-
end
|
64
|
-
|
65
|
-
def load(&block)
|
66
|
-
@setup.each { |block| block.call self }
|
67
|
-
@setup.clear
|
68
|
-
end
|
69
|
-
|
70
|
-
def import(jlib)
|
71
|
-
if RUBY_PLATFORM == 'java'
|
72
|
-
::Java.send(jlib)
|
73
|
-
else
|
74
|
-
::Rjb.import jlib
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def method_missing(sym, *args, &block) #:nodoc:
|
79
|
-
# these aren't the same, but depending on method_missing while
|
80
|
-
# supporting two unrelated systems is asking for trouble anyways.
|
81
|
-
if RUBY_PLATFORM == 'java'
|
82
|
-
::Java.send sym, *args, &block
|
83
|
-
else
|
84
|
-
::Rjb.send sym, *args, &block
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class << self
|
90
|
-
|
91
|
-
# :call-seq:
|
92
|
-
# version() => string
|
93
|
-
#
|
94
|
-
# Returns the version number of the JVM.
|
95
|
-
#
|
96
|
-
# For example:
|
97
|
-
# puts Java.version
|
98
|
-
# => 1.5.0_10
|
99
|
-
def version()
|
100
|
-
@version ||= Java.wrapper { |jw| jw.import("java.lang.System").getProperty("java.version") }
|
101
|
-
end
|
102
|
-
|
103
|
-
# :call-seq:
|
104
|
-
# tools_jar() => path
|
105
|
-
#
|
106
|
-
# Returns a path to tools.jar. On OS/X which has not tools.jar, returns an empty array,
|
107
|
-
# on all other platforms, fails if it doesn't find tools.jar.
|
108
|
-
def tools_jar()
|
109
|
-
return [] if darwin?
|
110
|
-
@tools ||= [File.join(home, "lib/tools.jar")] or raise "I need tools.jar to compile, can't find it in #{home}/lib"
|
111
|
-
end
|
112
|
-
|
113
|
-
# :call-seq:
|
114
|
-
# home() => path
|
115
|
-
#
|
116
|
-
# Returns JAVA_HOME, fails if JAVA_HOME not set.
|
117
|
-
def home()
|
118
|
-
@home ||= ENV["JAVA_HOME"] or fail "Are we forgetting something? JAVA_HOME not set."
|
119
|
-
end
|
120
|
-
|
121
|
-
# :call-seq:
|
122
|
-
# java(class, *args, options?)
|
123
|
-
#
|
124
|
-
# Runs Java with the specified arguments.
|
125
|
-
#
|
126
|
-
# The last argument may be a Hash with additional options:
|
127
|
-
# * :classpath -- One or more file names, tasks or artifact specifications.
|
128
|
-
# These are all expanded into artifacts, and all tasks are invoked.
|
129
|
-
# * :java_args -- Any additional arguments to pass (e.g. -hotspot, -xms)
|
130
|
-
# * :properties -- Hash of system properties (e.g. "path"=>base_dir).
|
131
|
-
# * :name -- Shows this name, otherwise shows the first argument (the class name).
|
132
|
-
# * :verbose -- If true, prints the command and all its argument.
|
133
|
-
def java(*args, &block)
|
134
|
-
options = Hash === args.last ? args.pop : {}
|
135
|
-
options[:verbose] ||= Rake.application.options.trace || false
|
136
|
-
rake_check_options options, *JAVA_OPTIONS
|
137
|
-
|
138
|
-
name = options[:name] || "java #{args.first}"
|
139
|
-
cmd_args = [path_to_bin("java")]
|
140
|
-
classpath = classpath_from(options)
|
141
|
-
cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
142
|
-
options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
|
143
|
-
cmd_args += (options[:java_args] || Buildr.options.java_args).flatten
|
144
|
-
cmd_args += args.flatten.compact
|
145
|
-
unless Rake.application.options.dryrun
|
146
|
-
puts "Running #{name}" if verbose
|
147
|
-
block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
|
148
|
-
puts cmd_args.join(" ") if Rake.application.options.trace
|
149
|
-
system(cmd_args.map { |arg| %Q{"#{arg}"} }.join(" ")).tap do |ok|
|
150
|
-
block.call ok, $?
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
# :call-seq:
|
156
|
-
# apt(*files, options)
|
157
|
-
#
|
158
|
-
# Runs Apt with the specified arguments.
|
159
|
-
#
|
160
|
-
# The last argument may be a Hash with additional options:
|
161
|
-
# * :compile -- If true, compile source files to class files.
|
162
|
-
# * :source -- Specifies source compatibility with a given JVM release.
|
163
|
-
# * :output -- Directory where to place the generated source files, or the
|
164
|
-
# generated class files when compiling.
|
165
|
-
# * :classpath -- One or more file names, tasks or artifact specifications.
|
166
|
-
# These are all expanded into artifacts, and all tasks are invoked.
|
167
|
-
def apt(*args)
|
168
|
-
options = Hash === args.last ? args.pop : {}
|
169
|
-
rake_check_options options, :compile, :source, :output, :classpath
|
170
|
-
|
171
|
-
files = args.flatten.map(&:to_s).
|
172
|
-
collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
|
173
|
-
cmd_args = [ Rake.application.options.trace ? "-verbose" : "-nowarn" ]
|
174
|
-
if options[:compile]
|
175
|
-
cmd_args << "-d" << options[:output].to_s
|
176
|
-
else
|
177
|
-
cmd_args << "-nocompile" << "-s" << options[:output].to_s
|
178
|
-
end
|
179
|
-
cmd_args << "-source" << options[:source] if options[:source]
|
180
|
-
classpath = classpath_from(options)
|
181
|
-
cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
182
|
-
cmd_args += files
|
183
|
-
unless Rake.application.options.dryrun
|
184
|
-
puts "Running apt" if verbose
|
185
|
-
puts (["apt"] + cmd_args).join(" ") if Rake.application.options.trace
|
186
|
-
Java.wrapper do |jw|
|
187
|
-
jw.import("com.sun.tools.apt.Main").process(cmd_args) == 0 or
|
188
|
-
fail "Failed to process annotations, see errors above"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
# :call-seq:
|
194
|
-
# javac(*files, options)
|
195
|
-
#
|
196
|
-
# Runs Javac with the specified arguments.
|
197
|
-
#
|
198
|
-
# The last argument may be a Hash with additional options:
|
199
|
-
# * :output -- Target directory for all compiled class files.
|
200
|
-
# * :classpath -- One or more file names, tasks or artifact specifications.
|
201
|
-
# These are all expanded into artifacts, and all tasks are invoked.
|
202
|
-
# * :sourcepath -- Additional source paths to use.
|
203
|
-
# * :javac_args -- Any additional arguments to pass (e.g. -extdirs, -encoding)
|
204
|
-
# * :name -- Shows this name, otherwise shows the working directory.
|
205
|
-
def javac(*args)
|
206
|
-
options = Hash === args.last ? args.pop : {}
|
207
|
-
rake_check_options options, :classpath, :sourcepath, :output, :javac_args, :name
|
208
|
-
|
209
|
-
files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).
|
210
|
-
collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
|
211
|
-
name = options[:name] || Dir.pwd
|
212
|
-
|
213
|
-
cmd_args = []
|
214
|
-
classpath = classpath_from(options)
|
215
|
-
cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
216
|
-
cmd_args << "-sourcepath" << options[:sourcepath].join(File::PATH_SEPARATOR) if options[:sourcepath]
|
217
|
-
cmd_args << "-d" << options[:output].to_s if options[:output]
|
218
|
-
cmd_args += options[:javac_args].flatten if options[:javac_args]
|
219
|
-
cmd_args += files
|
220
|
-
unless Rake.application.options.dryrun
|
221
|
-
puts "Compiling #{files.size} source files in #{name}" if verbose
|
222
|
-
puts (["javac"] + cmd_args).join(" ") if Rake.application.options.trace
|
223
|
-
Java.wrapper do |jw|
|
224
|
-
jw.import("com.sun.tools.javac.Main").compile(cmd_args) == 0 or
|
225
|
-
fail "Failed to compile, see errors above"
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
# :call-seq:
|
231
|
-
# javadoc(*files, options)
|
232
|
-
#
|
233
|
-
# Runs Javadocs with the specified files and options.
|
234
|
-
#
|
235
|
-
# This method accepts the following special options:
|
236
|
-
# * :output -- The output directory
|
237
|
-
# * :classpath -- Array of classpath dependencies.
|
238
|
-
# * :sourcepath -- Array of sourcepaths (paths or tasks).
|
239
|
-
# * :name -- Shows this name, otherwise shows the working directory.
|
240
|
-
#
|
241
|
-
# All other options are passed to Javadoc as following:
|
242
|
-
# * true -- As is, for example, :author=>true becomes -author
|
243
|
-
# * false -- Prefixed, for example, :index=>false becomes -noindex
|
244
|
-
# * string -- Option with value, for example, :windowtitle=>"My project" becomes -windowtitle "My project"
|
245
|
-
# * array -- Option with set of values separated by spaces.
|
246
|
-
def javadoc(*args)
|
247
|
-
options = Hash === args.last ? args.pop : {}
|
248
|
-
|
249
|
-
cmd_args = [ "-d", options[:output], Rake.application.options.trace ? "-verbose" : "-quiet" ]
|
250
|
-
options.reject { |key, value| [:output, :name, :sourcepath, :classpath].include?(key) }.
|
251
|
-
each { |key, value| value.invoke if value.respond_to?(:invoke) }.
|
252
|
-
each do |key, value|
|
253
|
-
case value
|
254
|
-
when true, nil
|
255
|
-
cmd_args << "-#{key}"
|
256
|
-
when false
|
257
|
-
cmd_args << "-no#{key}"
|
258
|
-
when Hash
|
259
|
-
value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
|
260
|
-
else
|
261
|
-
cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
|
262
|
-
end
|
263
|
-
end
|
264
|
-
[:sourcepath, :classpath].each do |option|
|
265
|
-
options[option].to_a.flatten.tap do |paths|
|
266
|
-
cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
|
267
|
-
end
|
268
|
-
end
|
269
|
-
cmd_args += args.flatten.uniq
|
270
|
-
name = options[:name] || Dir.pwd
|
271
|
-
unless Rake.application.options.dryrun
|
272
|
-
puts "Generating Javadoc for #{name}" if verbose
|
273
|
-
puts (["javadoc"] + cmd_args).join(" ") if Rake.application.options.trace
|
274
|
-
Java.wrapper do |jw|
|
275
|
-
jw.import("com.sun.tools.javadoc.Main").execute(cmd_args) == 0 or
|
276
|
-
fail "Failed to generate Javadocs, see errors above"
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
# :call-seq:
|
282
|
-
# junit(*classes, options) => [ passed, failed ]
|
283
|
-
#
|
284
|
-
# Runs JUnit test cases from the specified classes. Returns an array with two lists,
|
285
|
-
# one containing the names of all classes that passes, the other containing the names
|
286
|
-
# of all classes that failed.
|
287
|
-
#
|
288
|
-
# The last argument may be a Hash with additional options:
|
289
|
-
# * :classpath -- One or more file names, tasks or artifact specifications.
|
290
|
-
# These are all expanded into artifacts, and all tasks are invoked.
|
291
|
-
# * :properties -- Hash of system properties (e.g. "path"=>base_dir).
|
292
|
-
# * :java_args -- Any additional arguments to pass (e.g. -hotspot, -xms)
|
293
|
-
# * :verbose -- If true, prints the command and all its argument.
|
294
|
-
#
|
295
|
-
# *Deprecated:* Please use JUnitTask instead.Use the test task to run JUnit and other test frameworks.
|
296
|
-
def junit(*args)
|
297
|
-
warn_deprecated "Use the test task to run JUnit and other test frameworks"
|
298
|
-
options = Hash === args.last ? args.pop : {}
|
299
|
-
options[:verbose] ||= Rake.application.options.trace || false
|
300
|
-
rake_check_options options, :verbose, :classpath, :properties, :java_args
|
301
|
-
|
302
|
-
classpath = classpath_from(options) + JUnitTask::requires
|
303
|
-
tests = args.flatten
|
304
|
-
failed = tests.inject([]) do |failed, test|
|
305
|
-
begin
|
306
|
-
java "junit.textui.TestRunner", test, :classpath=>classpath, :properties=>options[:properties],
|
307
|
-
:name=>"#{test}", :verbose=>options[:verbose], :java_args=>options[:java_args]
|
308
|
-
failed
|
309
|
-
rescue
|
310
|
-
failed << test
|
311
|
-
end
|
312
|
-
end
|
313
|
-
[ tests - failed, failed ]
|
314
|
-
end
|
315
|
-
|
316
|
-
|
317
|
-
# :call-seq:
|
318
|
-
# wrapper() => JavaWrapper
|
319
|
-
# wrapper() { ... }
|
320
|
-
#
|
321
|
-
# This method can be used in two ways. Without a block, returns the
|
322
|
-
# JavaWrapper object which you can use to configure the classpath or call
|
323
|
-
# other methods. With a block, loads RJB or sets up JRuby and yields to
|
324
|
-
# the block, returning its result.
|
325
|
-
#
|
326
|
-
# For example:
|
327
|
-
# # Add class path dependency.
|
328
|
-
# Java.wrapper.classpath << REQUIRES
|
329
|
-
# # Require AntWrap when loading RJB/JRuby.
|
330
|
-
# Java.wrapper.setup { require "antwrap" }
|
331
|
-
#
|
332
|
-
# def execute(name, options)
|
333
|
-
# options = options.merge(:name=>name, :base_dir=>Dir.pwd, :declarative=>true)
|
334
|
-
# # Load RJB/JRuby and run AntWrap.
|
335
|
-
# Java.wrapper { AntProject.new(options) }
|
336
|
-
# end
|
337
|
-
def wrapper()
|
338
|
-
if block_given?
|
339
|
-
JavaWrapper.instance.load
|
340
|
-
yield JavaWrapper.instance
|
341
|
-
else
|
342
|
-
JavaWrapper.instance
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
def rjb(&block)
|
347
|
-
warn_deprecated "please use Java.wrapper() instead"
|
348
|
-
wrapper &block
|
349
|
-
end
|
350
|
-
|
351
|
-
# :call-seq:
|
352
|
-
# path_to_bin(cmd?) => path
|
353
|
-
#
|
354
|
-
# Returns the path to the specified Java command (with no argument to java itself).
|
355
|
-
def path_to_bin(name = "java")
|
356
|
-
File.join(home, "bin", name)
|
357
|
-
end
|
358
|
-
|
359
|
-
protected
|
360
|
-
|
361
|
-
# :call-seq:
|
362
|
-
# classpath_from(options) => files
|
363
|
-
#
|
364
|
-
# Extracts the classpath from the options, expands it by calling artifacts, invokes
|
365
|
-
# each of the artifacts and returns an array of paths.
|
366
|
-
def classpath_from(options)
|
367
|
-
classpath = (options[:classpath] || []).collect
|
368
|
-
Buildr.artifacts(classpath).each { |t| t.invoke if t.respond_to?(:invoke) }.map(&:to_s)
|
369
|
-
end
|
370
|
-
|
371
|
-
def darwin?() #:nodoc:
|
372
|
-
RUBY_PLATFORM =~ /darwin/i
|
373
|
-
end
|
374
|
-
|
375
|
-
end
|
376
|
-
|
377
|
-
# See Java#java.
|
378
|
-
def java(*args)
|
379
|
-
Java.java(*args)
|
380
|
-
end
|
381
|
-
|
382
|
-
# :call-seq:
|
383
|
-
# apt(*sources) => task
|
384
|
-
#
|
385
|
-
# Returns a task that will use Java#apt to generate source files in target/generated/apt,
|
386
|
-
# from all the source directories passed as arguments. Uses the compile.sources list if
|
387
|
-
# on arguments supplied.
|
388
|
-
#
|
389
|
-
# For example:
|
390
|
-
#
|
391
|
-
def apt(*sources)
|
392
|
-
sources = compile.sources if sources.empty?
|
393
|
-
file(path_to(:target, "generated/apt")=>sources) do |task|
|
394
|
-
Java.apt(sources.map(&:to_s) - [task.name], :output=>task.name,
|
395
|
-
:classpath=>compile.classpath, :source=>compile.options.source)
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
end
|
400
|
-
|
401
|
-
include Java
|
402
|
-
|
403
|
-
class Options
|
404
|
-
|
405
|
-
# :call-seq:
|
406
|
-
# java_args => array
|
407
|
-
#
|
408
|
-
# Returns the Java arguments.
|
409
|
-
def java_args()
|
410
|
-
@java_args ||= (ENV["JAVA_OPTS"] || ENV["JAVA_OPTIONS"] || "").split(" ")
|
411
|
-
end
|
412
|
-
|
413
|
-
# :call-seq:
|
414
|
-
# java_args = array|string|nil
|
415
|
-
#
|
416
|
-
# Sets the Java arguments. These arguments are used when creating a JVM, including for use with RJB
|
417
|
-
# for most tasks (e.g. Ant, compile) and when forking a separate JVM (e.g. JUnit tests). You can also
|
418
|
-
# use the JAVA_OPTS environment variable.
|
419
|
-
#
|
420
|
-
# For example:
|
421
|
-
# options.java_args = "-verbose"
|
422
|
-
# Or:
|
423
|
-
# $ set JAVA_OPTS = "-Xms1g"
|
424
|
-
# $ buildr
|
425
|
-
def java_args=(args)
|
426
|
-
args = args.split if String === args
|
427
|
-
@java_args = args.to_a
|
428
|
-
end
|
429
|
-
|
430
|
-
end
|
431
|
-
|
432
|
-
end
|