buildr 1.4.2-x86-mswin32 → 1.4.3-x86-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +29 -3
- data/LICENSE +0 -0
- data/NOTICE +0 -0
- data/_jbuildr +2 -0
- data/addon/buildr/antlr.rb +0 -0
- data/addon/buildr/cobertura.rb +0 -0
- data/addon/buildr/drb.rb +0 -0
- data/addon/buildr/emma.rb +0 -0
- data/addon/buildr/javacc.rb +0 -0
- data/addon/buildr/jdepend.rb +0 -0
- data/addon/buildr/jetty.rb +0 -0
- data/addon/buildr/jibx.rb +0 -0
- data/addon/buildr/nailgun.rb +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -0
- data/addon/buildr/xmlbeans.rb +0 -0
- data/buildr.gemspec +1 -1
- data/doc/_config.yml +0 -0
- data/doc/_layouts/preface.html +0 -0
- data/doc/css/syntax.css +0 -0
- data/doc/extending.textile +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +14 -15
- data/doc/mailing_lists.textile +0 -0
- data/doc/more_stuff.textile +54 -1
- data/doc/releasing.textile +17 -16
- data/doc/settings_profiles.textile +13 -13
- data/lib/buildr.rb +1 -0
- data/lib/buildr/core.rb +1 -0
- data/lib/buildr/core/application.rb +8 -3
- data/lib/buildr/core/checks.rb +0 -0
- data/lib/buildr/core/doc.rb +15 -4
- data/lib/buildr/core/environment.rb +0 -0
- data/lib/buildr/core/generate.rb +0 -0
- data/lib/buildr/core/help.rb +0 -0
- data/lib/buildr/core/progressbar.rb +0 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/util.rb +21 -3
- data/lib/buildr/ide.rb +0 -0
- data/lib/buildr/ide/idea.ipr.template +0 -0
- data/lib/buildr/ide/idea.rb +0 -0
- data/lib/buildr/ide/idea7x.ipr.template +0 -0
- data/lib/buildr/java/doc.rb +16 -0
- data/lib/buildr/java/packaging.rb +9 -4
- data/lib/buildr/packaging.rb +0 -0
- data/lib/buildr/packaging/archive.rb +4 -4
- data/lib/buildr/packaging/artifact.rb +16 -15
- data/lib/buildr/packaging/artifact_search.rb +0 -0
- data/lib/buildr/packaging/gems.rb +0 -0
- data/lib/buildr/packaging/package.rb +1 -1
- data/lib/buildr/packaging/version_requirement.rb +0 -0
- data/lib/buildr/packaging/ziptask.rb +6 -4
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/run.rb +202 -0
- data/lib/buildr/scala/doc.rb +18 -0
- data/lib/buildr/scala/tests.rb +3 -0
- data/lib/buildr/shell.rb +1 -1
- data/lib/buildr/version.rb +1 -1
- data/rakelib/doc.rake +23 -5
- data/rakelib/release.rake +0 -0
- data/rakelib/setup.rake +2 -2
- data/rakelib/stage.rake +3 -3
- data/spec/addon/drb_spec.rb +0 -0
- data/spec/core/application_spec.rb +65 -27
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/run_spec.rb +92 -0
- data/spec/java/compiler_spec.rb +0 -194
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/packaging_spec.rb +30 -14
- data/spec/java/run_spec.rb +78 -0
- data/spec/packaging/archive_spec.rb +20 -5
- data/spec/packaging/artifact_spec.rb +23 -14
- data/spec/packaging/packaging_helper.rb +0 -0
- data/spec/scala/doc_spec.rb +68 -0
- metadata +151 -143
data/lib/buildr/core/checks.rb
CHANGED
File without changes
|
data/lib/buildr/core/doc.rb
CHANGED
@@ -74,7 +74,6 @@ module Buildr
|
|
74
74
|
# Returns the documentation tool options.
|
75
75
|
attr_reader :options
|
76
76
|
|
77
|
-
|
78
77
|
attr_reader :project # :nodoc:
|
79
78
|
|
80
79
|
def initialize(*args) #:nodoc:
|
@@ -158,6 +157,19 @@ module Buildr
|
|
158
157
|
@engine ||= guess_engine
|
159
158
|
end
|
160
159
|
|
160
|
+
# :call-seq:
|
161
|
+
# engine?(clazz) => boolean
|
162
|
+
#
|
163
|
+
# Check if the underlying engine is an instance of the given class
|
164
|
+
def engine?(clazz)
|
165
|
+
begin
|
166
|
+
@engine ||= guess_engine if project.compile.language
|
167
|
+
rescue
|
168
|
+
return false
|
169
|
+
end
|
170
|
+
@engine.is_a?(clazz) if @engine
|
171
|
+
end
|
172
|
+
|
161
173
|
# :call-seq:
|
162
174
|
# from(*sources) => self
|
163
175
|
#
|
@@ -221,15 +233,14 @@ module Buildr
|
|
221
233
|
Project.local_task :doc
|
222
234
|
end
|
223
235
|
|
224
|
-
before_define do |project|
|
236
|
+
before_define(:doc) do |project|
|
225
237
|
DocTask.define_task('doc').tap do |doc|
|
226
238
|
doc.send(:associate_with, project)
|
227
239
|
doc.into project.path_to(:target, :doc)
|
228
|
-
doc.using :windowtitle=>project.comment || project.name
|
229
240
|
end
|
230
241
|
end
|
231
242
|
|
232
|
-
after_define do |project|
|
243
|
+
after_define(:doc) do |project|
|
233
244
|
project.doc.from project
|
234
245
|
end
|
235
246
|
|
File without changes
|
data/lib/buildr/core/generate.rb
CHANGED
File without changes
|
data/lib/buildr/core/help.rb
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'buildr/run'
|
17
|
+
require 'buildr/java/commands'
|
18
|
+
require 'buildr/core/util'
|
19
|
+
|
20
|
+
module Buildr
|
21
|
+
module Run
|
22
|
+
|
23
|
+
class JavaRunner < Base
|
24
|
+
include Shell::JavaRebel
|
25
|
+
|
26
|
+
specify :name => :java, :languages => [:java, :scala, :groovy, :clojure]
|
27
|
+
|
28
|
+
def run(task)
|
29
|
+
fail "Missing :main option" unless task.options[:main]
|
30
|
+
cp = project.compile.dependencies + [project.path_to(:target, :classes)] + task.classpath
|
31
|
+
Java::Commands.java(task.options[:main], {
|
32
|
+
:properties => rebel_props(project).merge(task.options[:properties] || {}),
|
33
|
+
:classpath => cp,
|
34
|
+
:java_args => rebel_args + (task.options[:java_args] || [])
|
35
|
+
})
|
36
|
+
end
|
37
|
+
end # JavaRunnner
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Buildr::Run.runners << Buildr::Run::JavaRunner
|
43
|
+
|
data/lib/buildr/core/util.rb
CHANGED
@@ -54,7 +54,7 @@ module Buildr
|
|
54
54
|
def ruby(*args)
|
55
55
|
options = Hash === args.last ? args.pop : {}
|
56
56
|
cmd = []
|
57
|
-
ruby_bin =
|
57
|
+
ruby_bin = normalize_path(Config::CONFIG['ruby_install_name'], Config::CONFIG['bindir'])
|
58
58
|
if options.delete(:sudo) && !(win_os? || Process.uid == File.stat(ruby_bin).uid)
|
59
59
|
cmd << 'sudo' << '-u' << "##{File.stat(ruby_bin).uid}"
|
60
60
|
end
|
@@ -142,8 +142,20 @@ module Buildr
|
|
142
142
|
# is not running interactively (on a tty)
|
143
143
|
def install(*dependencies)
|
144
144
|
raise ArgumentError, "Expected at least one argument" if dependencies.empty?
|
145
|
-
|
146
|
-
|
145
|
+
not_found_deps = []
|
146
|
+
to_install = []
|
147
|
+
remote = dependencies.each do |dep|
|
148
|
+
if spec = Gem.source_index.search(dep).last
|
149
|
+
# Found in local repo
|
150
|
+
to_install << spec
|
151
|
+
elsif (spec = Gem::SpecFetcher.fetcher.fetch(dep, true).map { |spec, source| spec }.last)
|
152
|
+
# Found in remote repo
|
153
|
+
to_install << spec
|
154
|
+
else
|
155
|
+
# Not found anywhere
|
156
|
+
not_found_deps << "#{dep.name} #{dep.requirement}"
|
157
|
+
end
|
158
|
+
end
|
147
159
|
fail Gem::LoadError, "Build requires the gems #{not_found_deps.join(', ')}, which cannot be found in local or remote repository." unless not_found_deps.empty?
|
148
160
|
uses = "This build requires the gems #{to_install.map(&:full_name).join(', ')}:"
|
149
161
|
fail Gem::LoadError, "#{uses} to install, run Buildr interactively." unless $stdout.isatty
|
@@ -330,6 +342,12 @@ end
|
|
330
342
|
if Buildr::Util.java_platform?
|
331
343
|
require 'ffi'
|
332
344
|
|
345
|
+
# Workaround for BUILDR-535: when requiring 'ffi', JRuby defines an :error
|
346
|
+
# method with arity 0.
|
347
|
+
class Module
|
348
|
+
remove_method :error if method_defined?(:error)
|
349
|
+
end
|
350
|
+
|
333
351
|
# Fix for BUILDR-292.
|
334
352
|
# JRuby fails to rename a file on different devices
|
335
353
|
# this monkey-patch wont be needed when JRUBY-3381 gets resolved.
|
data/lib/buildr/ide.rb
CHANGED
File without changes
|
File without changes
|
data/lib/buildr/ide/idea.rb
CHANGED
File without changes
|
File without changes
|
data/lib/buildr/java/doc.rb
CHANGED
@@ -18,6 +18,18 @@ require 'buildr/core/doc'
|
|
18
18
|
module Buildr
|
19
19
|
module Doc
|
20
20
|
|
21
|
+
module JavadocDefaults
|
22
|
+
include Extension
|
23
|
+
|
24
|
+
# Default javadoc -windowtitle to project's comment or name
|
25
|
+
after_define(:javadoc => :doc) do |project|
|
26
|
+
if project.doc.engine? Javadoc
|
27
|
+
options = project.doc.options
|
28
|
+
options[:windowtitle] = (project.comment || project.name) unless options[:windowtitle]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
21
33
|
# A convenient task for creating Javadocs from the project's compile task. Minimizes all
|
22
34
|
# the hard work to calling #from and #using.
|
23
35
|
#
|
@@ -65,6 +77,10 @@ module Buildr
|
|
65
77
|
end
|
66
78
|
end
|
67
79
|
end
|
80
|
+
|
81
|
+
class Project
|
82
|
+
include JavadocDefaults
|
83
|
+
end
|
68
84
|
end
|
69
85
|
|
70
86
|
Buildr::Doc.engines << Buildr::Doc::Javadoc
|
@@ -56,9 +56,14 @@ module Buildr
|
|
56
56
|
#
|
57
57
|
# Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new Manifest.
|
58
58
|
def from_zip(file)
|
59
|
-
Zip::
|
60
|
-
|
59
|
+
Zip::ZipInputStream::open(file.to_s) do |zip|
|
60
|
+
while (entry = zip.get_next_entry)
|
61
|
+
if entry.name == 'META-INF/MANIFEST.MF'
|
62
|
+
return Manifest.parse zip.read
|
63
|
+
end
|
64
|
+
end
|
61
65
|
end
|
66
|
+
Manifest.new
|
62
67
|
end
|
63
68
|
|
64
69
|
# :call-seq:
|
@@ -257,7 +262,7 @@ module Buildr
|
|
257
262
|
@classes = []
|
258
263
|
@libs = []
|
259
264
|
enhance do |war|
|
260
|
-
@libs.each {|lib| lib.invoke}
|
265
|
+
@libs.each {|lib| lib.invoke if lib.respond_to?(:invoke) }
|
261
266
|
@classes.to_a.flatten.each { |classes| include classes, :as => 'WEB-INF/classes' }
|
262
267
|
path('WEB-INF/lib').include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
|
263
268
|
end
|
@@ -625,7 +630,7 @@ module Buildr
|
|
625
630
|
selected = options[:only] ? projects(options[:only]) :
|
626
631
|
options[:except] ? ([self] + projects - projects(options[:except])) :
|
627
632
|
[self] + projects
|
628
|
-
selected.reject { |project| project.compile.sources.empty? }.
|
633
|
+
selected.reject { |project| project.compile.sources.empty? && project.resources.target.nil? }.
|
629
634
|
each { |project| project.package(:sources) }
|
630
635
|
end
|
631
636
|
end
|
data/lib/buildr/packaging.rb
CHANGED
File without changes
|
@@ -202,7 +202,7 @@ module Buildr
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def include_as(source, as)
|
205
|
-
|
205
|
+
|
206
206
|
@sources << proc { source }
|
207
207
|
@actions << proc do |file_map|
|
208
208
|
file = source.to_s
|
@@ -212,19 +212,19 @@ module Buildr
|
|
212
212
|
path = rel_path.split('/')[1..-1]
|
213
213
|
path.unshift as unless as == '.'
|
214
214
|
dest = "#{@path}#{path.join('/')}"
|
215
|
-
unless excluded?(dest)
|
215
|
+
unless excluded?(dest)
|
216
216
|
trace "Adding #{dest}"
|
217
217
|
file_map[dest] = file
|
218
218
|
end
|
219
219
|
end
|
220
220
|
unless as == "."
|
221
221
|
trace "Adding #{@path}#{as}/"
|
222
|
-
file_map["#{@path}#{as}/"] =
|
222
|
+
file_map["#{@path}#{as}/"] = nil # :as is a folder, so the trailing / is required.
|
223
223
|
end
|
224
224
|
else
|
225
225
|
file_map["#{@path}#{as}"] = file
|
226
226
|
end
|
227
|
-
|
227
|
+
|
228
228
|
end
|
229
229
|
end
|
230
230
|
end
|
@@ -488,23 +488,23 @@ module Buildr
|
|
488
488
|
end
|
489
489
|
|
490
490
|
protected
|
491
|
-
|
491
|
+
|
492
492
|
# :call-seq:
|
493
493
|
# needed?
|
494
494
|
#
|
495
495
|
# Validates whether artifact is required to be downloaded from repository
|
496
496
|
def needed?
|
497
|
-
return true if snapshot? && File.exist?(name) && old?
|
498
|
-
super
|
497
|
+
return true if snapshot? && File.exist?(name) && (update_snapshot? || old?)
|
498
|
+
super
|
499
499
|
end
|
500
|
-
|
500
|
+
|
501
501
|
private
|
502
|
-
|
502
|
+
|
503
503
|
# :call-seq:
|
504
504
|
# download_artifact
|
505
505
|
#
|
506
|
-
# Downloads artifact from given repository,
|
507
|
-
# supports downloading snapshot artifact with relocation on succeed to local repository
|
506
|
+
# Downloads artifact from given repository,
|
507
|
+
# supports downloading snapshot artifact with relocation on succeed to local repository
|
508
508
|
def download_artifact(path)
|
509
509
|
download_file = "#{name}.#{Time.new.to_i}"
|
510
510
|
begin
|
@@ -517,7 +517,7 @@ module Buildr
|
|
517
517
|
File.delete(download_file) if File.exist?(download_file)
|
518
518
|
end
|
519
519
|
end
|
520
|
-
|
520
|
+
|
521
521
|
# :call-seq:
|
522
522
|
# :download_needed?
|
523
523
|
#
|
@@ -529,22 +529,22 @@ module Buildr
|
|
529
529
|
return false if offline? && File.exist?(name)
|
530
530
|
return true if update_snapshot? || old?
|
531
531
|
end
|
532
|
-
|
532
|
+
|
533
533
|
return false
|
534
534
|
end
|
535
|
-
|
535
|
+
|
536
536
|
def update_snapshot?
|
537
537
|
Buildr.application.options.update_snapshots
|
538
538
|
end
|
539
|
-
|
539
|
+
|
540
540
|
def offline?
|
541
541
|
Buildr.application.options.work_offline
|
542
542
|
end
|
543
|
-
|
543
|
+
|
544
544
|
# :call-seq:
|
545
545
|
# old?
|
546
546
|
#
|
547
|
-
# Checks whether existing artifact is older than period from build settings or one day
|
547
|
+
# Checks whether existing artifact is older than period from build settings or one day
|
548
548
|
def old?
|
549
549
|
settings = Buildr.application.settings
|
550
550
|
time_to_be_old = settings.user[:expire_time] || settings.build[:expire_time] || 60 * 60 * 24
|
@@ -706,7 +706,8 @@ module Buildr
|
|
706
706
|
# repositories.release_to[:password] = 'secret'
|
707
707
|
def release_to
|
708
708
|
unless @release_to
|
709
|
-
value = Buildr.settings.user['repositories'] && Buildr.settings.user['repositories']['release_to']
|
709
|
+
value = (Buildr.settings.user['repositories'] && Buildr.settings.user['repositories']['release_to']) \
|
710
|
+
|| (Buildr.settings.build['repositories'] && Buildr.settings.build['repositories']['release_to'])
|
710
711
|
@release_to = Hash === value ? value.inject({}) { |hash, (key, value)| hash.update(key.to_sym=>value) } : { :url=>Array(value).first }
|
711
712
|
end
|
712
713
|
@release_to
|
@@ -757,7 +758,7 @@ module Buildr
|
|
757
758
|
Rake::Task['rake:artifacts'].enhance [task]
|
758
759
|
Artifact.register(task)
|
759
760
|
unless spec[:type] == :pom
|
760
|
-
Rake::Task['artifacts:sources'].enhance [task.sources_artifact]
|
761
|
+
Rake::Task['artifacts:sources'].enhance [task.sources_artifact]
|
761
762
|
Rake::Task['artifacts:javadoc'].enhance [task.javadoc_artifact]
|
762
763
|
end
|
763
764
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -59,14 +59,16 @@ module Buildr
|
|
59
59
|
Zip::ZipOutputStream.open name do |zip|
|
60
60
|
seen = {}
|
61
61
|
mkpath = lambda do |dir|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
dirname = (dir[-1..-1] =~ /\/$/) ? dir : dir + '/'
|
63
|
+
unless dir == '.' || seen[dirname]
|
64
|
+
mkpath.call File.dirname(dirname)
|
65
|
+
zip.put_next_entry(dirname, compression_level)
|
66
|
+
seen[dirname] = true
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
70
|
file_map.each do |path, content|
|
71
|
+
warn "Warning: Path in zipfile #{name} contains backslash: #{path}" if path =~ /\\/
|
70
72
|
mkpath.call File.dirname(path)
|
71
73
|
if content.respond_to?(:call)
|
72
74
|
zip.put_next_entry(path, compression_level)
|
File without changes
|
data/lib/buildr/run.rb
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
module Buildr
|
18
|
+
module Run
|
19
|
+
include Extension
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def runners
|
23
|
+
@runners ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
def select_by_lang(lang)
|
27
|
+
fail 'Unable to define run task for nil language' if lang.nil?
|
28
|
+
runners.detect { |e| e.languages.nil? ? false : e.languages.include?(lang.to_sym) }
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method :select, :select_by_lang
|
32
|
+
|
33
|
+
def select_by_name(name)
|
34
|
+
fail 'Unable to define run task for nil' if name.nil?
|
35
|
+
runners.detect { |e| e.to_sym == name.to_sym }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# Base class for any run provider. Defines most
|
41
|
+
# common functionality (things like @lang@, @build?@ and friends).
|
42
|
+
class Base
|
43
|
+
attr_reader :project
|
44
|
+
|
45
|
+
class << self
|
46
|
+
attr_accessor :name, :languages
|
47
|
+
|
48
|
+
def specify(options)
|
49
|
+
@name ||= options[:name]
|
50
|
+
@languages ||= options[:languages]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_sym
|
54
|
+
@name ||= name.split('::').last.downcase.to_sym
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(project)
|
59
|
+
@project = project
|
60
|
+
end
|
61
|
+
|
62
|
+
def build?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def launch
|
67
|
+
fail 'Not implemented'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class RunTask < Rake::Task
|
72
|
+
# Classpath dependencies.
|
73
|
+
attr_accessor :classpath
|
74
|
+
|
75
|
+
# Returns the run options.
|
76
|
+
attr_reader :options
|
77
|
+
|
78
|
+
# Returns file dependencies
|
79
|
+
attr_reader :files
|
80
|
+
|
81
|
+
attr_reader :project # :nodoc:
|
82
|
+
|
83
|
+
def initialize(*args) # :nodoc:
|
84
|
+
super
|
85
|
+
@options = {}
|
86
|
+
@classpath = []
|
87
|
+
@files = FileList[]
|
88
|
+
end
|
89
|
+
|
90
|
+
# :call-seq:
|
91
|
+
# with(*artifacts) => self
|
92
|
+
#
|
93
|
+
# Adds files and artifacts as classpath dependencies, and returns self.
|
94
|
+
def with(*specs)
|
95
|
+
@classpath |= Buildr.artifacts(specs.flatten).uniq
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
# :call-seq:
|
100
|
+
# using(options) => self
|
101
|
+
#
|
102
|
+
# Sets the run options from a hash and returns self.
|
103
|
+
#
|
104
|
+
# For example:
|
105
|
+
# run.using :main=>'org.example.Main'
|
106
|
+
def using(*args)
|
107
|
+
args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last
|
108
|
+
|
109
|
+
until args.empty?
|
110
|
+
new_runner = Run.select_by_name(args.pop)
|
111
|
+
@runner = new_runner.new(project) unless new_runner.nil?
|
112
|
+
end
|
113
|
+
|
114
|
+
self
|
115
|
+
end
|
116
|
+
|
117
|
+
# :call-seq:
|
118
|
+
# requires(*files) => self
|
119
|
+
#
|
120
|
+
# Adds additional files and directories as dependencies to the task and returns self.
|
121
|
+
# When specifying a directory, includes all files in that directory.
|
122
|
+
def requires(*files)
|
123
|
+
@files.include *files.flatten.compact
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
def runner
|
128
|
+
@runner ||= guess_runner
|
129
|
+
end
|
130
|
+
|
131
|
+
# :call-seq:
|
132
|
+
# runner?(clazz) => boolean
|
133
|
+
#
|
134
|
+
# Check if the underlying runner is an instance of the given class.
|
135
|
+
# If no class is supplied, simply check if runner is defined.
|
136
|
+
def runner?(clazz = nil)
|
137
|
+
begin
|
138
|
+
@runner ||= guess_runner if project.compile.language
|
139
|
+
rescue
|
140
|
+
return false
|
141
|
+
end
|
142
|
+
return !@runner.nil? unless clazz
|
143
|
+
@runner.is_a?(clazz) if @runner
|
144
|
+
end
|
145
|
+
|
146
|
+
def run
|
147
|
+
runner.run(self) if runner?
|
148
|
+
end
|
149
|
+
|
150
|
+
def prerequisites #:nodoc:
|
151
|
+
super + @files + classpath
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
def guess_runner
|
157
|
+
runner = Run.select project.compile.language
|
158
|
+
fail 'Unable to guess runner for project.' unless runner
|
159
|
+
runner.new project
|
160
|
+
end
|
161
|
+
|
162
|
+
def associate_with(project)
|
163
|
+
@project ||= project
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
first_time do
|
168
|
+
Project.local_task 'run'
|
169
|
+
end
|
170
|
+
|
171
|
+
before_define(:run => :test) do |project|
|
172
|
+
RunTask.define_task('run').tap do |run|
|
173
|
+
run.send(:associate_with, project)
|
174
|
+
run.enhance([project.compile, project.test]) do |t|
|
175
|
+
# double-enhance to execute the runner last
|
176
|
+
run.enhance { |t| t.run }
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
after_define(:run => :test) do |project|
|
182
|
+
project.run.with project.test.compile.dependencies
|
183
|
+
project.run.with project.test.compile.target if project.test.compile.target
|
184
|
+
end
|
185
|
+
|
186
|
+
# :call-seq:
|
187
|
+
# run(&block) => RunTask
|
188
|
+
#
|
189
|
+
# This method returns the project's run task. It also accepts a block to be executed
|
190
|
+
# when the run task is invoked.
|
191
|
+
def run(&block)
|
192
|
+
task('run').tap do |t|
|
193
|
+
t.enhance &block if block
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
class Project
|
200
|
+
include Run
|
201
|
+
end
|
202
|
+
end
|