lib/buildr/javacc.rb in buildr-0.22.0 vs lib/buildr/javacc.rb in buildr-1.0.0

- old
+ new

@@ -3,36 +3,38 @@ module Buildr module JavaCC REQUIRES = [ "net.java.dev.javacc:javacc:jar:4.0", "net.java.dev.javacc:javacc:jar:4.0" ] + Java.rjb.onload do + Java.rjb.classpath << REQUIRES + end + 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 = Hash === args.last ? args.pop : {} + rake_check_options 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) + args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten + args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output] + Java.rjb do |rjb| + rjb.import("org.javacc.parser.Main").mainProgram(args) == 0 or + fail "Failed to run JavaCC, see errors above." + end 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 = Hash === args.last ? args.pop : {} + rake_check_options 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) + args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "**/*.jjt"] : f }.flatten + args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output] + args.unshift "-BUILD_NODE_FILES=#{options[:build_node_files] || false}" + Java.rjb do |rjb| + rjb.import("org.javacc.jjtree.JJTree").new.main(args) == 0 or + fail "Failed to run JJTree, see errors above." + end end end def javacc(*args)