Skip to content

Commit 3535141

Browse files
committed
Bumping to Gradle9
1 parent 646ab31 commit 3535141

File tree

4 files changed

+131
-150
lines changed

4 files changed

+131
-150
lines changed

gen-tests.gradle.kts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535

3636
// JAVA
3737

38-
val generateJavaTests by tasks.creating(JavaExec::class) {
38+
val generateJavaTests by tasks.registering(JavaExec::class) {
3939
group = "Generate Tests"
4040
description = "Generates Java classes from the test protos"
4141
classpath = wire
@@ -47,7 +47,7 @@ val generateJavaTests by tasks.creating(JavaExec::class) {
4747
) + PROTOS
4848
}
4949

50-
val generateKotlinClassAmongJavaTests by tasks.creating(JavaExec::class) {
50+
val generateKotlinClassAmongJavaTests by tasks.registering(JavaExec::class) {
5151
group = "Generate Tests"
5252
description = "Generates Kotlin classes from the Java test protos"
5353
classpath = wire
@@ -61,7 +61,7 @@ val generateKotlinClassAmongJavaTests by tasks.creating(JavaExec::class) {
6161

6262
// NO OPTIONS
6363

64-
val generateNoOptionsTests by tasks.creating(JavaExec::class) {
64+
val generateNoOptionsTests by tasks.registering(JavaExec::class) {
6565
group = "Generate Tests"
6666
description = "Generates Java classes with no options from the test protos"
6767
classpath = wire
@@ -155,7 +155,7 @@ val generateGsonAdapterKotlinTests by tasks.creating(JavaExec::class) {
155155
)
156156
}
157157

158-
val generateGsonTests by tasks.creating {
158+
val generateGsonTests by tasks.registering {
159159
group = "Generate Tests"
160160
description = "Generates Java and Kotlin classes that use Gson from the test protos"
161161
dependsOn(
@@ -536,7 +536,7 @@ val generateSwiftProto2Tests by tasks.creating(JavaExec::class) {
536536
)
537537
}
538538

539-
val generateSwiftTests by tasks.creating {
539+
val generateSwiftTests by tasks.registering {
540540
group = "Generate Tests"
541541
description = "Generates Swift classes from the test protos"
542542
if (project.properties.get("swift") != "false") {
@@ -638,7 +638,7 @@ val generateMoshiAdapterKotlinTests by tasks.creating(JavaExec::class) {
638638
)
639639
}
640640

641-
val generateMoshiTests by tasks.creating {
641+
val generateMoshiTests by tasks.registering {
642642
group = "Generate Tests"
643643
description = "Generates Java and Kotlin classes that use Moshi from the test protos"
644644
dependsOn(
@@ -695,7 +695,7 @@ val generateSharedJsonKotlinTests by tasks.creating(JavaExec::class) {
695695
)
696696
}
697697

698-
val generateSharedJson by tasks.creating {
698+
val generateSharedJson by tasks.registering {
699699
group = "Generate Tests"
700700
description = "Generates Java and Kotlin classes for shared JSON tests"
701701
dependsOn(
@@ -704,7 +704,7 @@ val generateSharedJson by tasks.creating {
704704
)
705705
}
706706

707-
val generateTests by tasks.creating {
707+
val generateTests by tasks.registering {
708708
group = "Generate Tests"
709709
description = "Generates all test classes"
710710
dependsOn(

wire-benchmarks/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
sourceSets {
1616
main {
1717
// Adds protobuf generated classes to our source sets.
18-
java.srcDir("$buildDir/generated/source/proto/main/java")
18+
java.srcDir(layout.buildDirectory.dir("generated/source/proto/main/java"))
1919
}
2020
}
2121

wire-reflector/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
val main by sourceSets.getting {
7-
java.srcDir("$buildDir/wire")
7+
java.srcDir(layout.buildDirectory.dir("wire"))
88
}
99

1010
dependencies {
@@ -35,7 +35,7 @@ val generateReflectionProtos by tasks.registering(JavaExec::class) {
3535
classpath = generateReflectionProtosClasspath
3636
args(
3737
"--proto_path=$projectDir/src/main/resources",
38-
"--kotlin_out=$buildDir/wire",
38+
"--kotlin_out=${layout.buildDirectory.get()}/wire",
3939
"grpc/reflection/v1alpha/reflection.proto"
4040
)
4141
}

wire-tests/build.gradle.kts

Lines changed: 120 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
2+
import org.gradle.kotlin.dsl.sourceSets
23
import org.jetbrains.kotlin.gradle.dsl.JsModuleKind
4+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
5+
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
6+
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
37
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
48

59
plugins {
@@ -9,44 +13,58 @@ plugins {
913

1014
kotlin {
1115
applyDefaultHierarchyTemplate()
16+
registerJavaTest("javaTest") {
17+
java.srcDir("src/jvmJavaTest/proto-java")
18+
java.srcDir("src/jvmJavaTest/proto-kotlin")
19+
}
20+
21+
registerJavaTest("javaNoOptionsTest") {
22+
java.srcDir("src/jvmJavaNoOptionsTest/proto-java")
23+
}
24+
25+
registerJavaTest("javaCompactTest") {
26+
java.srcDir("src/jvmJavaCompactTest/proto-java")
27+
}
28+
29+
registerJavaTest("javaPrunedTest") {
30+
java.srcDir("src/jvmJavaPrunedTest/proto-java")
31+
}
32+
33+
registerJavaTest("javaAndroidTest") {
34+
java.srcDir("src/jvmJavaAndroidTest/proto-java")
35+
}
36+
37+
registerJavaTest("javaAndroidCompactTest") {
38+
java.srcDir("src/jvmJavaAndroidCompactTest/proto-java")
39+
}
40+
41+
registerJavaTest("jsonJavaTest") {
42+
java.srcDir("src/jvmJsonTest/kotlin")
43+
java.srcDir("src/jvmJsonJavaTest/proto-java")
44+
}
45+
46+
registerJavaTest("jsonKotlinTest") {
47+
java.srcDir("src/jvmJsonTest/kotlin")
48+
java.srcDir("src/jvmJsonKotlinTest/proto-kotlin")
49+
}
50+
1251
jvm {
13-
val kotlinInteropTest by compilations.creating {
14-
defaultSourceSet {
15-
kotlin.srcDir("src/jvmKotlinInteropTest/proto-kotlin")
16-
dependencies {
17-
implementation(projects.wireRuntime)
18-
implementation(libs.kotlin.test.junit)
19-
implementation(libs.assertk)
20-
implementation(libs.kotlin.reflect)
21-
}
22-
}
23-
val jvmKotlinInteropTest by tasks.registering(Test::class) {
24-
classpath = compileDependencyFiles + runtimeDependencyFiles + output.allOutputs
25-
testClassesDirs = output.classesDirs
26-
}
27-
val jvmTest by tasks.getting {
28-
dependsOn(jvmKotlinInteropTest)
29-
dependencies {
30-
implementation(projects.wireGrpcClient)
31-
}
52+
registerKotlinTest("kotlinInteropTest") {
53+
kotlin.srcDir("src/jvmKotlinInteropTest/proto-kotlin")
54+
dependencies {
55+
implementation(projects.wireRuntime)
56+
implementation(libs.kotlin.test.junit)
57+
implementation(libs.assertk)
58+
implementation(libs.kotlin.reflect)
3259
}
3360
}
34-
val kotlinAndroidTest by compilations.creating {
35-
defaultSourceSet {
61+
registerKotlinTest("kotlinAndroidTest") {
3662
kotlin.srcDir("src/jvmKotlinAndroidTest/proto-kotlin")
3763
dependencies {
3864
implementation(projects.wireRuntime)
3965
compileOnly(libs.android)
4066
implementation(libs.kotlin.test.junit)
4167
implementation(libs.assertk)
42-
}
43-
}
44-
val jvmKotlinAndroidTest by tasks.registering(Test::class) {
45-
classpath = compileDependencyFiles + runtimeDependencyFiles + output.allOutputs
46-
testClassesDirs = output.classesDirs
47-
}
48-
val jvmTest by tasks.getting {
49-
dependsOn(jvmKotlinAndroidTest)
5068
}
5169
}
5270
val kotlinProtoReader32Test by compilations.creating {
@@ -132,127 +150,90 @@ kotlin {
132150

133151
val jvmTest by tasks.getting
134152

135-
for (target in kotlin.targets.matching { it.platformType.name == "jvm" }) {
136-
target.project.sourceSets {
137-
val test by getting {
138-
java.srcDir("src/jvmTest/proto-java")
139-
}
140-
141-
val javaTest by creating {
142-
java.srcDir("src/jvmJavaTest/proto-java")
143-
java.srcDir("src/jvmJavaTest/proto-kotlin")
144-
}
145-
val jvmJavaTest by tasks.registering(Test::class) {
146-
classpath = javaTest.runtimeClasspath
147-
testClassesDirs = javaTest.output.classesDirs
148-
}
149-
jvmTest.dependsOn(jvmJavaTest)
150-
151-
val javaNoOptionsTest by creating {
152-
java.srcDir("src/jvmJavaNoOptionsTest/proto-java")
153-
}
154-
val jvmJavaNoOptionsTest by tasks.registering(Test::class) {
155-
classpath = javaNoOptionsTest.runtimeClasspath
156-
testClassesDirs = javaNoOptionsTest.output.classesDirs
157-
}
158-
jvmTest.dependsOn(jvmJavaNoOptionsTest)
159-
160-
val javaCompactTest by creating {
161-
java.srcDir("src/jvmJavaCompactTest/proto-java")
162-
}
163-
val jvmJavaCompactTest by tasks.registering(Test::class) {
164-
classpath = javaCompactTest.runtimeClasspath
165-
testClassesDirs = javaCompactTest.output.classesDirs
153+
fun KotlinJvmTarget.registerKotlinTest(
154+
name: String,
155+
configureSourceSet: KotlinSourceSet.() -> kotlin.Unit,
156+
) {
157+
val kotlinInteropTest = compilations.create(name) {
158+
defaultSourceSet {
159+
configureSourceSet()
166160
}
167-
jvmTest.dependsOn(jvmJavaCompactTest)
168-
169-
val javaPrunedTest by creating {
170-
java.srcDir("src/jvmJavaPrunedTest/proto-java")
171-
}
172-
val jvmJavaPrunedTest by tasks.registering(Test::class) {
173-
classpath = javaPrunedTest.runtimeClasspath
174-
testClassesDirs = javaPrunedTest.output.classesDirs
175-
}
176-
jvmTest.dependsOn(jvmJavaPrunedTest)
177-
178-
val javaAndroidTest by creating {
179-
java.srcDir("src/jvmJavaAndroidTest/proto-java")
161+
val jvmKotlinInteropTest by tasks.registering(Test::class) {
162+
classpath = compileDependencyFiles + runtimeDependencyFiles + output.allOutputs
163+
testClassesDirs = output.classesDirs
180164
}
181-
val jvmJavaAndroidTest by tasks.registering(Test::class) {
182-
classpath = javaAndroidTest.runtimeClasspath
183-
testClassesDirs = javaAndroidTest.output.classesDirs
184-
}
185-
jvmTest.dependsOn(jvmJavaAndroidTest)
186-
187-
val javaAndroidCompactTest by creating {
188-
java.srcDir("src/jvmJavaAndroidCompactTest/proto-java")
189-
}
190-
val jvmJavaAndroidCompactTest by tasks.registering(Test::class) {
191-
classpath = javaAndroidCompactTest.runtimeClasspath
192-
testClassesDirs = javaAndroidCompactTest.output.classesDirs
165+
val jvmTest by tasks.getting {
166+
dependsOn(jvmKotlinInteropTest)
167+
dependencies {
168+
implementation(projects.wireGrpcClient)
169+
}
193170
}
194-
jvmTest.dependsOn(jvmJavaAndroidCompactTest)
171+
}
172+
}
195173

196-
val jsonJavaTest by creating {
197-
java.srcDir("src/jvmJsonTest/kotlin")
198-
java.srcDir("src/jvmJsonJavaTest/proto-java")
174+
fun KotlinMultiplatformExtension.registerJavaTest(
175+
name: String, // Like jvmJavaTest
176+
configureSourceSet: SourceSet.() -> Unit,
177+
) {
178+
sourceSets {
179+
jvm { }
180+
}
181+
project.sourceSets {
182+
val sourceSet: SourceSet = create(name) {
183+
configureSourceSet()
199184
}
200-
val jvmJsonJavaTest by tasks.registering(Test::class) {
201-
classpath = jsonJavaTest.runtimeClasspath
202-
testClassesDirs = jsonJavaTest.output.classesDirs
185+
val taskProvider = tasks.register(name, Test::class) {
186+
classpath = sourceSet.runtimeClasspath
187+
testClassesDirs = sourceSet.output.classesDirs
203188
}
204-
jvmTest.dependsOn(jvmJsonJavaTest)
189+
jvmTest.dependsOn(taskProvider)
190+
}
191+
}
205192

206-
val jsonKotlinTest by creating {
207-
java.srcDir("src/jvmJsonTest/kotlin")
208-
java.srcDir("src/jvmJsonKotlinTest/proto-kotlin")
209-
}
210-
val jvmJsonKotlinTest by tasks.registering(Test::class) {
211-
classpath = jsonKotlinTest.runtimeClasspath
212-
testClassesDirs = jsonKotlinTest.output.classesDirs
213-
}
214-
jvmTest.dependsOn(jvmJsonKotlinTest)
193+
sourceSets {
194+
val jvmTest by getting {
195+
java.srcDir("src/jvmTest/proto-java")
196+
}
197+
}
215198

216-
dependencies {
217-
add("javaTestImplementation", projects.wireRuntime)
218-
add("javaNoOptionsTestImplementation", projects.wireRuntime)
219-
add("javaCompactTestImplementation", projects.wireRuntime)
220-
add("javaPrunedTestImplementation", projects.wireRuntime)
221-
add("javaAndroidTestImplementation", projects.wireRuntime)
222-
add("javaAndroidCompactTestImplementation", projects.wireRuntime)
223-
add("jsonJavaTestImplementation", projects.wireRuntime)
224-
add("jsonKotlinTestImplementation", projects.wireRuntime)
199+
dependencies {
200+
add("javaTestImplementation", projects.wireRuntime)
201+
add("javaNoOptionsTestImplementation", projects.wireRuntime)
202+
add("javaCompactTestImplementation", projects.wireRuntime)
203+
add("javaPrunedTestImplementation", projects.wireRuntime)
204+
add("javaAndroidTestImplementation", projects.wireRuntime)
205+
// add("javaAndroidCompactTestImplementation", projects.wireRuntime)
206+
add("jsonJavaTestImplementation", projects.wireRuntime)
207+
add("jsonKotlinTestImplementation", projects.wireRuntime)
225208

226-
add("javaAndroidTestCompileOnly", libs.android)
227-
add("javaAndroidCompactTestCompileOnly", libs.android)
228-
add("javaAndroidTestCompileOnly", libs.androidx.annotations)
229-
add("javaAndroidCompactTestCompileOnly", libs.androidx.annotations)
209+
add("javaAndroidTestCompileOnly", libs.android)
210+
// add("javaAndroidCompactTestCompileOnly", libs.android)
211+
add("javaAndroidTestCompileOnly", libs.androidx.annotations)
212+
// add("javaAndroidCompactTestCompileOnly", libs.androidx.annotations)
230213

231-
add("javaTestImplementation", libs.kotlin.test.junit)
232-
add("javaTestImplementation", libs.assertk)
233-
add("javaTestImplementation", libs.jimfs)
234-
add("javaTestImplementation", libs.truth)
235-
add("jsonJavaTestImplementation", projects.wireMoshiAdapter)
236-
add("jsonJavaTestImplementation", projects.wireGsonSupport)
237-
add("jsonJavaTestImplementation", projects.wireTestUtils)
238-
add("jsonJavaTestImplementation", libs.kotlin.test.junit)
239-
add("jsonJavaTestImplementation", libs.assertk)
240-
add("jsonJavaTestImplementation", libs.jimfs)
241-
add("jsonJavaTestImplementation", libs.truth)
242-
add("jsonKotlinTestImplementation", projects.wireMoshiAdapter)
243-
add("jsonKotlinTestImplementation", projects.wireGsonSupport)
244-
add("jsonKotlinTestImplementation", projects.wireTestUtils)
245-
add("jsonKotlinTestImplementation", libs.kotlin.test.junit)
246-
add("jsonKotlinTestImplementation", libs.assertk)
247-
add("jsonKotlinTestImplementation", libs.jimfs)
248-
add("jsonKotlinTestImplementation", libs.truth)
214+
add("javaTestImplementation", libs.kotlin.test.junit)
215+
add("javaTestImplementation", libs.assertk)
216+
add("javaTestImplementation", libs.jimfs)
217+
add("javaTestImplementation", libs.truth)
218+
add("jsonJavaTestImplementation", projects.wireMoshiAdapter)
219+
add("jsonJavaTestImplementation", projects.wireGsonSupport)
220+
add("jsonJavaTestImplementation", projects.wireTestUtils)
221+
add("jsonJavaTestImplementation", libs.kotlin.test.junit)
222+
add("jsonJavaTestImplementation", libs.assertk)
223+
add("jsonJavaTestImplementation", libs.jimfs)
224+
add("jsonJavaTestImplementation", libs.truth)
225+
add("jsonKotlinTestImplementation", projects.wireMoshiAdapter)
226+
add("jsonKotlinTestImplementation", projects.wireGsonSupport)
227+
add("jsonKotlinTestImplementation", projects.wireTestUtils)
228+
add("jsonKotlinTestImplementation", libs.kotlin.test.junit)
229+
add("jsonKotlinTestImplementation", libs.assertk)
230+
add("jsonKotlinTestImplementation", libs.jimfs)
231+
add("jsonKotlinTestImplementation", libs.truth)
249232

250-
add("jvmJavaTestImplementation", projects.wireMoshiAdapter)
251-
add("jvmJavaTestImplementation", libs.kotlin.reflect)
252-
add("jvmJavaTestImplementation", libs.moshi)
253-
add("jvmJavaTestImplementation", libs.moshiKotlin)
254-
}
255-
}
233+
// add("jvmJavaTestImplementation", projects.wireMoshiAdapter)
234+
// add("jvmJavaTestImplementation", libs.kotlin.reflect)
235+
// add("jvmJavaTestImplementation", libs.moshi)
236+
// add("jvmJavaTestImplementation", libs.moshiKotlin)
256237
}
257238

258239
configure<SpotlessExtension> {

0 commit comments

Comments
 (0)