diff options
author | Stephen George <sfgeorge@users.noreply.github.com> | 2019-10-20 16:42:36 -0500 |
---|---|---|
committer | Sutou Kouhei <kou@clear-code.com> | 2019-10-21 06:42:36 +0900 |
commit | 2b8ada9f162a3ee0af253390b06bbf1bc2e8014a (patch) | |
tree | b3944de14e8891ead1dc0676d6f51b6f0eb27648 /lib/rake | |
parent | 37483c61ba627f105ca6dcc7331641ede72da73d (diff) | |
download | rake-compiler-2b8ada9f162a3ee0af253390b06bbf1bc2e8014a.tar.gz |
Make lint options customizable (#158)
* Make customizable compiler Xlint option for JRuby native extension
* [CS] restructure and fix indentation of (defaults) spec
* Add specs for lint_option
* [DOC] CHANGELOG: stub changelog entry for the next release
* [DOC] CHANGELOG: Make customizable compiler Xlint option for JRuby native extension
* Use "-Xlint" option for JRuby native extension by default.
`javac -help -X`
> -Xlint Enable recommended warnings
Diffstat (limited to 'lib/rake')
-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 |