diff options
Diffstat (limited to 'lib/rake/javaextensiontask.rb')
-rw-r--r-- | lib/rake/javaextensiontask.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb index 162a463..0963338 100644 --- a/lib/rake/javaextensiontask.rb +++ b/lib/rake/javaextensiontask.rb @@ -19,6 +19,9 @@ module Rake attr_accessor :encoding + # Specify lint option + attr_accessor :lint_option + def platform @platform ||= 'java' end @@ -36,6 +39,7 @@ module Rake @target_version = '1.6' @encoding = nil @java_compiling = nil + @lint_option = nil end def define @@ -98,7 +102,7 @@ execute the Rake compilation task using the JRuby interpreter. classpath_arg = java_classpath_arg(@classpath) debug_arg = @debug ? '-g' : '' - 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(' ')}" + sh "javac #{java_encoding_arg} #{java_extdirs_arg} -target #{@target_version} -source #{@source_version} #{java_lint_arg @lint_option} #{debug_arg} #{classpath_arg} -d #{tmp_path} #{source_files.join(' ')}" # Checkpoint file touch "#{tmp_path}/.build" @@ -254,5 +258,16 @@ execute the Rake compilation task using the JRuby interpreter. jruby_cpath ? "-cp \"#{jruby_cpath}\"" : "" end + # + # Convert a `-Xlint:___` linting option such as `deprecation` into a full javac argument, such as `-Xlint:deprecation`. + # + # @param [String] lint_option A `-Xlint:___` linting option such as `deprecation`, `all`, `none`, etc. + # @return [String] Default: _Simply `-Xlint` is run, which enables recommended warnings. + # + def java_lint_arg(lint_option) + return '-Xlint' unless lint_option + + "-Xlint:#{lint_option}" + end end end |