[Gradle] Increase max Kotlin daemon heap size to 2g for all kapt tests
Apparently, they all require more than 1g of heap size to run kapt.
This commit is contained in:
committed by
Space Team
parent
1183244455
commit
55f6614b66
+43
-17
@@ -22,13 +22,16 @@ import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_JVM_INCREMENTAL_COMPILATION_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.testbase.project as testBaseProject
|
||||
import org.jetbrains.kotlin.gradle.util.addBeforeSubstring
|
||||
import org.jetbrains.kotlin.gradle.util.checkedReplace
|
||||
import org.jetbrains.kotlin.gradle.util.testResolveAllConfigurations
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.OS
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.zip.ZipFile
|
||||
import java.util.zip.ZipOutputStream
|
||||
import kotlin.io.path.appendText
|
||||
@@ -62,6 +65,38 @@ abstract class Kapt3BaseIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
// All Kapt projects require around 2.5g of heap size for Kotlin daemon
|
||||
@OptIn(EnvironmentalVariablesOverride::class)
|
||||
protected fun Kapt3BaseIT.project(
|
||||
projectName: String,
|
||||
gradleVersion: GradleVersion,
|
||||
buildOptions: BuildOptions = defaultBuildOptions,
|
||||
forceOutput: Boolean = false,
|
||||
enableBuildScan: Boolean = false,
|
||||
addHeapDumpOptions: Boolean = true,
|
||||
enableGradleDebug: Boolean = false,
|
||||
enableKotlinDaemonMemoryLimitInMb: Int? = 2512,
|
||||
projectPathAdditionalSuffix: String = "",
|
||||
buildJdk: File? = null,
|
||||
localRepoDir: Path? = null,
|
||||
environmentVariables: EnvironmentalVariables = EnvironmentalVariables(),
|
||||
test: TestProject.() -> Unit = {},
|
||||
): TestProject = testBaseProject(
|
||||
projectName = projectName,
|
||||
gradleVersion = gradleVersion,
|
||||
buildOptions = buildOptions,
|
||||
forceOutput = forceOutput,
|
||||
enableBuildScan = enableBuildScan,
|
||||
addHeapDumpOptions = addHeapDumpOptions,
|
||||
enableGradleDebug = enableGradleDebug,
|
||||
enableKotlinDaemonMemoryLimitInMb = enableKotlinDaemonMemoryLimitInMb,
|
||||
projectPathAdditionalSuffix = projectPathAdditionalSuffix,
|
||||
buildJdk = buildJdk,
|
||||
localRepoDir = localRepoDir,
|
||||
environmentVariables = environmentVariables,
|
||||
test = test,
|
||||
)
|
||||
|
||||
protected val String.withPrefix get() = "kapt2/$this"
|
||||
}
|
||||
|
||||
@@ -152,7 +187,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("Kapt is skipped when no annotation processors are added")
|
||||
@GradleTest
|
||||
fun testKaptSkipped(gradleVersion: GradleVersion) {
|
||||
project("kaptSkipped".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("kaptSkipped".withPrefix, gradleVersion) {
|
||||
build("build") {
|
||||
assertTasksSkipped(":kaptGenerateStubsKotlin", ":kaptKotlin")
|
||||
assertOutputContains("No annotation processors provided. Skip KAPT processing.")
|
||||
@@ -178,7 +213,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build(":kaptCustomKotlin", forceOutput = true) {
|
||||
build(":kaptCustomKotlin") {
|
||||
assertTasksExecuted(":kaptCustomKotlin")
|
||||
assertOutputDoesNotContain("No annotation processors provided. Skip KAPT processing.")
|
||||
assertOutputContains("Annotation processors: example.ExampleAnnotationProcessor, example.KotlinFilerGeneratingProcessor")
|
||||
@@ -189,7 +224,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("Kapt is not skipped when all annotation processors are declared as indirect dependencies")
|
||||
@GradleTest
|
||||
fun testKaptNotSkippedWithIndirectDependencies(gradleVersion: GradleVersion) {
|
||||
project("indirectDependencies".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("indirectDependencies".withPrefix, gradleVersion) {
|
||||
build("assemble") {
|
||||
assertTasksExecuted(":kaptGenerateStubsKotlin", ":kaptKotlin")
|
||||
}
|
||||
@@ -206,7 +241,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
) {
|
||||
//language=Groovy
|
||||
buildGradle.appendText(
|
||||
@@ -237,7 +271,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048
|
||||
) {
|
||||
//language=Groovy
|
||||
buildGradle.appendText(
|
||||
@@ -366,7 +399,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("Kapt tasks is up-to-date on the second run")
|
||||
@GradleTest
|
||||
fun testSimple(gradleVersion: GradleVersion) {
|
||||
project("simple".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("simple".withPrefix, gradleVersion) {
|
||||
|
||||
build("build") {
|
||||
assertKaptSuccessful()
|
||||
@@ -580,7 +613,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"incrementalRebuild".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
buildOptions = defaultBuildOptions.copy(incremental = true)
|
||||
) {
|
||||
val generatedSrc = "build/generated/source/kapt/main"
|
||||
@@ -616,7 +648,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
buildOptions = defaultBuildOptions.copy(incremental = true)
|
||||
) {
|
||||
val internalDummyKt = javaSourcesDir().resolve("foo/InternalDummy.kt")
|
||||
@@ -665,7 +696,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
val arg = "-Xsuppress-version-warnings"
|
||||
@@ -690,7 +720,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("generates Kotlin code")
|
||||
@GradleTest
|
||||
fun testOutputKotlinCode(gradleVersion: GradleVersion) {
|
||||
project("kaptOutputKotlinCode".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("kaptOutputKotlinCode".withPrefix, gradleVersion) {
|
||||
build("build") {
|
||||
assertKaptSuccessful()
|
||||
assertFileExists(projectPath.resolve("build/generated/source/kapt/main/example/TestClassCustomized.java"))
|
||||
@@ -704,7 +734,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("location mapping is working as expected")
|
||||
@GradleTest
|
||||
fun testLocationMapping(gradleVersion: GradleVersion) {
|
||||
project("locationMapping".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("locationMapping".withPrefix, gradleVersion) {
|
||||
val regex = "((Test\\.java)|(test\\.kt)):(\\d+): error: GenError element".toRegex()
|
||||
|
||||
fun BuildResult.getErrorMessages(): String =
|
||||
@@ -836,7 +866,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("up-to-date checks are working")
|
||||
@GradleTest
|
||||
fun testKaptAvoidance(gradleVersion: GradleVersion) {
|
||||
project("kaptAvoidance".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("kaptAvoidance".withPrefix, gradleVersion) {
|
||||
|
||||
subProject("app").buildGradle.modify {
|
||||
"$it\n\nkapt.includeCompileClasspath = true"
|
||||
@@ -1091,7 +1121,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"jpms-module".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
) {
|
||||
build("assemble") {
|
||||
assertTasksExecuted(":kaptKotlin", ":kaptGenerateStubsKotlin", ":compileKotlin", ":compileJava")
|
||||
@@ -1122,7 +1151,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"incrementalRebuild".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
buildOptions = defaultBuildOptions.withConfigurationCache
|
||||
) {
|
||||
build("assemble")
|
||||
@@ -1192,7 +1220,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
@DisplayName("Generated sources attached to KotlinSourceSet are also used by generate stubs task")
|
||||
@GradleTest
|
||||
fun testGeneratedSourcesUsedInGenerateStubsTask(gradleVersion: GradleVersion) {
|
||||
project("generatedSources".withPrefix, gradleVersion, enableKotlinDaemonMemoryLimitInMb = 2048) {
|
||||
project("generatedSources".withPrefix, gradleVersion) {
|
||||
build("assemble")
|
||||
}
|
||||
}
|
||||
@@ -1225,7 +1253,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
buildGradle.appendText(
|
||||
@@ -1414,7 +1441,6 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
project(
|
||||
"simple".withPrefix,
|
||||
gradleVersion,
|
||||
enableKotlinDaemonMemoryLimitInMb = 2048,
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user