buildr 1.3.5-x86-mswin32 → 1.4.0-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 +153 -8
- data/README.rdoc +1 -1
- data/addon/buildr/antlr.rb +5 -5
- data/addon/buildr/drb.rb +18 -18
- data/addon/buildr/hibernate.rb +18 -14
- data/addon/buildr/javacc.rb +4 -4
- data/addon/buildr/jetty.rb +5 -5
- data/addon/buildr/nailgun.rb +23 -23
- data/addon/buildr/openjpa.rb +1 -1
- 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/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/protobuf.rb +75 -0
- data/addon/buildr/xmlbeans.rb +5 -5
- data/buildr.buildfile +2 -2
- data/buildr.gemspec +8 -7
- data/doc/_layouts/default.html +2 -2
- data/doc/artifacts.textile +4 -4
- data/doc/building.textile +35 -3
- data/doc/contributing.textile +5 -0
- data/doc/download.textile +16 -5
- data/doc/extending.textile +38 -12
- data/doc/installing.textile +6 -5
- data/doc/languages.textile +182 -42
- data/doc/more_stuff.textile +2 -2
- data/doc/packaging.textile +14 -15
- data/doc/projects.textile +7 -2
- data/doc/quick_start.textile +4 -4
- data/doc/scripts/buildr-git.rb +63 -63
- data/doc/scripts/gitflow.rb +21 -21
- data/doc/settings_profiles.textile +9 -2
- data/doc/testing.textile +16 -5
- data/etc/KEYS +38 -0
- data/lib/buildr.rb +1 -1
- data/lib/buildr/core.rb +1 -0
- data/lib/buildr/core/application.rb +33 -27
- data/lib/buildr/core/build.rb +41 -28
- data/lib/buildr/core/cc.rb +172 -0
- data/lib/buildr/core/checks.rb +1 -1
- data/lib/buildr/core/common.rb +7 -6
- data/lib/buildr/core/compile.rb +7 -8
- data/lib/buildr/core/doc.rb +263 -0
- data/lib/buildr/core/environment.rb +6 -6
- data/lib/buildr/core/filter.rb +77 -35
- data/lib/buildr/core/generate.rb +7 -7
- data/lib/buildr/core/help.rb +1 -1
- data/lib/buildr/core/osx.rb +6 -6
- data/lib/buildr/core/progressbar.rb +4 -4
- data/lib/buildr/core/project.rb +144 -36
- data/lib/buildr/core/shell.rb +34 -34
- data/lib/buildr/core/test.rb +89 -20
- data/lib/buildr/core/transports.rb +8 -7
- data/lib/buildr/core/util.rb +77 -23
- data/lib/buildr/groovy/bdd.rb +5 -5
- data/lib/buildr/groovy/compiler.rb +19 -15
- data/lib/buildr/groovy/shell.rb +6 -6
- data/lib/buildr/ide/eclipse.rb +148 -75
- data/lib/buildr/ide/eclipse/java.rb +3 -3
- data/lib/buildr/ide/eclipse/plugin.rb +8 -5
- data/lib/buildr/ide/eclipse/scala.rb +4 -2
- data/lib/buildr/ide/idea.rb +2 -2
- data/lib/buildr/ide/idea7x.rb +23 -4
- data/lib/buildr/java.rb +1 -0
- data/lib/buildr/java/ant.rb +4 -4
- data/lib/buildr/java/bdd.rb +51 -54
- data/lib/buildr/java/cobertura.rb +57 -35
- data/lib/buildr/java/commands.rb +14 -5
- data/lib/buildr/java/compiler.rb +3 -217
- data/lib/buildr/java/deprecated.rb +4 -4
- data/lib/buildr/java/doc.rb +70 -0
- data/lib/buildr/java/emma.rb +22 -22
- data/lib/buildr/java/jruby.rb +4 -4
- data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
- data/lib/buildr/java/packaging.rb +30 -29
- data/lib/buildr/java/pom.rb +4 -4
- data/lib/buildr/java/rjb.rb +6 -6
- data/lib/buildr/java/test_result.rb +61 -85
- data/lib/buildr/java/tests.rb +44 -27
- data/lib/buildr/java/version_requirement.rb +8 -8
- data/lib/buildr/packaging/archive.rb +55 -22
- data/lib/buildr/packaging/artifact.rb +75 -36
- data/lib/buildr/packaging/artifact_namespace.rb +90 -78
- data/lib/buildr/packaging/artifact_search.rb +5 -5
- data/lib/buildr/packaging/gems.rb +11 -7
- data/lib/buildr/packaging/package.rb +10 -7
- data/lib/buildr/packaging/tar.rb +14 -14
- data/lib/buildr/packaging/version_requirement.rb +30 -10
- data/lib/buildr/packaging/ziptask.rb +51 -13
- data/lib/buildr/scala.rb +1 -0
- data/lib/buildr/scala/bdd.rb +25 -20
- data/lib/buildr/scala/compiler.rb +87 -40
- data/lib/buildr/scala/doc.rb +106 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +14 -9
- data/lib/buildr/scala/tests.rb +33 -26
- data/lib/buildr/shell.rb +33 -33
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +1 -1
- data/rakelib/doc.rake +7 -0
- data/rakelib/package.rake +1 -1
- data/rakelib/release.rake +9 -6
- data/rakelib/rspec.rake +26 -7
- data/rakelib/setup.rake +15 -3
- data/rakelib/stage.rake +18 -11
- data/spec/addon/drb_spec.rb +25 -25
- data/spec/core/application_spec.rb +111 -21
- data/spec/core/build_spec.rb +16 -15
- data/spec/core/cc_spec.rb +174 -0
- data/spec/core/checks_spec.rb +34 -34
- data/spec/core/common_spec.rb +51 -5
- data/spec/core/compile_spec.rb +89 -14
- data/spec/core/extension_spec.rb +127 -19
- data/spec/core/generate_spec.rb +2 -2
- data/spec/core/project_spec.rb +10 -10
- data/spec/core/test_spec.rb +144 -35
- data/spec/core/transport_spec.rb +8 -8
- data/spec/core/util_spec.rb +63 -5
- data/spec/groovy/bdd_spec.rb +5 -5
- data/spec/groovy/compiler_spec.rb +29 -18
- data/spec/ide/eclipse_spec.rb +185 -9
- data/spec/ide/idea7x_spec.rb +22 -10
- data/spec/java/ant_spec.rb +9 -5
- data/spec/java/bdd_spec.rb +29 -37
- data/spec/java/cobertura_spec.rb +12 -12
- data/spec/java/commands_spec.rb +34 -0
- data/spec/java/compiler_spec.rb +53 -53
- data/spec/java/emma_spec.rb +11 -11
- data/spec/java/java_spec.rb +10 -10
- data/spec/java/packaging_spec.rb +67 -20
- data/spec/java/test_coverage_helper.rb +18 -18
- data/spec/java/tests_spec.rb +13 -9
- data/spec/packaging/archive_spec.rb +187 -20
- data/spec/packaging/artifact_namespace_spec.rb +172 -83
- data/spec/packaging/artifact_spec.rb +83 -18
- data/spec/packaging/packaging_spec.rb +41 -14
- data/spec/sandbox.rb +23 -12
- data/spec/scala/bdd_spec.rb +13 -8
- data/spec/scala/compiler_spec.rb +18 -13
- data/spec/scala/scala.rb +3 -3
- data/spec/scala/tests_spec.rb +46 -24
- data/spec/spec_helpers.rb +28 -10
- data/spec/version_requirement_spec.rb +25 -11
- metadata +149 -133
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
- data/rakelib/stage.rake~ +0 -213
@@ -0,0 +1,263 @@
|
|
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
|
+
module Buildr
|
17
|
+
module Doc
|
18
|
+
include Extension
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def select_by_lang(lang)
|
22
|
+
fail 'Unable to define doc task for nil language' if lang.nil?
|
23
|
+
engines.detect { |e| e.language.to_sym == lang.to_sym }
|
24
|
+
end
|
25
|
+
|
26
|
+
alias_method :select, :select_by_lang
|
27
|
+
|
28
|
+
def select_by_name(name)
|
29
|
+
fail 'Unable to define doc task for nil' if name.nil?
|
30
|
+
engines.detect { |e| e.to_sym == name.to_sym }
|
31
|
+
end
|
32
|
+
|
33
|
+
def engines
|
34
|
+
@engines ||= []
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# Base class for any documentation provider. Defines most
|
40
|
+
# common functionality (things like @into@, @from@ and friends).
|
41
|
+
class Base
|
42
|
+
class << self
|
43
|
+
attr_accessor :language, :source_ext
|
44
|
+
|
45
|
+
def specify(options)
|
46
|
+
@language = options[:language]
|
47
|
+
@source_ext = options[:source_ext]
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_sym
|
51
|
+
@symbol ||= name.split('::').last.downcase.to_sym
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
attr_reader :project
|
56
|
+
|
57
|
+
def initialize(project)
|
58
|
+
@project = project
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
class DocTask < Rake::Task
|
64
|
+
|
65
|
+
# The target directory for the generated documentation files.
|
66
|
+
attr_reader :target
|
67
|
+
|
68
|
+
# Classpath dependencies.
|
69
|
+
attr_accessor :classpath
|
70
|
+
|
71
|
+
# Additional sourcepaths that are not part of the documented files.
|
72
|
+
attr_accessor :sourcepath
|
73
|
+
|
74
|
+
# Returns the documentation tool options.
|
75
|
+
attr_reader :options
|
76
|
+
|
77
|
+
|
78
|
+
attr_reader :project # :nodoc:
|
79
|
+
|
80
|
+
def initialize(*args) #:nodoc:
|
81
|
+
super
|
82
|
+
@options = {}
|
83
|
+
@classpath = []
|
84
|
+
@sourcepath = []
|
85
|
+
@files = FileList[]
|
86
|
+
enhance do |task|
|
87
|
+
rm_rf target.to_s
|
88
|
+
mkdir_p target.to_s
|
89
|
+
|
90
|
+
engine.generate(source_files, File.expand_path(target.to_s),
|
91
|
+
options.merge(:classpath => classpath, :sourcepath => sourcepath))
|
92
|
+
|
93
|
+
touch target.to_s
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# :call-seq:
|
98
|
+
# into(path) => self
|
99
|
+
#
|
100
|
+
# Sets the target directory and returns self. This will also set the Javadoc task
|
101
|
+
# as a prerequisite to a file task on the target directory.
|
102
|
+
#
|
103
|
+
# For example:
|
104
|
+
# package :zip, :classifier=>'docs', :include=>doc.target
|
105
|
+
def into(path)
|
106
|
+
@target = file(path.to_s).enhance([self]) unless @target && @target.to_s == path.to_s
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
110
|
+
# :call-seq:
|
111
|
+
# include(*files) => self
|
112
|
+
#
|
113
|
+
# Includes additional source files and directories when generating the documentation
|
114
|
+
# and returns self. When specifying a directory, includes all source files in that directory.
|
115
|
+
def include(*files)
|
116
|
+
@files.include *files.flatten.compact
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
# :call-seq:
|
121
|
+
# exclude(*files) => self
|
122
|
+
#
|
123
|
+
# Excludes source files and directories from generating the documentation.
|
124
|
+
def exclude(*files)
|
125
|
+
@files.exclude *files
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
# :call-seq:
|
130
|
+
# with(*artifacts) => self
|
131
|
+
#
|
132
|
+
# Adds files and artifacts as classpath dependencies, and returns self.
|
133
|
+
def with(*specs)
|
134
|
+
@classpath |= Buildr.artifacts(specs.flatten).uniq
|
135
|
+
self
|
136
|
+
end
|
137
|
+
|
138
|
+
# :call-seq:
|
139
|
+
# using(options) => self
|
140
|
+
#
|
141
|
+
# Sets the documentation tool options from a hash and returns self.
|
142
|
+
#
|
143
|
+
# For example:
|
144
|
+
# doc.using :windowtitle=>'My application'
|
145
|
+
# doc.using :vscaladoc
|
146
|
+
def using(*args)
|
147
|
+
args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last
|
148
|
+
|
149
|
+
until args.empty?
|
150
|
+
new_engine = Doc.select_by_name(args.pop)
|
151
|
+
@engine = new_engine.new(project) unless new_engine.nil?
|
152
|
+
end
|
153
|
+
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
157
|
+
def engine
|
158
|
+
@engine ||= guess_engine
|
159
|
+
end
|
160
|
+
|
161
|
+
# :call-seq:
|
162
|
+
# from(*sources) => self
|
163
|
+
#
|
164
|
+
# Includes files, directories and projects in the documentation and returns self.
|
165
|
+
#
|
166
|
+
# You can call this method with source files and directories containing source files
|
167
|
+
# to include these files in the documentation, similar to #include. You can also call
|
168
|
+
# this method with projects. When called with a project, it includes all the source files compiled
|
169
|
+
# by that project and classpath dependencies used when compiling.
|
170
|
+
#
|
171
|
+
# For example:
|
172
|
+
# doc.from projects('myapp:foo', 'myapp:bar')
|
173
|
+
def from(*sources)
|
174
|
+
sources.flatten.each do |source|
|
175
|
+
case source
|
176
|
+
when Project
|
177
|
+
self.enhance source.prerequisites
|
178
|
+
self.include source.compile.sources
|
179
|
+
self.with source.compile.dependencies
|
180
|
+
when Rake::Task, String
|
181
|
+
self.include source
|
182
|
+
else
|
183
|
+
fail "Don't know how to generate documentation from #{source || 'nil'}"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
self
|
187
|
+
end
|
188
|
+
|
189
|
+
def prerequisites #:nodoc:
|
190
|
+
super + @files + classpath + sourcepath
|
191
|
+
end
|
192
|
+
|
193
|
+
def source_files #:nodoc:
|
194
|
+
@source_files ||= @files.map(&:to_s).map do |file|
|
195
|
+
File.directory?(file) ? FileList[File.join(file, "**/*.#{engine.class.source_ext}")] : file
|
196
|
+
end.flatten.reject { |file| @files.exclude?(file) }
|
197
|
+
end
|
198
|
+
|
199
|
+
def needed? #:nodoc:
|
200
|
+
return false if source_files.empty?
|
201
|
+
return true unless File.exist?(target.to_s)
|
202
|
+
source_files.map { |src| File.stat(src.to_s).mtime }.max > File.stat(target.to_s).mtime
|
203
|
+
end
|
204
|
+
|
205
|
+
private
|
206
|
+
|
207
|
+
def guess_engine
|
208
|
+
doc_engine = Doc.select project.compile.language
|
209
|
+
fail 'Unable to guess documentation provider for project.' unless doc_engine
|
210
|
+
doc_engine.new project
|
211
|
+
end
|
212
|
+
|
213
|
+
def associate_with(project)
|
214
|
+
@project ||= project
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
first_time do
|
220
|
+
desc 'Create the documentation for this project'
|
221
|
+
Project.local_task :doc
|
222
|
+
end
|
223
|
+
|
224
|
+
before_define do |project|
|
225
|
+
DocTask.define_task('doc').tap do |doc|
|
226
|
+
doc.send(:associate_with, project)
|
227
|
+
doc.into project.path_to(:target, :doc)
|
228
|
+
doc.using :windowtitle=>project.comment || project.name
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
after_define do |project|
|
233
|
+
project.doc.from project
|
234
|
+
end
|
235
|
+
|
236
|
+
# :call-seq:
|
237
|
+
# doc(*sources) => JavadocTask
|
238
|
+
#
|
239
|
+
# This method returns the project's documentation task. It also accepts a list of source files,
|
240
|
+
# directories and projects to include when generating the docs.
|
241
|
+
#
|
242
|
+
# By default the doc task uses all the source directories from compile.sources and generates
|
243
|
+
# documentation in the target/doc directory. This method accepts sources and adds them by calling
|
244
|
+
# Buildr::Doc::Base#from.
|
245
|
+
#
|
246
|
+
# For example, if you want to generate documentation for a given project that includes all source files
|
247
|
+
# in two of its sub-projects:
|
248
|
+
# doc projects('myapp:foo', 'myapp:bar').using(:windowtitle=>'Docs for foo and bar')
|
249
|
+
def doc(*sources, &block)
|
250
|
+
task('doc').from(*sources).enhance &block
|
251
|
+
end
|
252
|
+
|
253
|
+
def javadoc(*sources, &block)
|
254
|
+
warn 'The javadoc method is deprecated and will be removed in a future release.'
|
255
|
+
doc(*sources, &block)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
class Project
|
261
|
+
include Doc
|
262
|
+
end
|
263
|
+
end
|
@@ -21,19 +21,19 @@ module Buildr
|
|
21
21
|
|
22
22
|
# We use this to present environment variable as arrays.
|
23
23
|
class EnvArray < Array #:nodoc:
|
24
|
-
|
24
|
+
|
25
25
|
def initialize(name)
|
26
26
|
@name = name.upcase
|
27
27
|
replace((ENV[@name] || ENV[@name.downcase] || '').split(/\s*,\s*/).reject(&:empty?))
|
28
28
|
end
|
29
29
|
|
30
|
-
(Array.instance_methods - Object.instance_methods - Enumerable.instance_methods).sort.each do |method|
|
31
|
-
class_eval %{def #{method}(*args, &block) ; result = super ;
|
30
|
+
(Array.instance_methods - Object.instance_methods - Enumerable.instance_methods - ['each']).sort.each do |method|
|
31
|
+
class_eval %{def #{method}(*args, &block) ; result = super ; write_envarray ; result ; end}
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
def
|
36
|
+
def write_envarray
|
37
37
|
ENV[@name.downcase] = nil
|
38
38
|
ENV[@name] = map(&:to_s).join(',')
|
39
39
|
end
|
@@ -57,7 +57,7 @@ module Buildr
|
|
57
57
|
ENV['http_proxy'] = nil
|
58
58
|
ENV['HTTP_PROXY'] = url
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
# Returns the HTTPS_PROXY URL.
|
62
62
|
def https
|
63
63
|
ENV['HTTPS_PROXY'] || ENV['https_proxy']
|
@@ -69,7 +69,7 @@ module Buildr
|
|
69
69
|
ENV['HTTPS_PROXY'] = url
|
70
70
|
end
|
71
71
|
|
72
|
-
# Returns list of hosts to exclude from proxying (NO_PROXY).
|
72
|
+
# Returns list of hosts to exclude from proxying (NO_PROXY).
|
73
73
|
def exclude
|
74
74
|
@exclude ||= EnvArray.new('NO_PROXY')
|
75
75
|
end
|
data/lib/buildr/core/filter.rb
CHANGED
@@ -41,6 +41,9 @@ module Buildr
|
|
41
41
|
# relative to the source directories, so:
|
42
42
|
# filter.include '*.png'
|
43
43
|
# will only include PNG files from any of the source directories.
|
44
|
+
# In the same way, you can use regular expressions, so:
|
45
|
+
# filter.include /picture_.*\.png/
|
46
|
+
# will only include PNG files starting with picture_ from any of the sources directories.
|
44
47
|
#
|
45
48
|
# See Buildr#filter.
|
46
49
|
class Filter
|
@@ -52,9 +55,9 @@ module Buildr
|
|
52
55
|
# Returns the list of source directories (each being a file task).
|
53
56
|
attr_reader :sources
|
54
57
|
|
55
|
-
# :call-seq:
|
58
|
+
# :call-seq:
|
56
59
|
# clear => self
|
57
|
-
#
|
60
|
+
#
|
58
61
|
# Clear filter sources and include/exclude patterns
|
59
62
|
def clear
|
60
63
|
@include = []
|
@@ -77,7 +80,16 @@ module Buildr
|
|
77
80
|
end
|
78
81
|
|
79
82
|
# The target directory as a file task.
|
80
|
-
|
83
|
+
def target
|
84
|
+
return nil unless @target_dir
|
85
|
+
unless @target
|
86
|
+
@target = file(File.expand_path(@target_dir)) { |task| run if @target == task }
|
87
|
+
@target.enhance @include.select {|f| f.is_a?(Rake::FileTask)}
|
88
|
+
@target.enhance @exclude.select {|f| f.is_a?(Rake::FileTask)}
|
89
|
+
@target.enhance copy_map.values
|
90
|
+
end
|
91
|
+
@target
|
92
|
+
end
|
81
93
|
|
82
94
|
# :call-seq:
|
83
95
|
# into(dir) => self
|
@@ -87,7 +99,8 @@ module Buildr
|
|
87
99
|
# For example:
|
88
100
|
# filter.from('src').into('target').using('build'=>Time.now)
|
89
101
|
def into(dir)
|
90
|
-
@
|
102
|
+
@target_dir = dir.to_s
|
103
|
+
@target = nil
|
91
104
|
self
|
92
105
|
end
|
93
106
|
|
@@ -99,17 +112,17 @@ module Buildr
|
|
99
112
|
# By default all files are included. You can use this method to only include specific
|
100
113
|
# files from the source directory.
|
101
114
|
def include(*files)
|
102
|
-
@include += files
|
115
|
+
@include += files.flatten
|
103
116
|
self
|
104
117
|
end
|
105
|
-
alias :add :include
|
118
|
+
alias :add :include
|
106
119
|
|
107
120
|
# :call-seq:
|
108
121
|
# exclude(*files) => self
|
109
122
|
#
|
110
123
|
# Specifies files to exclude and returns self. See FileList#exclude.
|
111
124
|
def exclude(*files)
|
112
|
-
@exclude += files
|
125
|
+
@exclude += files.flatten
|
113
126
|
self
|
114
127
|
end
|
115
128
|
|
@@ -159,21 +172,8 @@ module Buildr
|
|
159
172
|
#
|
160
173
|
# Runs the filter.
|
161
174
|
def run
|
162
|
-
|
163
|
-
raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
|
175
|
+
copy_map = copy_map()
|
164
176
|
|
165
|
-
copy_map = sources.flatten.map(&:to_s).inject({}) do |map, source|
|
166
|
-
files = Util.recursive_with_dot_files(source).
|
167
|
-
map { |file| Util.relative_path(file, source) }.
|
168
|
-
select { |file| @include.empty? || @include.any? { |pattern| File.fnmatch(pattern, file) } }.
|
169
|
-
reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file) } }
|
170
|
-
files.each do |file|
|
171
|
-
src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
|
172
|
-
map[file] = src if !File.exist?(dest) || File.stat(src).mtime >= File.stat(dest).mtime
|
173
|
-
end
|
174
|
-
map
|
175
|
-
end
|
176
|
-
|
177
177
|
mkpath target.to_s
|
178
178
|
return false if copy_map.empty?
|
179
179
|
|
@@ -196,30 +196,71 @@ module Buildr
|
|
196
196
|
true
|
197
197
|
end
|
198
198
|
|
199
|
-
# Returns the target directory.
|
199
|
+
# Returns the target directory.
|
200
200
|
def to_s
|
201
|
-
|
201
|
+
target.to_s
|
202
|
+
end
|
203
|
+
|
204
|
+
protected
|
205
|
+
|
206
|
+
# :call-seq:
|
207
|
+
# pattern_match(file, pattern) => boolean
|
208
|
+
#
|
209
|
+
# This method returns true if the file name matches the pattern.
|
210
|
+
# The pattern may be a String, a Regexp or a Proc.
|
211
|
+
#
|
212
|
+
def pattern_match(file, pattern)
|
213
|
+
case
|
214
|
+
when pattern.is_a?(Regexp)
|
215
|
+
return file.match(pattern)
|
216
|
+
when pattern.is_a?(String)
|
217
|
+
return File.fnmatch(pattern, file)
|
218
|
+
when pattern.is_a?(Proc)
|
219
|
+
return pattern.call(file)
|
220
|
+
when pattern.is_a?(Rake::FileTask)
|
221
|
+
return pattern.to_s.match(file)
|
222
|
+
else
|
223
|
+
raise "Cannot interpret pattern #{pattern}"
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
private
|
228
|
+
def copy_map
|
229
|
+
sources.each { |source| raise "Source directory #{source} doesn't exist" unless File.exist?(source.to_s) }
|
230
|
+
raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
|
231
|
+
|
232
|
+
sources.flatten.map(&:to_s).inject({}) do |map, source|
|
233
|
+
files = Util.recursive_with_dot_files(source).
|
234
|
+
map { |file| Util.relative_path(file, source) }.
|
235
|
+
select { |file| @include.empty? || @include.any? { |pattern| pattern_match(file, pattern) } }.
|
236
|
+
reject { |file| @exclude.any? { |pattern| pattern_match(file, pattern) } }
|
237
|
+
files.each do |file|
|
238
|
+
src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
|
239
|
+
map[file] = src if !File.exist?(dest) || File.stat(src).mtime >= File.stat(dest).mtime
|
240
|
+
end
|
241
|
+
map
|
242
|
+
end
|
202
243
|
end
|
203
244
|
|
204
245
|
# This class implements content replacement logic for Filter.
|
205
246
|
#
|
206
|
-
# To register a new template engine @:foo@, extend this class with a method like:
|
207
|
-
#
|
247
|
+
# To register a new template engine @:foo@, extend this class with a method like:
|
248
|
+
#
|
208
249
|
# def foo_transform(content, path = nil)
|
209
250
|
# # if this method yields a key, the value comes from the mapping hash
|
210
251
|
# content.gsub(/world/) { |str| yield :bar }
|
211
252
|
# end
|
212
253
|
#
|
213
254
|
# Then you can use :foo mapping type on a Filter
|
214
|
-
#
|
255
|
+
#
|
215
256
|
# filter.using :foo, :bar => :baz
|
216
257
|
#
|
217
258
|
# Or all by your own, simply
|
218
259
|
#
|
219
260
|
# Mapper.new(:foo, :bar => :baz).transform("Hello world") # => "Hello baz"
|
220
|
-
#
|
261
|
+
#
|
221
262
|
# You can handle configuration arguments by providing a @*_config@ method like:
|
222
|
-
#
|
263
|
+
#
|
223
264
|
# # The return value of this method is available with the :config accessor.
|
224
265
|
# def moo_config(*args, &block)
|
225
266
|
# raise ArgumentError, "Expected moo block" unless block_given?
|
@@ -235,7 +276,7 @@ module Buildr
|
|
235
276
|
# end
|
236
277
|
#
|
237
278
|
# Usage for the @:moo@ mapper would be something like:
|
238
|
-
#
|
279
|
+
#
|
239
280
|
# mapper = Mapper.new(:moo, 'ooone', 'twoo') do |str|
|
240
281
|
# i = nil; str.capitalize.gsub(/\w/) { |s| s.send( (i = !i) ? 'upcase' : 'downcase' ) }
|
241
282
|
# end
|
@@ -247,7 +288,7 @@ module Buildr
|
|
247
288
|
def initialize(*args, &block) #:nodoc:
|
248
289
|
using(*args, &block)
|
249
290
|
end
|
250
|
-
|
291
|
+
|
251
292
|
def using(*args, &block)
|
252
293
|
case args.first
|
253
294
|
when Hash # Maven hash mapping
|
@@ -285,7 +326,8 @@ module Buildr
|
|
285
326
|
@config = configurer.call(*args, &block)
|
286
327
|
else
|
287
328
|
raise ArgumentError, "Missing hash argument after :#{mapper_type}" unless args.size == 1 && Hash === args[0]
|
288
|
-
@config =
|
329
|
+
@config = {} unless Hash === @config
|
330
|
+
args.first.each_pair { |k, v| @config[k] = v.to_s }
|
289
331
|
end
|
290
332
|
@mapper_type = mapper_type
|
291
333
|
end
|
@@ -293,15 +335,15 @@ module Buildr
|
|
293
335
|
def maven_transform(content, path = nil)
|
294
336
|
content.gsub(/\$\{.*?\}/) { |str| yield(str[2..-2]) || str }
|
295
337
|
end
|
296
|
-
|
338
|
+
|
297
339
|
def ant_transform(content, path = nil)
|
298
340
|
content.gsub(/@.*?@/) { |str| yield(str[1..-2]) || str }
|
299
341
|
end
|
300
|
-
|
342
|
+
|
301
343
|
def ruby_transform(content, path = nil)
|
302
344
|
content.gsub(/#\{.*?\}/) { |str| yield(str[2..-2]) || str }
|
303
345
|
end
|
304
|
-
|
346
|
+
|
305
347
|
def regexp_transform(content, path = nil)
|
306
348
|
content.gsub(mapper_type) { |str| yield(str.scan(mapper_type).join) || str }
|
307
349
|
end
|
@@ -309,7 +351,7 @@ module Buildr
|
|
309
351
|
def callback_transform(content, path = nil)
|
310
352
|
config.call(path, content)
|
311
353
|
end
|
312
|
-
|
354
|
+
|
313
355
|
def erb_transform(content, path = nil)
|
314
356
|
case config
|
315
357
|
when Binding
|