require "java/java" module Buildr module JavaCC REQUIRES = [ "net.java.dev.javacc:javacc:jar:4.0", "net.java.dev.javacc:javacc:jar:4.0" ] class << self 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] ||= []) << REQUIRES 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 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] (options[:classpath] ||= []) << REQUIRES 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 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| JavaCC.javacc task.prerequisites, :output=>File.join(task.name, in_package) end end 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| JavaCC.jjtree task.prerequisites, :output=>File.join(task.name, in_package), :build_node_files=>build_node_files end end end class Project include JavaCC end end