lib/java/javacc.rb in buildr-0.18.0 vs lib/java/javacc.rb in buildr-0.19.0
- old
+ new
@@ -1,88 +1,72 @@
+require "java/java"
+
module Buildr
+ module Java
+ module JavaCC
- module JavaCC
+ JAVACC = "net.java.dev.javacc:javacc:jar:4.0"
+ JJTREE = "net.java.dev.javacc:javacc:jar:4.0"
- JAVACC = "net.java.dev.javacc:javacc:jar:4.0"
- JJTREE = "net.java.dev.javacc:javacc:jar:4.0"
+ class << self
- def self.javacc(*args)
- options = Hash === args.last ? args.pop.clone : {}
- options[:verbose] ||= Rake.application.options.trace || false
- fu_check_options options, *Java::JAVA_OPTIONS + [:output]
+ def javacc(*args)
+ options = Hash === args.last ? args.pop.clone : {}
+ options[:verbose] ||= Rake.application.options.trace || false
+ fu_check_options options, *Java::JAVA_OPTIONS + [:output]
- (options[:classpath] ||= []) << JAVACC
- java_args = ["javacc"]
- java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
- java_args += args.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
- java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
- Java.java(*java_args)
- end
+ (options[:classpath] ||= []) << JAVACC
+ java_args = ["javacc"]
+ java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
+ java_args += args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
+ java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
+ Java.java(*java_args)
+ end
- class JavaCCTask < Rake::FileTask
+ def jjtree(*args)
+ options = Hash === args.last ? args.pop.clone : {}
+ options[:verbose] ||= Rake.application.options.trace || false
+ fu_check_options options, *Java::JAVA_OPTIONS + [:output, :build_node_files]
- def initialize(*args)
- super
- enhance do |task|
- JavaCC.javacc *(task.prerequisites + [task.options.merge(:output=>task.name)])
+ (options[:classpath] ||= []) << JJTREE
+ java_args = ["jjtree"]
+ java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
+ java_args << "-BUILD_NODE_FILES=#{options[:build_node_files] || false}"
+ java_args += args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
+ java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
+ Java.java(*java_args)
end
- end
- def options()
- @options ||= {}
end
- def using(options)
- self.options.merge!(options)
- self
+ def javacc(*args)
+ if Hash === args.last
+ options = args.pop
+ in_package = options[:in_package].split(".")
+ else
+ in_package = []
+ end
+ file(path_to("target/generated/javacc")=>args.flatten) do |task|
+ Java::JavaCC.javacc task.prerequisites, :output=>File.join(task.name, in_package)
+ end
end
- end
-
- def self.javacc_task(args)
- output = args.keys.first
- files = args.values.first.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
- JavaCCTask.define_task(output=>files)
- end
-
- def self.jjtree(*args)
- options = Hash === args.last ? args.pop.clone : {}
- options[:verbose] ||= Rake.application.options.trace || false
- fu_check_options options, *Java::JAVA_OPTIONS + [:output, :build_node_files]
-
- (options[:classpath] ||= []) << JJTREE
- java_args = ["jjtree"]
- java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
- java_args << "-BUILD_NODE_FILES=#{options[:build_node_files]}" if options.has_key?(:build_node_files)
- java_args += args.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
- java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
- Java.java(*java_args)
- end
-
- class JJTreeTask < Rake::FileTask
-
- def initialize(*args)
- super
- enhance do |task|
- JavaCC.jjtree *(task.prerequisites + [task.options.merge(:output=>task.name)])
+ def jjtree(*args)
+ if Hash === args.last
+ options = args.pop
+ in_package = options[:in_package].split(".")
+ build_node_files = options[:build_node_files]
+ else
+ in_package = []
end
+ file(path_to("target/generated/jjtree")=>args.flatten) do |task|
+ Java::JavaCC.jjtree task.prerequisites, :output=>File.join(task.name, in_package), :build_node_files=>build_node_files
+ end
end
- def options()
- @options ||= {}
- end
-
- def using(options)
- self.options.merge!(options)
- self
- end
-
end
+ end
- def self.jjtree_task(args)
- output = args.keys.first
- files = args.values.first.collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
- JJTreeTask.define_task(output=>files)
- end
-
+ class Project
+ include JavaCC
end
end