File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,32 @@ import java.io.File
1818import org.gradle.api.Plugin
1919import org.gradle.api.Project
2020import org.gradle.api.Task
21+ import org.gradle.internal.jvm.Jvm
22+ import kotlin.system.exitProcess
2123
2224class ReactPlugin : Plugin <Project > {
2325 override fun apply (project : Project ) {
26+ checkJvmVersion()
2427 val extension = project.extensions.create(" react" , ReactExtension ::class .java, project)
2528 applyAppPlugin(project, extension)
2629 applyCodegenPlugin(project, extension)
2730 }
2831
32+ private fun checkJvmVersion (){
33+ val jvmVersion = Jvm .current()?.javaVersion?.majorVersion
34+ if ((jvmVersion?.toIntOrNull() ? : 0 ) <= 8 ) {
35+ println (" \n\n\n " )
36+ println (" **************************************************************************************************************" )
37+ println (" \n\n " )
38+ println (" ERROR: requires JDK11 or higher." )
39+ println (" Incompatible major version detected: '" + jvmVersion + " '" )
40+ println (" \n\n " )
41+ println (" **************************************************************************************************************" )
42+ println (" \n\n\n " )
43+ exitProcess(1 )
44+ }
45+ }
46+
2947 private fun applyAppPlugin (project : Project , config : ReactExtension ) {
3048 project.afterEvaluate {
3149 if (config.applyAppPlugin.getOrElse(false )) {
Original file line number Diff line number Diff line change 66 */
77
88import org.apache.tools.ant.taskdefs.condition.Os
9+ import org.gradle.internal.jvm.Jvm
910
1011def config = project. hasProperty(" react" ) ? project. react : [:];
1112
@@ -129,6 +130,19 @@ android {
129130 }
130131}
131132
133+ def jvmVersion = Jvm . current(). javaVersion. majorVersion
134+ if (jvmVersion. toInteger() <= 8 ) {
135+ println " \n\n\n "
136+ println " **************************************************************************************************************"
137+ println " \n\n "
138+ println " ERROR: requires JDK11 or higher."
139+ println " Incompatible major version detected: '" + jvmVersion + " '"
140+ println " \n\n "
141+ println " **************************************************************************************************************"
142+ println " \n\n\n "
143+ System . exit(1 )
144+ }
145+
132146afterEvaluate {
133147 def isAndroidLibrary = plugins. hasPlugin(" com.android.library" )
134148 def variants = isAndroidLibrary ? android. libraryVariants : android. applicationVariants
You can’t perform that action at this time.
0 commit comments