summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Dias <tiagofrederico.dias@gmail.com>2019-09-19 22:16:07 +0100
committerSutou Kouhei <kou@clear-code.com>2019-09-20 06:16:07 +0900
commitb4b390cd791971f8d7bc861b32aa4278081a97d1 (patch)
tree123bb318dcffddb0ee1da5f6ae76b3dd92913d5f
parent19fd1e3834ff18c79e2d95529a8c558348b91b86 (diff)
downloadrake-compiler-b4b390cd791971f8d7bc861b32aa4278081a97d1.tar.gz
Add the -encoding option optionally to java compiler (#157)
-rw-r--r--lib/rake/javaextensiontask.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb
index 711148e..3a3300b 100644
--- a/lib/rake/javaextensiontask.rb
+++ b/lib/rake/javaextensiontask.rb
@@ -17,6 +17,8 @@ module Rake
# Generate class files for specific VM version
attr_accessor :target_version
+ attr_accessor :encoding
+
def platform
@platform ||= 'java'
end
@@ -29,6 +31,7 @@ module Rake
super
@source_pattern = '**/*.java'
@classpath = nil
+ @encoding = nil
@java_compiling = nil
@debug = false
@source_version = '1.6'
@@ -95,7 +98,7 @@ execute the Rake compilation task using the JRuby interpreter.
classpath_arg = java_classpath_arg(@classpath)
debug_arg = @debug ? '-g' : ''
- sh "javac #{java_extdirs_arg} -target #{@target_version} -source #{@source_version} -Xlint:unchecked #{debug_arg} #{classpath_arg} -d #{tmp_path} #{source_files.join(' ')}"
+ sh "javac #{java_encoding_arg} #{java_extdirs_arg} -target #{@target_version} -source #{@source_version} -Xlint:unchecked #{debug_arg} #{classpath_arg} -d #{tmp_path} #{source_files.join(' ')}"
# Checkpoint file
touch "#{tmp_path}/.build"
@@ -194,6 +197,13 @@ execute the Rake compilation task using the JRuby interpreter.
end
#
+ # Build an encoding argument
+ #
+ def java_encoding_arg
+ @encoding.nil? ? "" : "-encoding \"#{@encoding}\""
+ end
+
+ #
# Discover the Java/JRuby classpath and build a classpath argument
#
# @params