Skip to content

Commit 13ea273

Browse files
authored
[0.74] Stub com.facebook.react.settings on 0.74 (#45720)
1 parent b9f7005 commit 13ea273

File tree

61 files changed

+172
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+172
-78
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
react-native-gradle-plugin/build/
3+
settings-plugin/build/

packages/react-native-gradle-plugin/build.gradle.kts

+2-75
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import org.gradle.api.internal.classpath.ModuleRegistry
9-
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
10-
import org.gradle.configurationcache.extensions.serviceOf
11-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
12-
138
plugins {
14-
alias(libs.plugins.kotlin.jvm)
9+
alias(libs.plugins.kotlin.jvm).apply(false)
1510
id("java-gradle-plugin")
16-
}
17-
18-
repositories {
19-
google()
20-
mavenCentral()
21-
}
22-
23-
gradlePlugin {
24-
plugins {
25-
create("react") {
26-
id = "com.facebook.react"
27-
implementationClass = "com.facebook.react.ReactPlugin"
28-
}
29-
create("reactrootproject") {
30-
id = "com.facebook.react.rootproject"
31-
implementationClass = "com.facebook.react.ReactRootProjectPlugin"
32-
}
33-
}
34-
}
35-
36-
group = "com.facebook.react"
37-
38-
dependencies {
39-
implementation(gradleApi())
40-
41-
// The KGP/AGP version is defined by React Native Gradle plugin.
42-
// Therefore we specify an implementation dep rather than a compileOnly.
43-
implementation(libs.kotlin.gradle.plugin)
44-
implementation(libs.android.gradle.plugin)
45-
46-
implementation(libs.gson)
47-
implementation(libs.guava)
48-
implementation(libs.javapoet)
49-
50-
testImplementation(libs.junit)
51-
52-
testRuntimeOnly(
53-
files(
54-
serviceOf<ModuleRegistry>()
55-
.getModule("gradle-tooling-api-builders")
56-
.classpath
57-
.asFiles
58-
.first()))
59-
}
60-
61-
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
62-
// error first. Instead we produce a Java 11-compatible Gradle Plugin, so that AGP can print their
63-
// nice message showing that JDK 11 (or 17) is required first
64-
java { targetCompatibility = JavaVersion.VERSION_11 }
65-
66-
kotlin { jvmToolchain(17) }
67-
68-
tasks.withType<KotlinCompile>().configureEach {
69-
kotlinOptions {
70-
apiVersion = "1.6"
71-
// See comment above on JDK 11 support
72-
jvmTarget = "11"
73-
allWarningsAsErrors = true
74-
}
75-
}
76-
77-
tasks.withType<Test>().configureEach {
78-
testLogging {
79-
exceptionFormat = TestExceptionFormat.FULL
80-
showExceptions = true
81-
showCauses = true
82-
showStackTraces = true
83-
}
84-
}
11+
}

packages/react-native-gradle-plugin/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"gradle",
3030
"gradlew",
3131
"gradlew.bat",
32-
"src/main",
33-
"README.md"
32+
"README.md",
33+
"react-native-gradle-plugin",
34+
"settings-plugin"
3435
]
3536
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import org.gradle.api.internal.classpath.ModuleRegistry
9+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
10+
import org.gradle.configurationcache.extensions.serviceOf
11+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
12+
13+
plugins {
14+
alias(libs.plugins.kotlin.jvm)
15+
id("java-gradle-plugin")
16+
}
17+
18+
repositories {
19+
google()
20+
mavenCentral()
21+
}
22+
23+
gradlePlugin {
24+
plugins {
25+
create("react") {
26+
id = "com.facebook.react"
27+
implementationClass = "com.facebook.react.ReactPlugin"
28+
}
29+
create("reactrootproject") {
30+
id = "com.facebook.react.rootproject"
31+
implementationClass = "com.facebook.react.ReactRootProjectPlugin"
32+
}
33+
}
34+
}
35+
36+
group = "com.facebook.react"
37+
38+
dependencies {
39+
implementation(gradleApi())
40+
41+
// The KGP/AGP version is defined by React Native Gradle plugin.
42+
// Therefore we specify an implementation dep rather than a compileOnly.
43+
implementation(libs.kotlin.gradle.plugin)
44+
implementation(libs.android.gradle.plugin)
45+
46+
implementation(libs.gson)
47+
implementation(libs.guava)
48+
implementation(libs.javapoet)
49+
50+
testImplementation(libs.junit)
51+
52+
testRuntimeOnly(
53+
files(
54+
serviceOf<ModuleRegistry>()
55+
.getModule("gradle-tooling-api-builders")
56+
.classpath
57+
.asFiles
58+
.first()))
59+
}
60+
61+
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
62+
// error first. Instead we produce a Java 11-compatible Gradle Plugin, so that AGP can print their
63+
// nice message showing that JDK 11 (or 17) is required first
64+
java { targetCompatibility = JavaVersion.VERSION_11 }
65+
66+
kotlin { jvmToolchain(17) }
67+
68+
tasks.withType<KotlinCompile>().configureEach {
69+
kotlinOptions {
70+
apiVersion = "1.6"
71+
// See comment above on JDK 11 support
72+
jvmTarget = "11"
73+
allWarningsAsErrors = true
74+
}
75+
}
76+
77+
tasks.withType<Test>().configureEach {
78+
testLogging {
79+
exceptionFormat = TestExceptionFormat.FULL
80+
showExceptions = true
81+
showCauses = true
82+
showStackTraces = true
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
9+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
10+
11+
plugins {
12+
alias(libs.plugins.kotlin.jvm)
13+
id("java-gradle-plugin")
14+
}
15+
16+
repositories {
17+
google()
18+
mavenCentral()
19+
}
20+
21+
gradlePlugin {
22+
plugins {
23+
create("react.settings") {
24+
id = "com.facebook.react.settings"
25+
implementationClass = "com.facebook.react.ReactSettingsPlugin"
26+
}
27+
}
28+
}
29+
30+
group = "com.facebook.react"
31+
32+
dependencies {
33+
implementation(gradleApi())
34+
}
35+
36+
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
37+
// error first. Instead we produce a Java 11-compatible Gradle Plugin, so that AGP can print their
38+
// nice message showing that JDK 11 (or 17) is required first
39+
java { targetCompatibility = JavaVersion.VERSION_11 }
40+
41+
kotlin { jvmToolchain(17) }
42+
43+
tasks.withType<KotlinCompile>().configureEach {
44+
kotlinOptions {
45+
apiVersion = "1.6"
46+
// See comment above on JDK 11 support
47+
jvmTarget = "11"
48+
allWarningsAsErrors = true
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react
9+
10+
import org.gradle.api.Plugin
11+
import org.gradle.api.initialization.Settings
12+
13+
/**
14+
* This is a stub of the com.facebook.react.settings plugin.
15+
*
16+
* The plugin got added in 0.75, but to make it easier for 0.74 users to upgrade to 0.75, we're
17+
* creating a stub plugin that does nothing. This way, users can include a `id("com.facebook.react.settings")`
18+
* in their settings.gradle file without causing a build failure on 0.74.
19+
*/
20+
class ReactSettingsPlugin : Plugin<Settings> {
21+
override fun apply(settings: Settings) {
22+
// Do nothing, just register the plugin.
23+
}
24+
}

packages/react-native-gradle-plugin/settings.gradle.kts

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ pluginManagement {
1515

1616
plugins { id("org.gradle.toolchains.foojay-resolver-convention").version("0.5.0") }
1717

18-
rootProject.name = "react-native-gradle-plugin"
18+
include(
19+
":react-native-gradle-plugin",
20+
":settings-plugin",
21+
)
22+
23+
rootProject.name = "gradle-plugin-root"

0 commit comments

Comments
 (0)