Test that javac is loaded once when worker is reused
This commit is contained in:
+14
@@ -42,6 +42,20 @@ abstract class Kapt3BaseIT : BaseGradleIT() {
|
|||||||
class Kapt3WorkersIT : Kapt3IT() {
|
class Kapt3WorkersIT : Kapt3IT() {
|
||||||
override fun kaptOptions(): KaptOptions =
|
override fun kaptOptions(): KaptOptions =
|
||||||
super.kaptOptions().copy(useWorkers = true)
|
super.kaptOptions().copy(useWorkers = true)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testJavacIsLoadedOnce() {
|
||||||
|
// todo: actual minimum version is 4.3, but I had some problems. Investigate later.
|
||||||
|
// todo: consider minimum version for the whole class, with Gradle <4.3 all tests duplicate tests without workers
|
||||||
|
val gradleVersionRequired = GradleVersionRequired.AtLeast("4.5.1")
|
||||||
|
|
||||||
|
val project =
|
||||||
|
Project("javacIsLoadedOnce", directoryPrefix = "kapt2", gradleVersionRequirement = gradleVersionRequired)
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertSubstringCount("Loaded com.sun.tools.javac.util.Context from", 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class Kapt3IT : Kapt3BaseIT() {
|
open class Kapt3IT : Kapt3BaseIT() {
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
kapt.verbose=true
|
||||||
|
kapt.workers.log.classloading=true
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
apply plugin: "kotlin"
|
||||||
|
apply plugin: "kotlin-kapt"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||||
|
kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package module1
|
||||||
|
|
||||||
|
@example.ExampleAnnotation
|
||||||
|
class Module1Class {
|
||||||
|
@example.ExampleAnnotation
|
||||||
|
fun testFunction(): Module1ClassGenerated = Module1ClassGenerated()
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
apply plugin: "kotlin"
|
||||||
|
apply plugin: "kotlin-kapt"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(":module1")
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||||
|
kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package module2
|
||||||
|
|
||||||
|
import module1.Module1Class
|
||||||
|
|
||||||
|
@example.ExampleAnnotation
|
||||||
|
class Module2Class {
|
||||||
|
@example.ExampleAnnotation
|
||||||
|
fun testFunction(): Module2ClassGenerated = Module2ClassGenerated()
|
||||||
|
|
||||||
|
fun useModule1Class(m: Module1Class) {
|
||||||
|
m.testFunction()
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
include 'module1', 'module2'
|
||||||
+4
@@ -84,6 +84,10 @@ open class KaptWithoutKotlincTask @Inject constructor(private val workerExecutor
|
|||||||
workerExecutor.submit(KaptExecution::class.java) { config ->
|
workerExecutor.submit(KaptExecution::class.java) { config ->
|
||||||
config.isolationMode = IsolationMode.PROCESS
|
config.isolationMode = IsolationMode.PROCESS
|
||||||
config.params(optionsForWorker, findToolsJar(), kaptClasspath)
|
config.params(optionsForWorker, findToolsJar(), kaptClasspath)
|
||||||
|
if (project.findProperty("kapt.workers.log.classloading") == "true") {
|
||||||
|
// for tests
|
||||||
|
config.forkOptions.jvmArgs("-verbose:class")
|
||||||
|
}
|
||||||
logger.info("Kapt worker classpath: ${config.classpath}")
|
logger.info("Kapt worker classpath: ${config.classpath}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user