Skip to content

Commit e4d77b7

Browse files
committed
[Gradle] Add an integration test for KT-59256
(cherry picked from commit b23b9ab)
1 parent d9e4796 commit e4d77b7

File tree

4 files changed

+61
-0
lines changed
  • libraries/tools/kotlin-gradle-plugin-integration-tests/src/test

4 files changed

+61
-0
lines changed

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,4 +1271,15 @@ open class Kapt3IT : Kapt3BaseIT() {
12711271
}
12721272
}
12731273
}
1274+
1275+
@DisplayName("KT-59256: kapt generated files are included into the test runtime classpath")
1276+
@GradleTest
1277+
@Disabled("The fix is not yet provided")
1278+
fun testKaptGeneratedInTestRuntimeClasspath(gradleVersion: GradleVersion) {
1279+
project("kapt-in-test-runtime-classpath".withPrefix, gradleVersion) {
1280+
build("test") {
1281+
assertFileInProjectExists("build/tmp/kapt3/classes/main/META-INF/services/com.example.SomeInterface")
1282+
}
1283+
}
1284+
}
12741285
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id("org.jetbrains.kotlin.jvm")
3+
id("org.jetbrains.kotlin.kapt")
4+
}
5+
6+
repositories {
7+
mavenLocal()
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
13+
implementation("com.google.auto.service:auto-service:1.0-rc3")
14+
kapt("com.google.auto.service:auto-service:1.0-rc3")
15+
testImplementation'junit:junit:4.13.2'
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package com.example
7+
8+
import com.google.auto.service.AutoService
9+
import javax.annotation.processing.AbstractProcessor
10+
import javax.annotation.processing.Processor
11+
import javax.annotation.processing.RoundEnvironment
12+
import javax.lang.model.element.TypeElement
13+
import javax.tools.Diagnostic.Kind.MANDATORY_WARNING
14+
15+
interface SomeInterface
16+
17+
@AutoService(SomeInterface::class)
18+
class SomeService : SomeInterface
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package com.example
7+
8+
import org.junit.Test
9+
import java.util.ServiceLoader
10+
11+
class Tests {
12+
@Test
13+
fun testServiceLoading() {
14+
ServiceLoader.load(SomeInterface::class.java).singleOrNull() ?: error("Cannot load SomeInterface implementation, perhaps the service declaration couldn't be found")
15+
}
16+
}

0 commit comments

Comments
 (0)