buildr 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +62 -4
- data/LICENSE +1 -1
- data/README +64 -1
- data/lib/buildr.rb +27 -28
- data/lib/core/build.rb +39 -30
- data/lib/core/project.rb +323 -247
- data/lib/core/rake_ext.rb +116 -0
- data/lib/core/transports.rb +81 -36
- data/lib/java/ant.rb +78 -0
- data/lib/{core → java}/artifact.rb +212 -109
- data/lib/java/compile.rb +158 -78
- data/lib/java/eclipse.rb +27 -12
- data/lib/java/java.rb +269 -111
- data/lib/java/javacc.rb +53 -69
- data/lib/java/jetty.rb +203 -92
- data/lib/java/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/java/jetty/JettyWrapper.class +0 -0
- data/lib/java/jetty/JettyWrapper.java +69 -20
- data/lib/java/openjpa.rb +57 -45
- data/lib/java/packaging.rb +248 -116
- data/lib/java/test.rb +261 -128
- data/lib/java/xmlbeans.rb +55 -49
- data/lib/tasks/concat.rb +34 -0
- data/lib/tasks/download.rb +5 -0
- data/lib/tasks/filter.rb +107 -55
- data/lib/tasks/zip.rb +283 -155
- metadata +25 -5
- data/lib/core/core.rb +0 -155
data/lib/java/java.rb
CHANGED
@@ -1,152 +1,310 @@
|
|
1
|
-
require
|
1
|
+
require "rjb"
|
2
|
+
require "core/project"
|
2
3
|
|
3
4
|
module Buildr
|
5
|
+
|
6
|
+
# Base module for all things Java.
|
4
7
|
module Java
|
5
8
|
|
6
|
-
|
9
|
+
# Options accepted by #java and other methods here.
|
10
|
+
JAVA_OPTIONS = [ :verbose, :classpath, :name, :java_args ]
|
11
|
+
# Classpath dependencies available when running JUnit.
|
7
12
|
JUNIT_REQUIRES = [ "junit:junit:jar:3.8.1", "jmock:jmock:jar:1.1.0" ]
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
puts "Running #{name}" if verbose
|
23
|
-
sh(path_to_bin("java"), *cmd_args) { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok }
|
24
|
-
end
|
25
|
-
end
|
14
|
+
# Returned by Java#rjb, you can use this object to set the RJB classpath, specify blocks to be invoked
|
15
|
+
# after loading RJB, and load RJB itself.
|
16
|
+
#
|
17
|
+
# RJB can be loaded exactly once, and once loaded, you cannot change its classpath. Of course you can
|
18
|
+
# call libraries that manage their own classpath, but the lazy way is to just tell RJB of all the
|
19
|
+
# classpath dependencies you need in advance, before loading it.
|
20
|
+
#
|
21
|
+
# For that reason, you should not load RJB until the moment you need it. You can call #load or call
|
22
|
+
# Java#rjb with a block. For the same reason, you may need to specify code to execute when loading
|
23
|
+
# (see #onload).
|
24
|
+
class RjbWrapper
|
25
|
+
|
26
|
+
include Singleton
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
if options[:compile]
|
35
|
-
args << "-d" << options[:output]
|
36
|
-
else
|
37
|
-
args << "-nocompile" << "-s" << options[:output]
|
28
|
+
def initialize() #:nodoc:
|
29
|
+
@classpath = []
|
30
|
+
@onload = []
|
31
|
+
onload do
|
32
|
+
Rjb.load(artifacts(classpath).each { |task| task.invoke if task.respond_to?(:invoke) }.
|
33
|
+
map(&:to_s).join(File::PATH_SEPARATOR))
|
34
|
+
end
|
38
35
|
end
|
39
|
-
|
40
|
-
classpath
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
|
37
|
+
# The classpath used when loading RJB.
|
38
|
+
attr_accessor :classpath
|
39
|
+
|
40
|
+
# :call-seq:
|
41
|
+
# onload { ... }
|
42
|
+
#
|
43
|
+
# Adds a block to call when loading RJB and returns self.
|
44
|
+
#
|
45
|
+
# You can only load RJB once, and you may need to do some tasks after the initial load.
|
46
|
+
# For example, the Ant module requires Antwrap which can only be loaded after RJB.
|
47
|
+
def onload(&block)
|
48
|
+
@onload << block
|
49
|
+
self
|
47
50
|
end
|
48
|
-
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
# :call-seq:
|
53
|
+
# load()
|
54
|
+
#
|
55
|
+
# Loads RJB. You can also call Java#ejb with a block to get the same effect.
|
56
|
+
def load()
|
57
|
+
@onload.each(&:call)
|
58
|
+
@onload.clear
|
59
|
+
end
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
tools = File.join(ENV['JAVA_HOME'], "lib", "tools.jar")
|
58
|
-
@tools = File.exist?(tools) ? tools : []
|
61
|
+
def method_missing(sym, *args, &block) #:nodoc:
|
62
|
+
Rjb.send sym, *args, &block
|
59
63
|
end
|
60
|
-
@tools
|
61
64
|
end
|
62
65
|
|
63
|
-
class
|
66
|
+
class << self
|
67
|
+
|
68
|
+
# :call-seq:
|
69
|
+
# version() => string
|
70
|
+
#
|
71
|
+
# Returns the version number of the JVM.
|
72
|
+
#
|
73
|
+
# For example:
|
74
|
+
# puts Java.version
|
75
|
+
# => 1.5.0_10
|
76
|
+
def version()
|
77
|
+
@version ||= `#{path_to_bin("java")} -version 2>&1`.scan(/java version "(.*)"/)[0][0]
|
78
|
+
end
|
64
79
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
# :call-seq:
|
81
|
+
# tools_jar() => path
|
82
|
+
#
|
83
|
+
# Returns a path to tools.jar.
|
84
|
+
def tools_jar()
|
85
|
+
unless @tools
|
86
|
+
home = ENV["JAVA_HOME"] || File.dirname(File.dirname(`which java`.split.first))
|
87
|
+
tools = File.join(home, "lib/tools.jar")
|
88
|
+
@tools = tools if File.exist?(tools)
|
69
89
|
end
|
90
|
+
@tools
|
70
91
|
end
|
71
92
|
|
72
|
-
|
73
|
-
|
93
|
+
# :call-seq:
|
94
|
+
# java(class, *args, options?)
|
95
|
+
#
|
96
|
+
# Runs Java with the specified arguments.
|
97
|
+
#
|
98
|
+
# The last argument may be a Hash with additional options:
|
99
|
+
# * :classpath -- One or more file names, tasks or artifact specifications.
|
100
|
+
# These are all expanded into artifacts, and all tasks are invoked.
|
101
|
+
# * :java_args -- Any additional arguments to pass (e.g. -hotspot, -xms)
|
102
|
+
# * :name -- Shows this name, otherwise shows the first argument (the class name).
|
103
|
+
# * :verbose -- If true, prints the command and all its argument.
|
104
|
+
def java(*args)
|
105
|
+
options = Hash === args.last ? args.pop : {}
|
106
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
107
|
+
fu_check_options options, *JAVA_OPTIONS
|
108
|
+
|
109
|
+
name = options[:name] || "java #{args.first}"
|
110
|
+
cmd_args = []
|
111
|
+
classpath = classpath_from(options)
|
112
|
+
cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
113
|
+
cmd_args += options[:java_args].flatten if options[:java_args]
|
114
|
+
cmd_args += args.flatten.compact
|
115
|
+
cmd_args << { :verbose=>options[:verbose] }
|
116
|
+
unless Rake.application.options.dryrun
|
117
|
+
puts "Running #{name}" if verbose
|
118
|
+
sh(path_to_bin("java"), *cmd_args) { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok }
|
119
|
+
end
|
74
120
|
end
|
75
121
|
|
76
|
-
|
77
|
-
|
78
|
-
|
122
|
+
# :call-seq:
|
123
|
+
# apt(*files, options)
|
124
|
+
#
|
125
|
+
# Runs Apt with the specified arguments.
|
126
|
+
#
|
127
|
+
# The last argument may be a Hash with additional options:
|
128
|
+
# * :compile -- If true, compile source files to class files.
|
129
|
+
# * :source -- Specifies source compatibility with a given JVM release.
|
130
|
+
# * :output -- Directory where to place the generated source files, or the
|
131
|
+
# generated class files when compiling.
|
132
|
+
# * :classpath -- One or more file names, tasks or artifact specifications.
|
133
|
+
# These are all expanded into artifacts, and all tasks are invoked.
|
134
|
+
# * :verbose -- If true, prints the command and all its argument and also runs
|
135
|
+
# Apt in verbose mode (the default is -nowarn).
|
136
|
+
def apt(*args)
|
137
|
+
options = Hash === args.last ? args.pop : {}
|
138
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
139
|
+
fu_check_options options, :verbose, :compile, :source, :output, :classpath
|
140
|
+
|
141
|
+
files = args.flatten.map(&:to_s).
|
142
|
+
collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
|
143
|
+
args = [ options[:verbose] ? "-verbose" : "-nowarn" ]
|
144
|
+
if options[:compile]
|
145
|
+
args << "-d" << options[:output].to_s
|
146
|
+
else
|
147
|
+
args << "-nocompile" << "-s" << options[:output].to_s
|
148
|
+
end
|
149
|
+
args << "-source" << options[:source] if options[:source]
|
150
|
+
classpath = classpath_from(options)
|
151
|
+
args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
152
|
+
args += files
|
153
|
+
args << { :verbose=>options[:verbose] }
|
154
|
+
unless Rake.application.options.dryrun
|
155
|
+
puts "Running apt" if verbose
|
156
|
+
sh(path_to_bin("apt"), *args) { |ok, res| fail "Failed to execute apt, see errors above" unless ok }
|
157
|
+
end
|
79
158
|
end
|
80
159
|
|
81
|
-
|
160
|
+
# :call-seq:
|
161
|
+
# javac(*files, options)
|
162
|
+
#
|
163
|
+
# Runs Javac with the specified arguments.
|
164
|
+
#
|
165
|
+
# The last argument may be a Hash with additional options:
|
166
|
+
# * :output -- Target directory for all compiled class files.
|
167
|
+
# * :classpath -- One or more file names, tasks or artifact specifications.
|
168
|
+
# These are all expanded into artifacts, and all tasks are invoked.
|
169
|
+
# * :sourcepath -- Additional source paths to use.
|
170
|
+
# * :javac_args -- Any additional arguments to pass (e.g. -extdirs, -encoding)
|
171
|
+
# * :name -- Shows this name, otherwise shows the working directory.
|
172
|
+
# * :verbose -- If true, prints the command and all its argument.
|
173
|
+
def javac(*args)
|
174
|
+
options = Hash === args.last ? args.pop : {}
|
175
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
176
|
+
fu_check_options options, :verbose, :classpath, :sourcepath, :output, :javac_args, :name
|
82
177
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
AptTask.define_task(output=>files)
|
87
|
-
end
|
178
|
+
files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).
|
179
|
+
collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
|
180
|
+
name = options[:name] || Dir.pwd
|
88
181
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
cmd_args << "-sourcepath" << options[:sourcepath].join(File::PATH_SEPARATOR) if options[:sourcepath]
|
103
|
-
cmd_args << "-d" << options[:output] if options[:output]
|
104
|
-
cmd_args += options[:javac_args].flatten if options[:javac_args]
|
105
|
-
cmd_args += files
|
106
|
-
cmd_args << { :verbose=>options[:verbose] }
|
107
|
-
unless options[:noop] || files.empty?
|
108
|
-
puts "Compiling #{files.size} source files in #{name}" if verbose
|
109
|
-
sh(path_to_bin("javac"), *cmd_args) { |ok, res| fail "Failed to compile, see errors above" unless ok }
|
182
|
+
cmd_args = []
|
183
|
+
classpath = classpath_from(options)
|
184
|
+
#classpath += options[:output] if options[:output]
|
185
|
+
cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
|
186
|
+
cmd_args << "-sourcepath" << options[:sourcepath].join(File::PATH_SEPARATOR) if options[:sourcepath]
|
187
|
+
cmd_args << "-d" << options[:output].to_s if options[:output]
|
188
|
+
cmd_args += options[:javac_args].flatten if options[:javac_args]
|
189
|
+
cmd_args += files
|
190
|
+
cmd_args << { :verbose=>options[:verbose] }
|
191
|
+
unless Rake.application.options.dryrun
|
192
|
+
puts "Compiling #{files.size} source files in #{name}" if verbose
|
193
|
+
sh(path_to_bin("javac"), *cmd_args) { |ok, res| fail "Failed to compile, see errors above" unless ok }
|
194
|
+
end
|
110
195
|
end
|
111
|
-
end
|
112
196
|
|
113
|
-
|
114
|
-
options
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
197
|
+
# :call-seq:
|
198
|
+
# junit(*classes, options) => [ passed, failed ]
|
199
|
+
#
|
200
|
+
# Runs JUnit test cases from the specified classes. Returns an array with two lists,
|
201
|
+
# one containing the names of all classes that passes, the other containing the names
|
202
|
+
# of all classes that failed.
|
203
|
+
#
|
204
|
+
# The last argument may be a Hash with additional options:
|
205
|
+
# * :classpath -- One or more file names, tasks or artifact specifications.
|
206
|
+
# These are all expanded into artifacts, and all tasks are invoked.
|
207
|
+
# * :verbose -- If true, prints the command and all its argument.
|
208
|
+
def junit(*args)
|
209
|
+
options = Hash === args.last ? args.pop : {}
|
210
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
211
|
+
fu_check_options options, :verbose, :classpath
|
212
|
+
|
213
|
+
classpath = classpath_from(options) + junit_artifacts
|
214
|
+
tests = args.flatten
|
215
|
+
failed = tests.inject([]) do |failed, test|
|
216
|
+
begin
|
217
|
+
java "junit.textui.TestRunner", test, :classpath=>classpath, :name=>"tests in #{test}", :verbose=>options[:verbose]
|
218
|
+
failed
|
219
|
+
rescue
|
220
|
+
failed << test
|
221
|
+
end
|
222
|
+
end
|
223
|
+
[ tests - failed, failed ]
|
224
|
+
end
|
225
|
+
|
226
|
+
# :call-seq:
|
227
|
+
# rjb() => RjbWrapper
|
228
|
+
# rjb() { ... }
|
229
|
+
#
|
230
|
+
# This method can be used in two ways. Without a block, returns the RjbWrapper
|
231
|
+
# object which you can use to configure the RJB classpath or call other RJB methods.
|
232
|
+
# With a block, loads RJB and yields to the block, returning its result.
|
233
|
+
#
|
234
|
+
# For example:
|
235
|
+
# Java.rjb.classpath += REQUIRES
|
236
|
+
# Java.rjb.onload { require "antwrap" }
|
237
|
+
# . . .
|
238
|
+
#
|
239
|
+
# def execute(name, options)
|
240
|
+
# options = options.merge(:name=>name, :base_dir=>Dir.pwd, :declarative=>true)
|
241
|
+
# Java.rjb { AntProject.new(options) }
|
242
|
+
# end
|
243
|
+
def rjb()
|
244
|
+
if block_given?
|
245
|
+
RjbWrapper.instance.load
|
246
|
+
yield
|
247
|
+
else
|
248
|
+
RjbWrapper.instance
|
126
249
|
end
|
127
250
|
end
|
128
|
-
|
129
|
-
|
251
|
+
|
252
|
+
# :call-seq:
|
253
|
+
# path_to_bin(cmd?) => path
|
254
|
+
#
|
255
|
+
# Returns the path to the specified Java command (with no argument to java itself).
|
256
|
+
# Uses JAVA_HOME if set, otherwise assumes the command is accessible from the path.
|
257
|
+
def path_to_bin(name = "java")
|
258
|
+
ENV["JAVA_HOME"] ? File.join(ENV["JAVA_HOME"], "bin", name) : name
|
259
|
+
end
|
130
260
|
|
131
261
|
protected
|
132
262
|
|
133
|
-
|
134
|
-
|
263
|
+
# :call-seq:
|
264
|
+
# classpath_from(options) => files
|
265
|
+
#
|
266
|
+
# Extracts the classpath from the options, expands it by calling artifacts, invokes
|
267
|
+
# each of the artifacts and returns an array of paths.
|
268
|
+
def classpath_from(options)
|
269
|
+
classpath = (options[:classpath] || []).collect
|
270
|
+
artifacts(classpath).each { |t| t.invoke if t.respond_to?(:invoke) }.map(&:to_s)
|
271
|
+
end
|
272
|
+
|
273
|
+
# :call-seq:
|
274
|
+
# junit_artifacts() => files
|
275
|
+
#
|
276
|
+
# Returns the JUnit artifacts as paths, after downloading and installing them (if necessary).
|
277
|
+
def junit_artifacts()
|
278
|
+
@junit_artifacts ||= artifacts(JUNIT_REQUIRES).each { |task| task.invoke }.map(&:to_s)
|
279
|
+
end
|
280
|
+
|
135
281
|
end
|
136
282
|
|
137
|
-
|
138
|
-
|
139
|
-
|
283
|
+
# See Java#java.
|
284
|
+
def java(*args)
|
285
|
+
Java.java(*args)
|
140
286
|
end
|
141
287
|
|
142
|
-
|
143
|
-
|
288
|
+
# :call-seq:
|
289
|
+
# apt(*sources) => task
|
290
|
+
#
|
291
|
+
# Returns a task that will use Java#apt to generate source files in target/generated/apt,
|
292
|
+
# from all the source directories passed as arguments. Uses the compile.sources list if
|
293
|
+
# on arguments supplied.
|
294
|
+
#
|
295
|
+
# For example:
|
296
|
+
#
|
297
|
+
def apt(*sources)
|
298
|
+
sources = compile.sources if sources.empty?
|
299
|
+
file(path_to("target/generated/apt")=>sources) do |task|
|
300
|
+
Java.apt(sources.map(&:to_s) - [task.name], :output=>task.name,
|
301
|
+
:classpath=>compile.classpath, :source=>compile.options.source)
|
302
|
+
end
|
144
303
|
end
|
145
304
|
|
146
305
|
end
|
147
306
|
|
148
|
-
|
149
|
-
Java
|
307
|
+
class Project
|
308
|
+
include Java
|
150
309
|
end
|
151
|
-
|
152
310
|
end
|
data/lib/java/javacc.rb
CHANGED
@@ -1,88 +1,72 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module JavaCC
|
1
|
+
require "java/java"
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
module Buildr
|
4
|
+
module Java
|
5
|
+
module JavaCC
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
options[:verbose] ||= Rake.application.options.trace || false
|
11
|
-
fu_check_options options, *Java::JAVA_OPTIONS + [:output]
|
7
|
+
JAVACC = "net.java.dev.javacc:javacc:jar:4.0"
|
8
|
+
JJTREE = "net.java.dev.javacc:javacc:jar:4.0"
|
12
9
|
|
13
|
-
|
14
|
-
java_args = ["javacc"]
|
15
|
-
java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
|
16
|
-
java_args += args.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
|
17
|
-
java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
|
18
|
-
Java.java(*java_args)
|
19
|
-
end
|
10
|
+
class << self
|
20
11
|
|
21
|
-
|
12
|
+
def javacc(*args)
|
13
|
+
options = Hash === args.last ? args.pop.clone : {}
|
14
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
15
|
+
fu_check_options options, *Java::JAVA_OPTIONS + [:output]
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
(options[:classpath] ||= []) << JAVACC
|
18
|
+
java_args = ["javacc"]
|
19
|
+
java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
|
20
|
+
java_args += args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
|
21
|
+
java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
|
22
|
+
Java.java(*java_args)
|
27
23
|
end
|
28
|
-
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
def jjtree(*args)
|
26
|
+
options = Hash === args.last ? args.pop.clone : {}
|
27
|
+
options[:verbose] ||= Rake.application.options.trace || false
|
28
|
+
fu_check_options options, *Java::JAVA_OPTIONS + [:output, :build_node_files]
|
29
|
+
|
30
|
+
(options[:classpath] ||= []) << JJTREE
|
31
|
+
java_args = ["jjtree"]
|
32
|
+
java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
|
33
|
+
java_args << "-BUILD_NODE_FILES=#{options[:build_node_files] || false}"
|
34
|
+
java_args += args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
|
35
|
+
java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
|
36
|
+
Java.java(*java_args)
|
37
|
+
end
|
33
38
|
|
34
|
-
def using(options)
|
35
|
-
self.options.merge!(options)
|
36
|
-
self
|
37
39
|
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.jjtree(*args)
|
48
|
-
options = Hash === args.last ? args.pop.clone : {}
|
49
|
-
options[:verbose] ||= Rake.application.options.trace || false
|
50
|
-
fu_check_options options, *Java::JAVA_OPTIONS + [:output, :build_node_files]
|
51
|
-
|
52
|
-
(options[:classpath] ||= []) << JJTREE
|
53
|
-
java_args = ["jjtree"]
|
54
|
-
java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
|
55
|
-
java_args << "-BUILD_NODE_FILES=#{options[:build_node_files]}" if options.has_key?(:build_node_files)
|
56
|
-
java_args += args.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
|
57
|
-
java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
|
58
|
-
Java.java(*java_args)
|
59
|
-
end
|
60
|
-
|
61
|
-
class JJTreeTask < Rake::FileTask
|
62
|
-
|
63
|
-
def initialize(*args)
|
64
|
-
super
|
65
|
-
enhance do |task|
|
66
|
-
JavaCC.jjtree *(task.prerequisites + [task.options.merge(:output=>task.name)])
|
41
|
+
def javacc(*args)
|
42
|
+
if Hash === args.last
|
43
|
+
options = args.pop
|
44
|
+
in_package = options[:in_package].split(".")
|
45
|
+
else
|
46
|
+
in_package = []
|
67
47
|
end
|
48
|
+
file(path_to("target/generated/javacc")=>args.flatten) do |task|
|
49
|
+
Java::JavaCC.javacc task.prerequisites, :output=>File.join(task.name, in_package)
|
50
|
+
end
|
68
51
|
end
|
69
52
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
53
|
+
def jjtree(*args)
|
54
|
+
if Hash === args.last
|
55
|
+
options = args.pop
|
56
|
+
in_package = options[:in_package].split(".")
|
57
|
+
build_node_files = options[:build_node_files]
|
58
|
+
else
|
59
|
+
in_package = []
|
60
|
+
end
|
61
|
+
file(path_to("target/generated/jjtree")=>args.flatten) do |task|
|
62
|
+
Java::JavaCC.jjtree task.prerequisites, :output=>File.join(task.name, in_package), :build_node_files=>build_node_files
|
63
|
+
end
|
77
64
|
end
|
78
65
|
|
79
66
|
end
|
67
|
+
end
|
80
68
|
|
81
|
-
|
82
|
-
|
83
|
-
files = args.values.first.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
|
84
|
-
JJTreeTask.define_task(output=>files)
|
85
|
-
end
|
86
|
-
|
69
|
+
class Project
|
70
|
+
include JavaCC
|
87
71
|
end
|
88
72
|
end
|