summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Rosický <pdahorek@seznam.cz>2023-03-30 02:10:29 +0200
committerGitHub <noreply@github.com>2023-03-30 09:10:29 +0900
commit8e798148ff92bb0fa1a326f928747278c17a190b (patch)
tree08cc99c5de49630721f19a143686209bff750a1f
parent89df143434599a29c5c2f70904d7ad63927b2d2d (diff)
downloadrake-compiler-8e798148ff92bb0fa1a326f928747278c17a190b.tar.gz
Don't use --release flag on Java 8 (#213)
this allows using ``` Rake::JavaExtensionTask.new("name", gemspec) do |ext| ext.release = '8' end ``` on Java 8 (for building the gem), because the flag is available since Java 9, see https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html this flag is for backward compatibility, so it's safe to just skip it if we can't use it. relates to https://github.com/puma/puma/pull/3109 https://github.com/socketry/nio4r/pull/292
-rw-r--r--lib/rake/javaextensiontask.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb
index 5603afc..7ad9095 100644
--- a/lib/rake/javaextensiontask.rb
+++ b/lib/rake/javaextensiontask.rb
@@ -212,7 +212,7 @@ execute the Rake compilation task using the JRuby interpreter.
end
def java_target_args
- if @release
+ if @release && release_flag_supported?
["--release=#{@release}"]
else
["-target", @target_version, "-source", @source_version]
@@ -303,5 +303,11 @@ execute the Rake compilation task using the JRuby interpreter.
"-Xlint:#{@lint_option}"
end
+
+ def release_flag_supported?
+ return true unless RUBY_PLATFORM =~ /java/
+
+ Gem::Version.new(Java::java.lang.System.getProperty('java.version')) >= Gem::Version.new("9")
+ end
end
end