ittayd-buildr 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +62 -9
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +20 -39
- data/_buildr +1 -0
- data/{spec/java/ant.rb → _jbuildr} +11 -15
- metadata +30 -210
- data/DISCLAIMER +0 -7
- data/addon/buildr/antlr.rb +0 -65
- data/addon/buildr/cobertura.rb +0 -22
- data/addon/buildr/drb.rb +0 -281
- data/addon/buildr/emma.rb +0 -22
- data/addon/buildr/hibernate.rb +0 -142
- data/addon/buildr/javacc.rb +0 -85
- data/addon/buildr/jdepend.rb +0 -60
- data/addon/buildr/jetty.rb +0 -248
- data/addon/buildr/jibx.rb +0 -86
- data/addon/buildr/nailgun.rb +0 -221
- data/addon/buildr/openjpa.rb +0 -90
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -41
- 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/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -144
- data/addon/buildr/path.rb +0 -136
- data/addon/buildr/xmlbeans.rb +0 -93
- data/buildr.buildfile +0 -53
- data/buildr.gemspec +0 -58
- data/doc/css/default.css +0 -228
- data/doc/css/print.css +0 -100
- data/doc/css/syntax.css +0 -52
- 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/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.tif +0 -0
- data/doc/pages/artifacts.textile +0 -207
- data/doc/pages/building.textile +0 -240
- data/doc/pages/contributing.textile +0 -208
- data/doc/pages/download.textile +0 -62
- data/doc/pages/extending.textile +0 -175
- data/doc/pages/getting_started.textile +0 -273
- data/doc/pages/index.textile +0 -42
- data/doc/pages/languages.textile +0 -407
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/more_stuff.textile +0 -314
- data/doc/pages/packaging.textile +0 -427
- data/doc/pages/projects.textile +0 -274
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/settings_profiles.textile +0 -274
- data/doc/pages/testing.textile +0 -212
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/print.toc.yaml +0 -29
- data/doc/scripts/buildr-git.rb +0 -412
- data/doc/scripts/install-jruby.sh +0 -44
- data/doc/scripts/install-linux.sh +0 -64
- data/doc/scripts/install-osx.sh +0 -52
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/KEYS +0 -151
- data/etc/git-svn-authors +0 -16
- data/lib/buildr.rb +0 -33
- data/lib/buildr/core.rb +0 -29
- data/lib/buildr/core/application.rb +0 -665
- data/lib/buildr/core/build.rb +0 -311
- data/lib/buildr/core/checks.rb +0 -254
- data/lib/buildr/core/common.rb +0 -150
- data/lib/buildr/core/compile.rb +0 -590
- data/lib/buildr/core/environment.rb +0 -117
- data/lib/buildr/core/filter.rb +0 -366
- data/lib/buildr/core/generate.rb +0 -195
- data/lib/buildr/core/help.rb +0 -119
- data/lib/buildr/core/osx.rb +0 -49
- data/lib/buildr/core/progressbar.rb +0 -156
- data/lib/buildr/core/project.rb +0 -923
- data/lib/buildr/core/test.rb +0 -715
- data/lib/buildr/core/transports.rb +0 -560
- data/lib/buildr/core/util.rb +0 -294
- data/lib/buildr/groovy.rb +0 -18
- data/lib/buildr/groovy/bdd.rb +0 -106
- data/lib/buildr/groovy/compiler.rb +0 -138
- data/lib/buildr/ide.rb +0 -19
- data/lib/buildr/ide/eclipse.rb +0 -222
- data/lib/buildr/ide/idea.ipr.template +0 -300
- data/lib/buildr/ide/idea.rb +0 -190
- data/lib/buildr/ide/idea7x.ipr.template +0 -290
- data/lib/buildr/ide/idea7x.rb +0 -212
- data/lib/buildr/java.rb +0 -23
- data/lib/buildr/java/ant.rb +0 -92
- data/lib/buildr/java/bdd.rb +0 -451
- data/lib/buildr/java/cobertura.rb +0 -236
- data/lib/buildr/java/commands.rb +0 -211
- data/lib/buildr/java/compiler.rb +0 -348
- data/lib/buildr/java/deprecated.rb +0 -141
- data/lib/buildr/java/emma.rb +0 -238
- data/lib/buildr/java/jruby.rb +0 -117
- data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
- data/lib/buildr/java/packaging.rb +0 -717
- data/lib/buildr/java/pom.rb +0 -174
- data/lib/buildr/java/rjb.rb +0 -155
- data/lib/buildr/java/test_result.rb +0 -307
- data/lib/buildr/java/tests.rb +0 -329
- data/lib/buildr/java/version_requirement.rb +0 -172
- data/lib/buildr/packaging.rb +0 -24
- data/lib/buildr/packaging/archive.rb +0 -488
- data/lib/buildr/packaging/artifact.rb +0 -759
- data/lib/buildr/packaging/artifact_namespace.rb +0 -972
- data/lib/buildr/packaging/artifact_search.rb +0 -140
- data/lib/buildr/packaging/gems.rb +0 -102
- data/lib/buildr/packaging/package.rb +0 -233
- data/lib/buildr/packaging/tar.rb +0 -186
- data/lib/buildr/packaging/version_requirement.rb +0 -172
- data/lib/buildr/packaging/zip.rb +0 -64
- data/lib/buildr/packaging/ziptask.rb +0 -313
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +0 -19
- data/lib/buildr/scala/compiler.rb +0 -109
- data/lib/buildr/scala/tests.rb +0 -203
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/doc.rake +0 -103
- data/rakelib/package.rake +0 -76
- data/rakelib/release.rake +0 -65
- data/rakelib/rspec.rake +0 -83
- data/rakelib/rubyforge.rake +0 -56
- data/rakelib/scm.rake +0 -49
- data/rakelib/setup.rake +0 -81
- data/rakelib/stage.rake +0 -48
- data/spec/addon/drb_spec.rb +0 -328
- data/spec/core/application_spec.rb +0 -419
- data/spec/core/build_spec.rb +0 -423
- data/spec/core/checks_spec.rb +0 -519
- data/spec/core/common_spec.rb +0 -670
- data/spec/core/compile_spec.rb +0 -582
- data/spec/core/generate_spec.rb +0 -33
- data/spec/core/project_spec.rb +0 -776
- data/spec/core/test_spec.rb +0 -1098
- data/spec/core/transport_spec.rb +0 -500
- data/spec/groovy/bdd_spec.rb +0 -80
- data/spec/groovy/compiler_spec.rb +0 -239
- data/spec/ide/eclipse_spec.rb +0 -311
- data/spec/java/bdd_spec.rb +0 -358
- data/spec/java/cobertura_spec.rb +0 -77
- data/spec/java/compiler_spec.rb +0 -446
- data/spec/java/emma_spec.rb +0 -120
- data/spec/java/java_spec.rb +0 -96
- data/spec/java/packaging_spec.rb +0 -1120
- data/spec/java/test_coverage_spec.rb +0 -255
- data/spec/java/tests_spec.rb +0 -471
- data/spec/packaging/archive_spec.rb +0 -503
- data/spec/packaging/artifact_namespace_spec.rb +0 -646
- data/spec/packaging/artifact_spec.rb +0 -795
- data/spec/packaging/packaging_helper.rb +0 -63
- data/spec/packaging/packaging_spec.rb +0 -589
- data/spec/sandbox.rb +0 -139
- data/spec/scala/compiler_spec.rb +0 -228
- data/spec/scala/tests_spec.rb +0 -215
- data/spec/spec_helpers.rb +0 -327
- data/spec/version_requirement_spec.rb +0 -123
data/lib/buildr/core/common.rb
DELETED
@@ -1,150 +0,0 @@
|
|
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
|
-
require 'rake'
|
18
|
-
require 'buildr/core/util'
|
19
|
-
|
20
|
-
|
21
|
-
module Buildr
|
22
|
-
|
23
|
-
# :call-seq:
|
24
|
-
# struct(hash) => Struct
|
25
|
-
#
|
26
|
-
# Convenience method for creating an anonymous Struct.
|
27
|
-
#
|
28
|
-
# For example:
|
29
|
-
# COMMONS = struct(
|
30
|
-
# :collections =>'commons-collections:commons-collections:jar:3.1',
|
31
|
-
# :lang =>'commons-lang:commons-lang:jar:2.1',
|
32
|
-
# :logging =>'commons-logging:commons-logging:jar:1.0.3',
|
33
|
-
# )
|
34
|
-
#
|
35
|
-
# compile.with COMMONS.logging
|
36
|
-
def struct(hash)
|
37
|
-
Struct.new(nil, *hash.keys).new(*hash.values)
|
38
|
-
end
|
39
|
-
|
40
|
-
# :call-seq:
|
41
|
-
# write(name, content)
|
42
|
-
# write(name) { ... }
|
43
|
-
#
|
44
|
-
# Write the contents into a file. The second form calls the block and writes the result.
|
45
|
-
#
|
46
|
-
# For example:
|
47
|
-
# write 'TIMESTAMP', Time.now
|
48
|
-
# write('TIMESTAMP') { Time.now }
|
49
|
-
#
|
50
|
-
# Yields to the block before writing the file, so you can chain read and write together.
|
51
|
-
# For example:
|
52
|
-
# write('README') { read('README').sub("${build}", Time.now) }
|
53
|
-
def write(name, content = nil)
|
54
|
-
mkpath File.dirname(name), :verbose=>false
|
55
|
-
content = yield if block_given?
|
56
|
-
File.open(name.to_s, 'wb') { |file| file.write content.to_s }
|
57
|
-
content.to_s
|
58
|
-
end
|
59
|
-
|
60
|
-
# :call-seq:
|
61
|
-
# read(name) => string
|
62
|
-
# read(name) { |string| ... } => result
|
63
|
-
#
|
64
|
-
# Reads and returns the contents of a file. The second form yields to the block and returns
|
65
|
-
# the result of the block.
|
66
|
-
#
|
67
|
-
# For example:
|
68
|
-
# puts read('README')
|
69
|
-
# read('README') { |text| puts text }
|
70
|
-
def read(name)
|
71
|
-
contents = File.open(name.to_s) { |f| f.read }
|
72
|
-
if block_given?
|
73
|
-
yield contents
|
74
|
-
else
|
75
|
-
contents
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# :call-seq:
|
80
|
-
# download(url_or_uri) => task
|
81
|
-
# download(path=>url_or_uri) =>task
|
82
|
-
#
|
83
|
-
# Create a task that will download a file from a URL.
|
84
|
-
#
|
85
|
-
# Takes a single argument, a hash with one pair. The key is the file being
|
86
|
-
# created, the value if the URL to download. The task executes only if the
|
87
|
-
# file does not exist; the URL is not checked for updates.
|
88
|
-
#
|
89
|
-
# The task will show download progress on the console; if there are MD5/SHA1
|
90
|
-
# checksums on the server it will verify the download before saving it.
|
91
|
-
#
|
92
|
-
# For example:
|
93
|
-
# download 'image.jpg'=>'http://example.com/theme/image.jpg'
|
94
|
-
def download(args)
|
95
|
-
args = URI.parse(args) if String === args
|
96
|
-
if URI === args
|
97
|
-
# Given only a download URL, download into a temporary file.
|
98
|
-
# You can infer the file from task name.
|
99
|
-
temp = Tempfile.open(File.basename(args.to_s))
|
100
|
-
file(temp.path).tap do |task|
|
101
|
-
# Since temporary file exists, force a download.
|
102
|
-
class << task ; def needed? ; true ; end ; end
|
103
|
-
task.sources << args
|
104
|
-
task.enhance { args.download temp }
|
105
|
-
end
|
106
|
-
else
|
107
|
-
# Download to a file created by the task.
|
108
|
-
fail unless args.keys.size == 1
|
109
|
-
uri = URI.parse(args.values.first.to_s)
|
110
|
-
file(args.keys.first.to_s).tap do |task|
|
111
|
-
task.sources << uri
|
112
|
-
task.enhance { uri.download task.name }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
# A file task that concatenates all its prerequisites to create a new file.
|
119
|
-
#
|
120
|
-
# For example:
|
121
|
-
# concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
|
122
|
-
#
|
123
|
-
# See also Buildr#concat.
|
124
|
-
class ConcatTask < Rake::FileTask
|
125
|
-
def initialize(*args) #:nodoc:
|
126
|
-
super
|
127
|
-
enhance do |task|
|
128
|
-
content = prerequisites.inject("") do |content, prereq|
|
129
|
-
content << File.read(prereq.to_s) if File.exists?(prereq) && !File.directory?(prereq)
|
130
|
-
content
|
131
|
-
end
|
132
|
-
File.open(task.name, "wb") { |file| file.write content }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# :call-seq:
|
138
|
-
# concat(target=>files) => task
|
139
|
-
#
|
140
|
-
# Creates and returns a file task that concatenates all its prerequisites to create
|
141
|
-
# a new file. See #ConcatTask.
|
142
|
-
#
|
143
|
-
# For example:
|
144
|
-
# concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
|
145
|
-
def concat(args)
|
146
|
-
file, arg_names, deps = Buildr.application.resolve_args([args])
|
147
|
-
ConcatTask.define_task(File.expand_path(file)=>deps)
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
data/lib/buildr/core/compile.rb
DELETED
@@ -1,590 +0,0 @@
|
|
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
|
-
require 'buildr/core/common'
|
18
|
-
|
19
|
-
|
20
|
-
module Buildr
|
21
|
-
|
22
|
-
# The underlying compiler used by CompileTask.
|
23
|
-
# To add a new compiler, extend Compiler::Base and add your compiler using:
|
24
|
-
# Buildr::Compiler.add MyCompiler
|
25
|
-
module Compiler
|
26
|
-
|
27
|
-
class << self
|
28
|
-
|
29
|
-
# Returns true if the specified compiler exists.
|
30
|
-
def has?(name)
|
31
|
-
compilers.any? { |compiler| compiler.to_sym == name.to_sym }
|
32
|
-
end
|
33
|
-
|
34
|
-
# Select a compiler by its name.
|
35
|
-
def select(name)
|
36
|
-
compilers.detect { |compiler| compiler.to_sym == name.to_sym }
|
37
|
-
end
|
38
|
-
|
39
|
-
# Adds a compiler to the list of supported compiler.
|
40
|
-
#
|
41
|
-
# For example:
|
42
|
-
# Buildr::Compiler << Buildr::Javac
|
43
|
-
def add(compiler)
|
44
|
-
@compilers ||= []
|
45
|
-
@compilers |= [compiler]
|
46
|
-
end
|
47
|
-
alias :<< :add
|
48
|
-
|
49
|
-
# Returns a list of available compilers.
|
50
|
-
def compilers
|
51
|
-
@compilers ||= []
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
# Base class for all compilers, with common functionality. Extend and over-ride as you see fit
|
57
|
-
# (see Javac as an example).
|
58
|
-
class Base #:nodoc:
|
59
|
-
|
60
|
-
class << self
|
61
|
-
|
62
|
-
# The compiler's identifier (e.g. :javac). Inferred from the class name.
|
63
|
-
def to_sym
|
64
|
-
@symbol ||= name.split('::').last.downcase.to_sym
|
65
|
-
end
|
66
|
-
|
67
|
-
# The compiled language (e.g. :java).
|
68
|
-
attr_reader :language
|
69
|
-
# Source directories to use if none were specified (e.g. 'java'). Defaults to #language.
|
70
|
-
attr_reader :sources
|
71
|
-
# Extension for source files (e.g. 'java'). Defaults to language.
|
72
|
-
attr_reader :source_ext
|
73
|
-
# The target path (e.g. 'classes')
|
74
|
-
attr_reader :target
|
75
|
-
# Extension for target files (e.g. 'class').
|
76
|
-
attr_reader :target_ext
|
77
|
-
# The default packaging type (e.g. :jar).
|
78
|
-
attr_reader :packaging
|
79
|
-
|
80
|
-
# Returns true if this compiler applies to any source code found in the listed source
|
81
|
-
# directories. For example, Javac returns true if any of the source directories contains
|
82
|
-
# a .java file. The default implementation looks to see if there are any files in the
|
83
|
-
# specified path with the extension #source_ext.
|
84
|
-
def applies_to?(project, task)
|
85
|
-
paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
|
86
|
-
paths.flatten!
|
87
|
-
ext_glob = Array(source_ext).join(',')
|
88
|
-
paths.any? { |path| !Dir["#{path}/**/*.{#{ext_glob}}"].empty? }
|
89
|
-
end
|
90
|
-
|
91
|
-
# Implementations can use this method to specify various compiler attributes.
|
92
|
-
# For example:
|
93
|
-
# specify :language=>:java, :target=>'classes', :target_ext=>'class', :packaging=>:jar
|
94
|
-
def specify(attrs)
|
95
|
-
attrs[:sources] ||= attrs[:language].to_s
|
96
|
-
attrs[:source_ext] ||= attrs[:language].to_s
|
97
|
-
attrs.each { |name, value| instance_variable_set("@#{name}", value) }
|
98
|
-
end
|
99
|
-
|
100
|
-
# Returns additional dependencies required by this language. For example, since the
|
101
|
-
# test framework picks on these, you can use the JUnit framework with Scala.
|
102
|
-
# Defaults to obtaining a list of artifact specifications from the REQUIRES constant.
|
103
|
-
def dependencies
|
104
|
-
[]
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
# Construct a new compiler with the specified options. Note that options may
|
110
|
-
# change before the compiler is run.
|
111
|
-
def initialize(project, options)
|
112
|
-
@project = project
|
113
|
-
@options = options
|
114
|
-
end
|
115
|
-
|
116
|
-
# Options for this compiler.
|
117
|
-
attr_reader :options
|
118
|
-
|
119
|
-
# Determines if the compiler needs to run by checking if the target files exist,
|
120
|
-
# and if any source files or dependencies are newer than corresponding target files.
|
121
|
-
def needed?(sources, target, dependencies)
|
122
|
-
map = compile_map(sources, target)
|
123
|
-
return false if map.empty?
|
124
|
-
return true unless File.exist?(target.to_s)
|
125
|
-
source_files_not_yet_compiled = map.select { |source, target| !File.exist?(target) }
|
126
|
-
trace "Compile needed because source file #{source_files_not_yet_compiled[0][0]} has no corresponding #{source_files_not_yet_compiled[0][1]}" unless source_files_not_yet_compiled.empty?
|
127
|
-
return true if map.any? { |source, target| !File.exist?(target) || File.stat(source).mtime > File.stat(target).mtime }
|
128
|
-
oldest = map.map { |source, target| File.stat(target).mtime }.min
|
129
|
-
return dependencies.any? { |path| file(path).timestamp > oldest }
|
130
|
-
end
|
131
|
-
|
132
|
-
# Compile all files lists in sources (files and directories) into target using the
|
133
|
-
# specified dependencies.
|
134
|
-
def compile(sources, target, dependencies)
|
135
|
-
raise 'Not implemented'
|
136
|
-
end
|
137
|
-
|
138
|
-
# Returns additional dependencies required by this language. For example, since the
|
139
|
-
# test framework picks on these, you can use the JUnit framework with Scala.
|
140
|
-
def dependencies
|
141
|
-
self.class.dependencies
|
142
|
-
end
|
143
|
-
|
144
|
-
protected
|
145
|
-
|
146
|
-
# Use this to complain about CompileTask options not supported by this compiler.
|
147
|
-
#
|
148
|
-
# For example:
|
149
|
-
# def compile(files, task)
|
150
|
-
# check_options task, OPTIONS
|
151
|
-
# . . .
|
152
|
-
# end
|
153
|
-
def check_options(options, *supported)
|
154
|
-
unsupported = options.to_hash.keys - supported.flatten
|
155
|
-
raise ArgumentError, "No such option: #{unsupported.join(' ')}" unless unsupported.empty?
|
156
|
-
end
|
157
|
-
|
158
|
-
# Expands a list of source directories/files into a list of files that have the #source_ext extension.
|
159
|
-
def files_from_sources(sources)
|
160
|
-
ext_glob = Array(self.class.source_ext).join(',')
|
161
|
-
sources.flatten.map { |source| File.directory?(source) ? FileList["#{source}/**/*.{#{ext_glob}}"] : source }.
|
162
|
-
flatten.reject { |file| File.directory?(file) }.map { |file| File.expand_path(file) }.uniq
|
163
|
-
end
|
164
|
-
|
165
|
-
# The compile map is a hash that associates source files with target files based
|
166
|
-
# on a list of source directories and target directory. The compile task uses this
|
167
|
-
# to determine if there are source files to compile, and which source files to compile.
|
168
|
-
# The default method maps all files in the source directories with #source_ext into
|
169
|
-
# paths in the target directory with #target_ext (e.g. 'source/foo.java'=>'target/foo.class').
|
170
|
-
def compile_map(sources, target)
|
171
|
-
target_ext = self.class.target_ext
|
172
|
-
ext_glob = Array(self.class.source_ext).join(',')
|
173
|
-
sources.flatten.map{|f| File.expand_path(f)}.inject({}) do |map, source|
|
174
|
-
if File.directory?(source)
|
175
|
-
FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file) }.
|
176
|
-
each { |file| map[file] = File.join(target, Util.relative_path(file, source).ext(target_ext)) }
|
177
|
-
else
|
178
|
-
map[source] = target # File.join(target, File.basename(source).ext(target_ext))
|
179
|
-
end
|
180
|
-
map
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
# Compile task.
|
190
|
-
#
|
191
|
-
# Attempts to determine which compiler to use based on the project layout, for example,
|
192
|
-
# uses the Javac compiler if it finds any .java files in src/main/java. You can also
|
193
|
-
# select the compiler explicitly:
|
194
|
-
# compile.using(:scalac)
|
195
|
-
#
|
196
|
-
# Accepts multiple source directories that are invoked as prerequisites before compilation.
|
197
|
-
# You can pass a task as a source directory:
|
198
|
-
# compile.from(apt)
|
199
|
-
#
|
200
|
-
# Likewise, dependencies are invoked before compiling. All dependencies are evaluated as
|
201
|
-
# #artifacts, so you can pass artifact specifications and even projects:
|
202
|
-
# compile.with('module1.jar', 'log4j:log4j:jar:1.0', project('foo'))
|
203
|
-
#
|
204
|
-
# Creates a file task for the target directory, so executing that task as a dependency will
|
205
|
-
# execute the compile task first.
|
206
|
-
#
|
207
|
-
# Compiler options are inherited form a parent task, e.g. the foo:bar:compile task inherits
|
208
|
-
# its options from the foo:compile task. Even if foo is an empty project that does not compile
|
209
|
-
# any classes itself, you can use it to set compile options for all its sub-projects.
|
210
|
-
#
|
211
|
-
# Normally, the project will take care of setting the source and target directory, and you
|
212
|
-
# only need to set options and dependencies. See Project#compile.
|
213
|
-
class CompileTask < Rake::Task
|
214
|
-
|
215
|
-
def initialize(*args) #:nodoc:
|
216
|
-
super
|
217
|
-
parent_task = Project.parent_task(name)
|
218
|
-
inherit = lambda { |hash, key| parent_task.options[key] } if parent_task.respond_to?(:options)
|
219
|
-
@options = OpenObject.new &inherit
|
220
|
-
@sources = FileList[]
|
221
|
-
@dependencies = FileList[]
|
222
|
-
|
223
|
-
enhance do |task|
|
224
|
-
unless sources.empty?
|
225
|
-
raise 'No compiler selected and can\'t determine which compiler to use' unless compiler
|
226
|
-
raise 'No target directory specified' unless target
|
227
|
-
mkpath target.to_s, :verbose=>false
|
228
|
-
info "Compiling #{task.name.gsub(/:[^:]*$/, '')} into #{target.to_s}"
|
229
|
-
@compiler.compile(sources.map(&:to_s), target.to_s, dependencies.map(&:to_s))
|
230
|
-
# By touching the target we let other tasks know we did something,
|
231
|
-
# and also prevent recompiling again for dependencies.
|
232
|
-
touch target.to_s, :verbose=>false
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
# Source directories.
|
238
|
-
attr_accessor :sources
|
239
|
-
|
240
|
-
# :call-seq:
|
241
|
-
# from(*sources) => self
|
242
|
-
#
|
243
|
-
# Adds source directories and files to compile, and returns self.
|
244
|
-
#
|
245
|
-
# For example:
|
246
|
-
# compile.from('src/java').into('classes').with('module1.jar')
|
247
|
-
def from(*sources)
|
248
|
-
@sources |= sources.flatten
|
249
|
-
guess_compiler if @compiler.nil? && sources.flatten.any? { |source| File.exist?(source) }
|
250
|
-
self
|
251
|
-
end
|
252
|
-
|
253
|
-
# *Deprecated*: Use dependencies instead.
|
254
|
-
def classpath
|
255
|
-
Buildr.application.deprecated 'Use dependencies instead.'
|
256
|
-
dependencies
|
257
|
-
end
|
258
|
-
|
259
|
-
# *Deprecated*: Use dependencies= instead.
|
260
|
-
def classpath=(artifacts)
|
261
|
-
Buildr.application.deprecated 'Use dependencies= instead.'
|
262
|
-
self.dependencies = artifacts
|
263
|
-
end
|
264
|
-
|
265
|
-
# Compilation dependencies.
|
266
|
-
attr_accessor :dependencies
|
267
|
-
|
268
|
-
# :call-seq:
|
269
|
-
# with(*artifacts) => self
|
270
|
-
#
|
271
|
-
# Adds files and artifacts as dependencies, and returns self.
|
272
|
-
#
|
273
|
-
# Calls #artifacts on the arguments, so you can pass artifact specifications,
|
274
|
-
# tasks, projects, etc. Use this rather than setting the dependencies array directly.
|
275
|
-
#
|
276
|
-
# For example:
|
277
|
-
# compile.with('module1.jar', 'log4j:log4j:jar:1.0', project('foo'))
|
278
|
-
def with(*specs)
|
279
|
-
@dependencies |= Buildr.artifacts(specs.flatten).uniq
|
280
|
-
self
|
281
|
-
end
|
282
|
-
|
283
|
-
# The target directory for the compiled code.
|
284
|
-
attr_reader :target
|
285
|
-
|
286
|
-
# :call-seq:
|
287
|
-
# into(path) => self
|
288
|
-
#
|
289
|
-
# Sets the target directory and returns self. This will also set the compile task
|
290
|
-
# as a prerequisite to a file task on the target directory.
|
291
|
-
#
|
292
|
-
# For example:
|
293
|
-
# compile(src_dir).into(target_dir).with(artifacts)
|
294
|
-
# Both compile.invoke and file(target_dir).invoke will compile the source files.
|
295
|
-
def into(path)
|
296
|
-
@target = file(path.to_s).enhance([self]) unless @target.to_s == path.to_s
|
297
|
-
self
|
298
|
-
end
|
299
|
-
|
300
|
-
# Returns the compiler options.
|
301
|
-
attr_reader :options
|
302
|
-
|
303
|
-
# :call-seq:
|
304
|
-
# using(options) => self
|
305
|
-
#
|
306
|
-
# Sets the compiler options from a hash and returns self. Can also be used to
|
307
|
-
# select the compiler.
|
308
|
-
#
|
309
|
-
# For example:
|
310
|
-
# compile.using(:warnings=>true, :source=>'1.5')
|
311
|
-
# compile.using(:scala)
|
312
|
-
def using(*args)
|
313
|
-
args.pop.each { |key, value| options.send "#{key}=", value } if Hash === args.last
|
314
|
-
self.compiler = args.pop until args.empty?
|
315
|
-
self
|
316
|
-
end
|
317
|
-
|
318
|
-
# Returns the compiler if known. The compiler is either automatically selected
|
319
|
-
# based on existing source directories (e.g. src/main/java), or by requesting
|
320
|
-
# a specific compiler (see #using).
|
321
|
-
def compiler
|
322
|
-
guess_compiler unless @compiler
|
323
|
-
@compiler && @compiler.class.to_sym
|
324
|
-
end
|
325
|
-
|
326
|
-
# Returns the compiled language, if known. See also #compiler.
|
327
|
-
def language
|
328
|
-
compiler && @compiler.class.language
|
329
|
-
end
|
330
|
-
|
331
|
-
# Returns the default packaging type for this compiler, if known.
|
332
|
-
def packaging
|
333
|
-
compiler && @compiler.class.packaging
|
334
|
-
end
|
335
|
-
|
336
|
-
def timestamp #:nodoc:
|
337
|
-
# If we compiled successfully, then the target directory reflects that.
|
338
|
-
# If we didn't, see needed?
|
339
|
-
target ? target.timestamp : Rake::EARLY
|
340
|
-
end
|
341
|
-
|
342
|
-
# The project this task belongs to.
|
343
|
-
attr_reader :project
|
344
|
-
|
345
|
-
# The usage, one of :main or :test.
|
346
|
-
attr_reader :usage
|
347
|
-
|
348
|
-
protected
|
349
|
-
|
350
|
-
# Selects which compiler to use.
|
351
|
-
def compiler=(name) #:nodoc:
|
352
|
-
cls = Compiler.select(name) or raise ArgumentError, "No #{name} compiler available. Did you install it?"
|
353
|
-
return self if cls === @compiler
|
354
|
-
raise "#{compiler} compiler already selected for this project" if @compiler
|
355
|
-
@compiler = cls.new(project, options)
|
356
|
-
from Array(cls.sources).map { |path| project.path_to(:source, usage, path) }.
|
357
|
-
select { |path| File.exist?(path) } if sources.empty?
|
358
|
-
into project.path_to(:target, usage, cls.target) unless target
|
359
|
-
with Array(@compiler.dependencies)
|
360
|
-
self
|
361
|
-
end
|
362
|
-
|
363
|
-
# Associates this task with project and particular usage (:main, :test).
|
364
|
-
def associate_with(project, usage) #:nodoc:
|
365
|
-
@project, @usage = project, usage
|
366
|
-
guess_compiler
|
367
|
-
end
|
368
|
-
|
369
|
-
# Try to guess if we have a compiler to match source files.
|
370
|
-
def guess_compiler #:nodoc:
|
371
|
-
candidate = Compiler.compilers.detect { |cls| cls.applies_to?(project, self) }
|
372
|
-
self.compiler = candidate if candidate
|
373
|
-
end
|
374
|
-
|
375
|
-
private
|
376
|
-
|
377
|
-
def needed? #:nodoc:
|
378
|
-
return false if sources.empty?
|
379
|
-
# Fail during invoke.
|
380
|
-
return true unless @compiler && target
|
381
|
-
return @compiler.needed?(sources.map(&:to_s), target.to_s, dependencies.map(&:to_s))
|
382
|
-
end
|
383
|
-
|
384
|
-
def invoke_prerequisites(args, chain) #:nodoc:
|
385
|
-
@sources = Array(@sources).map(&:to_s).uniq
|
386
|
-
@dependencies = FileList[@dependencies.uniq]
|
387
|
-
@prerequisites |= @dependencies + @sources
|
388
|
-
super
|
389
|
-
end
|
390
|
-
|
391
|
-
end
|
392
|
-
|
393
|
-
|
394
|
-
# The resources task is executed by the compile task to copy resource files over
|
395
|
-
# to the target directory. You can enhance this task in the normal way, but mostly
|
396
|
-
# you will use the task's filter.
|
397
|
-
#
|
398
|
-
# For example:
|
399
|
-
# resources.filter.using 'Copyright'=>'Acme Inc, 2007'
|
400
|
-
class ResourcesTask < Rake::Task
|
401
|
-
|
402
|
-
# Returns the filter used to copy resources over. See Buildr::Filter.
|
403
|
-
attr_reader :filter
|
404
|
-
|
405
|
-
def initialize(*args) #:nodoc:
|
406
|
-
super
|
407
|
-
@filter = Buildr::Filter.new
|
408
|
-
@filter.using Buildr.settings.profile['filter'] if Hash === Buildr.settings.profile['filter']
|
409
|
-
enhance do
|
410
|
-
target.invoke if target
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
# :call-seq:
|
415
|
-
# include(*files) => self
|
416
|
-
#
|
417
|
-
# Includes the specified files in the filter and returns self.
|
418
|
-
def include(*files)
|
419
|
-
filter.include *files
|
420
|
-
self
|
421
|
-
end
|
422
|
-
|
423
|
-
# :call-seq:
|
424
|
-
# exclude(*files) => self
|
425
|
-
#
|
426
|
-
# Excludes the specified files in the filter and returns self.
|
427
|
-
def exclude(*files)
|
428
|
-
filter.exclude *files
|
429
|
-
self
|
430
|
-
end
|
431
|
-
|
432
|
-
# :call-seq:
|
433
|
-
# from(*sources) => self
|
434
|
-
#
|
435
|
-
# Adds additional directories from which to copy resources.
|
436
|
-
#
|
437
|
-
# For example:
|
438
|
-
# resources.from _('src/etc')
|
439
|
-
def from(*sources)
|
440
|
-
filter.from *sources
|
441
|
-
self
|
442
|
-
end
|
443
|
-
|
444
|
-
# Returns the list of source directories (each being a file task).
|
445
|
-
def sources
|
446
|
-
filter.sources
|
447
|
-
end
|
448
|
-
|
449
|
-
# :call-seq:
|
450
|
-
# target => task
|
451
|
-
#
|
452
|
-
# Returns the filter's target directory as a file task.
|
453
|
-
def target
|
454
|
-
filter.into @project.path_to(:target, @usage, :resources) unless filter.target || sources.empty?
|
455
|
-
filter.target
|
456
|
-
end
|
457
|
-
|
458
|
-
def prerequisites #:nodoc:
|
459
|
-
super + filter.sources.flatten
|
460
|
-
end
|
461
|
-
|
462
|
-
protected
|
463
|
-
|
464
|
-
# Associates this task with project and particular usage (:main, :test).
|
465
|
-
def associate_with(project, usage) #:nodoc:
|
466
|
-
@project, @usage = project, usage
|
467
|
-
end
|
468
|
-
|
469
|
-
end
|
470
|
-
|
471
|
-
|
472
|
-
# Methods added to Project for compiling, handling of resources and generating source documentation.
|
473
|
-
module Compile
|
474
|
-
|
475
|
-
include Extension
|
476
|
-
|
477
|
-
first_time do
|
478
|
-
desc 'Compile all projects'
|
479
|
-
Project.local_task('compile') { |name| "Compiling #{name}" }
|
480
|
-
end
|
481
|
-
|
482
|
-
before_define do |project|
|
483
|
-
resources = ResourcesTask.define_task('resources')
|
484
|
-
resources.send :associate_with, project, :main
|
485
|
-
project.path_to(:source, :main, :resources).tap { |dir| resources.from dir if File.exist?(dir) }
|
486
|
-
|
487
|
-
compile = CompileTask.define_task('compile'=>resources)
|
488
|
-
compile.send :associate_with, project, :main
|
489
|
-
project.recursive_task('compile')
|
490
|
-
end
|
491
|
-
|
492
|
-
after_define do |project|
|
493
|
-
if project.compile.target
|
494
|
-
# This comes last because the target path is set inside the project definition.
|
495
|
-
project.build project.compile.target
|
496
|
-
project.clean do
|
497
|
-
rm_rf project.compile.target.to_s, :verbose=>false
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
|
503
|
-
# :call-seq:
|
504
|
-
# compile(*sources) => CompileTask
|
505
|
-
# compile(*sources) { |task| .. } => CompileTask
|
506
|
-
#
|
507
|
-
# The compile task does what its name suggests. This method returns the project's
|
508
|
-
# CompileTask. It also accepts a list of source directories and files to compile
|
509
|
-
# (equivalent to calling CompileTask#from on the task), and a block for any
|
510
|
-
# post-compilation work.
|
511
|
-
#
|
512
|
-
# The compile task attempts to guess which compiler to use. For example, if it finds
|
513
|
-
# any Java files in the src/main/java directory, it will use the Java compiler and
|
514
|
-
# create class files in the target/classes directory.
|
515
|
-
#
|
516
|
-
# You can also configure it yourself by telling it which compiler to use, pointing
|
517
|
-
# it as source directories and chooing a different target directory.
|
518
|
-
#
|
519
|
-
# For example:
|
520
|
-
# # Include Log4J and the api sub-project artifacts.
|
521
|
-
# compile.with 'log4j:log4j:jar:1.2', project('api')
|
522
|
-
# # Include Apt-generated source files.
|
523
|
-
# compile.from apt
|
524
|
-
# # For JavaC, force target compatibility.
|
525
|
-
# compile.options.source = '1.6'
|
526
|
-
# # Run the OpenJPA bytecode enhancer after compilation.
|
527
|
-
# compile { open_jpa_enhance }
|
528
|
-
# # Pick a given compiler.
|
529
|
-
# compile.using(:scalac).from('src/scala')
|
530
|
-
#
|
531
|
-
# For more information, see CompileTask.
|
532
|
-
def compile(*sources, &block)
|
533
|
-
task('compile').from(sources).enhance &block
|
534
|
-
end
|
535
|
-
|
536
|
-
# :call-seq:
|
537
|
-
# resources(*prereqs) => ResourcesTask
|
538
|
-
# resources(*prereqs) { |task| .. } => ResourcesTask
|
539
|
-
#
|
540
|
-
# The resources task is executed by the compile task to copy resources files
|
541
|
-
# from the resource directory into the target directory. By default the resources
|
542
|
-
# task copies files from the src/main/resources into the target/resources directory.
|
543
|
-
#
|
544
|
-
# This method returns the project's resources task. It also accepts a list of
|
545
|
-
# prerequisites and a block, used to enhance the resources task.
|
546
|
-
#
|
547
|
-
# Resources files are copied and filtered (see Buildr::Filter for more information).
|
548
|
-
# The default filter uses the profile properties for the current environment.
|
549
|
-
#
|
550
|
-
# For example:
|
551
|
-
# resources.from _('src/etc')
|
552
|
-
# resources.filter.using 'Copyright'=>'Acme Inc, 2007'
|
553
|
-
#
|
554
|
-
# Or in your profiles.yaml file:
|
555
|
-
# common:
|
556
|
-
# Copyright: Acme Inc, 2007
|
557
|
-
def resources(*prereqs, &block)
|
558
|
-
task('resources').enhance prereqs, &block
|
559
|
-
end
|
560
|
-
|
561
|
-
end
|
562
|
-
|
563
|
-
|
564
|
-
class Options
|
565
|
-
|
566
|
-
# Returns the debug option (environment variable DEBUG).
|
567
|
-
def debug
|
568
|
-
(ENV['DEBUG'] || ENV['debug']) !~ /(no|off|false)/
|
569
|
-
end
|
570
|
-
|
571
|
-
# Sets the debug option (environment variable DEBUG).
|
572
|
-
#
|
573
|
-
# You can turn this option off directly, or by setting the environment variable
|
574
|
-
# DEBUG to +no+. For example:
|
575
|
-
# buildr build DEBUG=no
|
576
|
-
#
|
577
|
-
# The release tasks runs a build with <tt>DEBUG=no</tt>.
|
578
|
-
def debug=(flag)
|
579
|
-
ENV['debug'] = nil
|
580
|
-
ENV['DEBUG'] = flag.to_s
|
581
|
-
end
|
582
|
-
|
583
|
-
end
|
584
|
-
|
585
|
-
end
|
586
|
-
|
587
|
-
|
588
|
-
class Buildr::Project
|
589
|
-
include Buildr::Compile
|
590
|
-
end
|