Class: Buildr::Compiler::Ecj

Inherits:
Javac show all
Defined in:
lib/buildr/java/ecj.rb

Overview

:nodoc:

Constant Summary collapse

VERSION =
"4.5.1"
OPTIONS =
Buildr::Compiler::Javac::OPTIONS

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Javac

#compile_map, #initialize

Methods inherited from Base

applies_to?, #dependencies, #initialize, #needed?, specify, to_sym

Constructor Details

This class inherits a constructor from Buildr::Compiler::Javac

Class Method Details

.dependenciesObject

ECJ classpath dependencies.



30
31
32
# File 'lib/buildr/java/ecj.rb', line 30

def dependencies
  @dependencies ||= ["org.eclipse.jdt.core.compiler:ecj:jar:#{version}"]
end

.versionObject

Current version of ECJ being used.



25
26
27
# File 'lib/buildr/java/ecj.rb', line 25

def version
  Buildr.settings.build['ecj'] || VERSION
end

Instance Method Details

#compile(sources, target, dependencies) ⇒ Object

:nodoc:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/buildr/java/ecj.rb', line 40

def compile(sources, target, dependencies) #:nodoc:
  check_options options, OPTIONS
  cmd_args = []
  # tools.jar contains the Java compiler.
  dependencies << Java.tools_jar if Java.tools_jar
  cmd_args << '-classpath' << ('"' + dependencies.join(File::PATH_SEPARATOR) + '"') unless dependencies.empty?
  source_paths = sources.select { |source| File.directory?(source) }
  cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
  cmd_args << '-d' << File.expand_path(target)
  cmd_args += ecj_args
  cmd_args += files_from_sources(sources)
  unless Buildr.application.options.dryrun
    trace((%w[javac -classpath org.eclipse.jdt.internal.compiler.batch.Main] + cmd_args).join(' '))
    Java.load
    Java.org.eclipse.jdt.internal.compiler.batch.Main.compile(cmd_args.join(" ")) or
    fail 'Failed to compile, see errors above'
  end
end