Module: Jdtc

Defined in:
lib/jdtc.rb

Constant Summary collapse

VERSION =
'0.0.1'
CURRENT_JDT_COMPILER =
'3.4.1'

Instance Method Summary collapse

Instance Method Details

#ecj_locationObject



10
11
12
# File 'lib/jdtc.rb', line 10

def ecj_location
  File.expand_path File.dirname(__FILE__) + "/../compiler/ecj-#{CURRENT_JDT_COMPILER}.jar"
end

#java_homeObject



6
7
8
# File 'lib/jdtc.rb', line 6

def java_home
  @home ||= ENV['JAVA_HOME']
end

#jdtc(args = []) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/jdtc.rb', line 14

def jdtc(args = [])
  java_call = "java"
  if (!java_home)
    warn 'JAVA_HOME not set, defaulting on the java executable in the path if there is one.'
  else
    java_call = "$JAVA_HOME/bin/java"
  end
  puts "#{java_call} -classpath #{ecj_location} org.eclipse.jdt.internal.compiler.batch.Main #{args.join(" ")}"
  system("#{java_call} -classpath #{ecj_location} org.eclipse.jdt.internal.compiler.batch.Main #{args.join(" ")}") or fail "Compilation failed"
end