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/buildr/cobertura.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
module Buildr
|
2
|
-
|
3
|
-
# Addes the <code>cobertura:html</code> and <code>cobertura:xml</code> tasks.
|
4
|
-
# Require explicitly using <code>require "buildr/cobertura"</code>.
|
5
|
-
module Cobertura
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
REQUIRES = ["net.sourceforge.cobertura:cobertura:jar:1.9", "log4j:log4j:jar:1.2.9",
|
10
|
-
"asm:asm:jar:2.2.1", "asm:asm-tree:jar:2.2.1", "oro:oro:jar:2.0.8"]
|
11
|
-
|
12
|
-
def requires()
|
13
|
-
@requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
|
14
|
-
end
|
15
|
-
|
16
|
-
def report_to(file = nil)
|
17
|
-
File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
|
18
|
-
end
|
19
|
-
|
20
|
-
def data_file()
|
21
|
-
File.expand_path("reports/cobertura.ser")
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
namespace "cobertura" do
|
27
|
-
|
28
|
-
task "instrument" do
|
29
|
-
Buildr.projects.each do |project|
|
30
|
-
unless project.compile.sources.empty?
|
31
|
-
# Instrumented bytecode goes in a different directory. This task creates before running the test
|
32
|
-
# cases and monitors for changes in the generate bytecode.
|
33
|
-
instrumented = project.file(project.path_to(:target, "instrumented")=>project.compile.target) do |task|
|
34
|
-
Buildr.ant "cobertura" do |ant|
|
35
|
-
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
|
36
|
-
ant.send "cobertura-instrument", :todir=>task.to_s, :datafile=>data_file do
|
37
|
-
ant.fileset(:dir=>project.compile.target.to_s) { ant.include :name=>"**/*.class" }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
touch task.to_s, :verbose=>false
|
41
|
-
end
|
42
|
-
# We now have two target directories with bytecode. It would make sense to remove compile.target
|
43
|
-
# and add instrumented instead, but apparently Cobertura only creates some of the classes, so
|
44
|
-
# we need both directories and instrumented must come first.
|
45
|
-
project.test.classpath.unshift instrumented
|
46
|
-
project.test.with requires
|
47
|
-
project.test.options[:properties]["net.sourceforge.cobertura.datafile"] = data_file
|
48
|
-
project.clean { rm_rf instrumented.to_s, :verbose=>false }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
desc "Run the test cases and produce code coverage reports in #{report_to(:html)}"
|
54
|
-
task "html"=>["instrument", "test"] do
|
55
|
-
puts "Creating test coverage reports in #{report_to(:html)}"
|
56
|
-
Buildr.ant "cobertura" do |ant|
|
57
|
-
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
|
58
|
-
ant.send "cobertura-report", :destdir=>report_to(:html), :format=>"html", :datafile=>data_file do
|
59
|
-
Buildr.projects.map(&:compile).map(&:sources).flatten.each do |src|
|
60
|
-
ant.fileset(:dir=>src.to_s) { ant.include :name=>"**/*.java" } if File.exist?(src.to_s)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
desc "Run the test cases and produce code coverage reports in #{report_to(:xml)}"
|
67
|
-
task "xml"=>["instrument", "test"] do
|
68
|
-
puts "Creating test coverage reports in #{report_to(:xml)}"
|
69
|
-
Buildr.ant "cobertura" do |ant|
|
70
|
-
ant.taskdef :classpath=>requires.join(File::PATH_SEPARATOR), :resource=>"tasks.properties"
|
71
|
-
ant.send "cobertura-report", :destdir=>report_to(:xml), :format=>"xml", :datafile=>data_file do
|
72
|
-
Buildr.projects.map(&:compile).map(&:sources).flatten.each do |src|
|
73
|
-
ant.fileset :dir=>src.to_s if File.exist?(src.to_s)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
task "clean" do
|
80
|
-
rm_rf [report_to, data_file], :verbose=>false
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
task "clean" do
|
85
|
-
task("cobertura:clean").invoke if Dir.pwd == Rake.application.original_dir
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
data/lib/buildr/jdepend.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module Buildr
|
2
|
-
|
3
|
-
# Addes the <code>jdepend:swing</code>, <code>jdepend:text</code> and <code>jdepend:xml</code> tasks.
|
4
|
-
# Require explicitly using <code>require "buildr/jdepend"</code>.
|
5
|
-
module Jdepend
|
6
|
-
|
7
|
-
REQUIRES = ["jdepend:jdepend:jar:2.9.1"]
|
8
|
-
|
9
|
-
class << self
|
10
|
-
|
11
|
-
def requires()
|
12
|
-
@requires ||= Buildr.artifacts(REQUIRES).each(&:invoke).map(&:to_s)
|
13
|
-
end
|
14
|
-
|
15
|
-
def paths()
|
16
|
-
Project.projects.map(&:compile).each(&:invoke).map(&:target).map(&:to_s).select { |path| File.exist?(path) }
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
namespace "jdepend" do
|
22
|
-
|
23
|
-
desc "Runs JDepend on all your projects (Swing UI)"
|
24
|
-
task "swing" do
|
25
|
-
Buildr.java "jdepend.swingui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "Runs JDepend on all your projects (Text UI)"
|
29
|
-
task "text" do
|
30
|
-
Buildr.java "jdepend.textui.JDepend", paths, :classpath=>requires, :name=>"JDepend"
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "Runs JDepend on all your projects (XML output to jdepend.xml)"
|
34
|
-
task "xml" do
|
35
|
-
Buildr.java "jdepend.xmlui.JDepend", "-file", "jdepend.xml", paths, :classpath=>requires, :name=>"JDepend"
|
36
|
-
puts "Created jdepend.xml"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
Binary file
|
Binary file
|
Binary file
|
data/lib/buildr/scala.rb
DELETED
@@ -1,368 +0,0 @@
|
|
1
|
-
require "java/java"
|
2
|
-
|
3
|
-
# TODO List
|
4
|
-
# -Eclipse support
|
5
|
-
# -SUnit
|
6
|
-
# -Cleanup compiler options
|
7
|
-
|
8
|
-
module Buildr
|
9
|
-
|
10
|
-
module Scala
|
11
|
-
class << self
|
12
|
-
def scala_home
|
13
|
-
ENV["SCALA_HOME"]
|
14
|
-
end
|
15
|
-
|
16
|
-
def scala_lib
|
17
|
-
scala_lib = scala_home + "/lib/scala-library.jar"
|
18
|
-
end
|
19
|
-
|
20
|
-
def scalac(*args)
|
21
|
-
options = Hash === args.last ? args.pop : {}
|
22
|
-
rake_check_options options, :classpath, :sourcepath, :output, :scalac_args, :name
|
23
|
-
|
24
|
-
files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).
|
25
|
-
collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.scala"] : arg }.flatten
|
26
|
-
name = options[:name] || Dir.pwd
|
27
|
-
return if files.empty?
|
28
|
-
|
29
|
-
fail "Missing SCALA_HOME environment variable" unless ENV["SCALA_HOME"]
|
30
|
-
fail "Invalid SCALA_HOME environment variable" unless File.directory? ENV["SCALA_HOME"]
|
31
|
-
|
32
|
-
cmd_args = []
|
33
|
-
use_fsc = !(ENV["USE_FSC"] =~ /^(no|off|false)$/i)
|
34
|
-
classpath = classpath_from(options)
|
35
|
-
scala_cp = [ classpath, FileList["#{scala_home}/lib/*"] ].flatten.join(File::PATH_SEPARATOR)
|
36
|
-
cmd_args << "-cp" << scala_cp unless scala_cp.empty?
|
37
|
-
cmd_args << "-sourcepath" << options[:sourcepath].join(File::PATH_SEPARATOR) if options[:sourcepath]
|
38
|
-
cmd_args << "-d" << options[:output].to_s if options[:output]
|
39
|
-
cmd_args += options[:scalac_args].flatten if options[:scalac_args]
|
40
|
-
cmd_args += files
|
41
|
-
unless Rake.application.options.dryrun
|
42
|
-
puts "Compiling #{files.size} source files in #{name}" if verbose
|
43
|
-
puts (["scalac"] + cmd_args).join(" ") if Rake.application.options.trace
|
44
|
-
if use_fsc
|
45
|
-
system ([ENV["SCALA_HOME"]+"/bin/fsc"] + cmd_args).join(" ")
|
46
|
-
else
|
47
|
-
Java.wrapper do |jw|
|
48
|
-
jw.import("scala.tools.nsc.Main").main(cmd_args) == 0 or
|
49
|
-
fail "Failed to compile, see errors above"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
protected
|
56
|
-
|
57
|
-
# :call-seq:
|
58
|
-
# classpath_from(options) => files
|
59
|
-
#
|
60
|
-
# Extracts the classpath from the options, expands it by calling artifacts, invokes
|
61
|
-
# each of the artifacts and returns an array of paths.
|
62
|
-
def classpath_from(options)
|
63
|
-
classpath = (options[:classpath] || []).collect
|
64
|
-
Buildr.artifacts(classpath).each { |t| t.invoke if t.respond_to?(:invoke) }.map(&:to_s)
|
65
|
-
end
|
66
|
-
end # Scala << self
|
67
|
-
|
68
|
-
|
69
|
-
# !! This is mostly a copy-paste Buildr:Java:CompileTask !!
|
70
|
-
#
|
71
|
-
# Wraps Scalac in a task that does all the heavy lifting.
|
72
|
-
#
|
73
|
-
# Accepts multiple source directories that are invoked as prerequisites before compilation.
|
74
|
-
# You can pass a task as a source directory, e.g. compile.from(apt).
|
75
|
-
#
|
76
|
-
# Likewise, classpath dependencies are invoked before compiling. All classpath dependencies
|
77
|
-
# are evaluated as #artifacts, so you can pass artifact specifications and even projects.
|
78
|
-
#
|
79
|
-
# Creates a file task for the target directory, so executing that task as a dependency will
|
80
|
-
# execute the compile task first.
|
81
|
-
#
|
82
|
-
# Compiler options are inherited form a parent task, e.g. the foo:bar:compile task inherits
|
83
|
-
# its options from the foo:compile task. Even if foo is an empty project that does not compile
|
84
|
-
# any classes itself, you can use it to set compile options for all its sub-projects.
|
85
|
-
#
|
86
|
-
# Normally, the project will take care of setting the source and target directory, and you
|
87
|
-
# only need to set options and classpath dependencies. See Project#compile.
|
88
|
-
class ScalaCompilerTask < Rake::Task
|
89
|
-
|
90
|
-
# Compiler options, accessible from CompileTask#options.
|
91
|
-
#
|
92
|
-
# Supported options are:
|
93
|
-
# - warnings -- Generate warnings if true (opposite of -nowarn).
|
94
|
-
# - deprecation -- Output source locations where deprecated APIs are used.
|
95
|
-
# - source -- Source compatibility with specified release.
|
96
|
-
# - target -- Class file compatibility with specified release.
|
97
|
-
# - lint -- Value to pass to xlint argument. Use true to enable default lint
|
98
|
-
# options, or pass a specific setting as string or array of strings.
|
99
|
-
# - debug -- Generate debugging info.
|
100
|
-
# - other -- Array of options to pass to the Scalac compiler as is.
|
101
|
-
#
|
102
|
-
# For example:
|
103
|
-
# compile.options.warnings = true
|
104
|
-
# compile.options.source = options.target = "1.6"
|
105
|
-
class Options
|
106
|
-
|
107
|
-
include InheritedAttributes
|
108
|
-
|
109
|
-
OPTIONS = [:warnings, :deprecation, :source, :target, :lint, :debug, :other]
|
110
|
-
|
111
|
-
# Generate warnings (opposite of -nowarn).
|
112
|
-
attr_accessor :warnings
|
113
|
-
inherited_attr(:warnings) { verbose }
|
114
|
-
# Output source locations where deprecated APIs are used.
|
115
|
-
attr_accessor :deprecation
|
116
|
-
inherited_attr :deprecation, false
|
117
|
-
# Provide source compatibility with specified release.
|
118
|
-
attr_accessor :source
|
119
|
-
inherited_attr :source
|
120
|
-
# Generate class files for specific VM version.
|
121
|
-
attr_accessor :target
|
122
|
-
inherited_attr :target
|
123
|
-
# Values to pass to Xlint: string or array. Use true to enable
|
124
|
-
# Xlint with no values.
|
125
|
-
attr_accessor :lint
|
126
|
-
inherited_attr :lint, false
|
127
|
-
# Generate all debugging info.
|
128
|
-
attr_accessor :debug
|
129
|
-
inherited_attr(:debug) { Buildr.options.debug }
|
130
|
-
# Array of arguments passed to the Scalac compiler as is.
|
131
|
-
attr_accessor :other
|
132
|
-
inherited_attr :other
|
133
|
-
|
134
|
-
def initialize(parent = nil) #:nodoc:
|
135
|
-
@parent = parent
|
136
|
-
end
|
137
|
-
|
138
|
-
attr_reader :parent # :nodoc:
|
139
|
-
|
140
|
-
# Resets all the options.
|
141
|
-
def clear()
|
142
|
-
OPTIONS.each { |name| send "#{name}=", nil }
|
143
|
-
end
|
144
|
-
|
145
|
-
def to_s() #:nodoc:
|
146
|
-
OPTIONS.inject({}){ |hash, name| hash[name] = send(name) ; hash }.reject{ |name,value| value.nil? }.inspect
|
147
|
-
end
|
148
|
-
|
149
|
-
# Returns Scalac command line arguments from the set of options.
|
150
|
-
def scalac_args()
|
151
|
-
args = []
|
152
|
-
args << "-nowarn" unless warnings
|
153
|
-
args << "-verbose" if Rake.application.options.trace
|
154
|
-
args << "-g" if debug
|
155
|
-
args << "-deprecation" if deprecation
|
156
|
-
args << "-source" << source.to_s if source
|
157
|
-
args << "-target:jvm-" + target.to_s if target
|
158
|
-
case lint
|
159
|
-
when Array
|
160
|
-
args << "-Xlint:#{lint.join(',')}"
|
161
|
-
when String
|
162
|
-
args << "-Xlint:#{lint}"
|
163
|
-
when true
|
164
|
-
args << "-Xlint"
|
165
|
-
end
|
166
|
-
args.concat(other.to_a) if other
|
167
|
-
args
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
def initialize(*args) #:nodoc:
|
174
|
-
super
|
175
|
-
parent = Rake::Task["^scalac"] if name[":"] # Only if in namespace
|
176
|
-
if parent && parent.respond_to?(:options)
|
177
|
-
@options = Options.new(parent.options)
|
178
|
-
else
|
179
|
-
@options = Options.new
|
180
|
-
end
|
181
|
-
@sources = []
|
182
|
-
@classpath = []
|
183
|
-
|
184
|
-
enhance do |task|
|
185
|
-
mkpath target.to_s, :verbose=>false
|
186
|
-
Scala.scalac source_files.keys, :sourcepath=>sources.map(&:to_s).select { |source| File.directory?(source) }.uniq,
|
187
|
-
:classpath=>classpath, :output=>target, :scalac_args=>options.scalac_args, :name=>task.name
|
188
|
-
# By touching the target we let other tasks know we did something,
|
189
|
-
# and also prevent recompiling again for classpath dependencies.
|
190
|
-
touch target.to_s, :verbose=>false
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
# Source directories and files to compile.
|
195
|
-
attr_accessor :sources
|
196
|
-
|
197
|
-
# :call-seq:
|
198
|
-
# from(*sources) => self
|
199
|
-
#
|
200
|
-
# Adds source directories and files to compile, and returns self.
|
201
|
-
#
|
202
|
-
# For example:
|
203
|
-
# compile.from("src/scala").into("classes").with("module1.jar")
|
204
|
-
def from(*sources)
|
205
|
-
@sources |= sources.flatten
|
206
|
-
self
|
207
|
-
end
|
208
|
-
|
209
|
-
# Classpath dependencies.
|
210
|
-
attr_accessor :classpath
|
211
|
-
|
212
|
-
# :call-seq:
|
213
|
-
# with(*artifacts) => self
|
214
|
-
#
|
215
|
-
# Adds files and artifacts as classpath dependencies, and returns self.
|
216
|
-
#
|
217
|
-
# Calls #artifacts on the arguments, so you can pass artifact specifications,
|
218
|
-
# tasks, projects, etc. Use this rather than setting the classpath directly.
|
219
|
-
#
|
220
|
-
# For example:
|
221
|
-
# compile.with("module1.jar", "log4j:log4j:jar:1.0", project("foo"))
|
222
|
-
def with(*specs)
|
223
|
-
@classpath |= Buildr.artifacts(specs.flatten).uniq
|
224
|
-
self
|
225
|
-
end
|
226
|
-
|
227
|
-
# The target directory for the generated class files.
|
228
|
-
attr_reader :target
|
229
|
-
|
230
|
-
# :call-seq:
|
231
|
-
# into(path) => self
|
232
|
-
#
|
233
|
-
# Sets the target directory and returns self. This will also set the compile task
|
234
|
-
# as a prerequisite to a file task on the target directory.
|
235
|
-
#
|
236
|
-
# For example:
|
237
|
-
# compile(src_dir).into(target_dir).with(artifacts)
|
238
|
-
# Both compile.invoke and file(target_dir).invoke will compile the source files.
|
239
|
-
def into(path)
|
240
|
-
path = File.expand_path(path.to_s)
|
241
|
-
@target = file(path).enhance([self]) unless @target && @target.to_s == path
|
242
|
-
self
|
243
|
-
end
|
244
|
-
|
245
|
-
# Returns the compiler options.
|
246
|
-
attr_reader :options
|
247
|
-
|
248
|
-
# :call-seq:
|
249
|
-
# using(options) => self
|
250
|
-
#
|
251
|
-
# Sets the compiler options from a hash and returns self.
|
252
|
-
#
|
253
|
-
# For example:
|
254
|
-
# compile.using(:warnings=>true, :source=>"1.5")
|
255
|
-
def using(*args)
|
256
|
-
args.pop.each { |key, value| options.send "#{key}=", value } if Hash === args.last
|
257
|
-
args.each { |key| options.send "#{key}=", value = true }
|
258
|
-
self
|
259
|
-
end
|
260
|
-
|
261
|
-
def timestamp() #:nodoc:
|
262
|
-
# If we compiled successfully, then the target directory reflects that.
|
263
|
-
# If we didn't, see needed?
|
264
|
-
target ? target.timestamp : Rake::EARLY
|
265
|
-
end
|
266
|
-
|
267
|
-
def needed?() #:nodoc:
|
268
|
-
return false if source_files.empty?
|
269
|
-
return true unless File.exist?(target.to_s)
|
270
|
-
return true if source_files.any? { |j, c| !File.exist?(c) || File.stat(j).mtime > File.stat(c).mtime }
|
271
|
-
oldest = source_files.map { |j, c| File.stat(c).mtime }.min
|
272
|
-
return classpath.any? { |path| application[path].timestamp > oldest }
|
273
|
-
end
|
274
|
-
|
275
|
-
def prerequisites() #:nodoc:
|
276
|
-
super + classpath + sources
|
277
|
-
end
|
278
|
-
|
279
|
-
def invoke_prerequisites() #:nodoc:
|
280
|
-
prerequisites.each { |n| application[n, @scope].invoke }
|
281
|
-
end
|
282
|
-
|
283
|
-
# Returns the files to compile. This list is derived from the list of sources,
|
284
|
-
# expanding directories into files, and includes only source files that are
|
285
|
-
# newer than the corresponding class file. Includes all files if one or more
|
286
|
-
# classpath dependency has been updated.
|
287
|
-
def source_files()
|
288
|
-
@source_files ||= @sources.map(&:to_s).inject({}) do |map, source|
|
289
|
-
raise "Compile task #{name} has source files, but no target directory" unless target
|
290
|
-
target_dir = target.to_s
|
291
|
-
if File.directory?(source)
|
292
|
-
base = Pathname.new(source)
|
293
|
-
FileList["#{source}/**/*.scala"].
|
294
|
-
each { |file| map[file] = File.join(target_dir, Pathname.new(file).relative_path_from(base).to_s.ext(".class")) }
|
295
|
-
else
|
296
|
-
map[source] = File.join(target_dir, File.basename(source).ext(".class"))
|
297
|
-
end
|
298
|
-
map
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
def scala_lib
|
303
|
-
Scala.scala_lib
|
304
|
-
end
|
305
|
-
end # ScalaCompilerTask
|
306
|
-
|
307
|
-
end # Scala
|
308
|
-
|
309
|
-
# Local task to execute the Scalac compile task of the current project.
|
310
|
-
# This task is not itself a compile task.
|
311
|
-
desc "Compile all scalac projects"
|
312
|
-
Project.local_task("scalac") { |name| "Compiling scala sources for #{name}" }
|
313
|
-
|
314
|
-
class Project
|
315
|
-
|
316
|
-
# :call-seq:
|
317
|
-
# compile(*sources) => CompileTask
|
318
|
-
# compile(*sources) { |task| .. } => CompileTask
|
319
|
-
#
|
320
|
-
# The compile task does what its name suggests. This method returns the project's
|
321
|
-
# CompileTask. It also accepts a list of source directories and files to compile
|
322
|
-
# (equivalent to calling CompileTask#from on the task), and a block for any
|
323
|
-
# post-compilation work.
|
324
|
-
#
|
325
|
-
# The compile task will pick all the source files in the src/main/scala directory,
|
326
|
-
# and unless specified, compile them into the target/classes directory. It will pick
|
327
|
-
# the default values for compiler options from the parent project's compile task.
|
328
|
-
#
|
329
|
-
# For example:
|
330
|
-
# # Force target compatibility.
|
331
|
-
# compile.options.source = "1.6"
|
332
|
-
# # Include Apt-generated source files.
|
333
|
-
# compile.from apt
|
334
|
-
# # Include Log4J and the api sub-project artifacts.
|
335
|
-
# compile.with "log4j:log4j:jar:1.2", project("api")
|
336
|
-
# # Run the OpenJPA bytecode enhancer after compilation.
|
337
|
-
# compile { open_jpa_enhance }
|
338
|
-
#
|
339
|
-
# For more information, see Scala::ScalaCompilerTask.
|
340
|
-
def scalac(*sources, &block)
|
341
|
-
task("scalac").from(sources).enhance &block
|
342
|
-
end
|
343
|
-
|
344
|
-
end # Project
|
345
|
-
|
346
|
-
Project.on_define do |project|
|
347
|
-
# Scalac runs after compile task (and therefore, after "prepare" and "resources")
|
348
|
-
scalac = Scala::ScalaCompilerTask.define_task("scalac"=>[task("compile")])
|
349
|
-
project.path_to("src/main/scala").tap { |dir| scalac.from dir if File.exist?(dir) }
|
350
|
-
scalac.into project.path_to(:target, "classes")
|
351
|
-
project.recursive_task("scalac")
|
352
|
-
|
353
|
-
project.enhance do |project|
|
354
|
-
# This comes last because the target path may change.
|
355
|
-
project.packages.each do |p|
|
356
|
-
p.with scalac.target if p.type == :jar
|
357
|
-
p.classes = scalac.target if p.type == :war
|
358
|
-
end
|
359
|
-
# Work-in-progress
|
360
|
-
#project.task("eclipse").classpathContainers 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
|
361
|
-
|
362
|
-
project.build project.scalac.target
|
363
|
-
project.clean { verbose(false) { rm_rf project.scalac.target.to_s } }
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
end # Buildr
|
368
|
-
|