[Gradle] Add an integration test for KT-59256
This commit is contained in:
committed by
Space Team
parent
13732881a6
commit
b23b9ab287
+11
@@ -1269,4 +1269,15 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-59256: kapt generated files are included into the test runtime classpath")
|
||||
@GradleTest
|
||||
@Disabled("The fix is not yet provided")
|
||||
fun testKaptGeneratedInTestRuntimeClasspath(gradleVersion: GradleVersion) {
|
||||
project("kapt-in-test-runtime-classpath".withPrefix, gradleVersion) {
|
||||
build("test") {
|
||||
assertFileInProjectExists("build/tmp/kapt3/classes/main/META-INF/services/com.example.SomeInterface")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm")
|
||||
id("org.jetbrains.kotlin.kapt")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
|
||||
implementation("com.google.auto.service:auto-service:1.0-rc3")
|
||||
kapt("com.google.auto.service:auto-service:1.0-rc3")
|
||||
testImplementation'junit:junit:4.13.2'
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package com.example
|
||||
|
||||
import com.google.auto.service.AutoService
|
||||
import javax.annotation.processing.AbstractProcessor
|
||||
import javax.annotation.processing.Processor
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.element.TypeElement
|
||||
import javax.tools.Diagnostic.Kind.MANDATORY_WARNING
|
||||
|
||||
interface SomeInterface
|
||||
|
||||
@AutoService(SomeInterface::class)
|
||||
class SomeService : SomeInterface
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package com.example
|
||||
|
||||
import org.junit.Test
|
||||
import java.util.ServiceLoader
|
||||
|
||||
class Tests {
|
||||
@Test
|
||||
fun testServiceLoading() {
|
||||
ServiceLoader.load(SomeInterface::class.java).singleOrNull() ?: error("Cannot load SomeInterface implementation, perhaps the service declaration couldn't be found")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user