Migrate configuration cache tests to new test DSL.
^KT-45745 In Progress
This commit is contained in:
committed by
TeamCityServer
parent
208422d2ec
commit
4339671457
+38
-33
@@ -5,46 +5,51 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.AGP.AGP_42
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
@DisplayName("Configuration cache in Android project")
|
||||
@KGPBaseTest.GradleTestVersions(minVersion = "6.7.1")
|
||||
class ConfigurationCacheForAndroidIT : AbstractConfigurationCacheIT() {
|
||||
private val androidGradlePluginVersion: AGPVersion
|
||||
get() = AGPVersion.v4_2_0
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(
|
||||
androidVersion = AGP_42
|
||||
)
|
||||
|
||||
override val defaultGradleVersion: GradleVersionRequired
|
||||
get() = GradleVersionRequired.AtLeast("6.7.1")
|
||||
@DisplayName("works in android plus kapt project")
|
||||
@GradleTest
|
||||
fun testAndroidKaptProject(gradleVersion: GradleVersion) {
|
||||
project("kapt2/android-dagger", gradleVersion) {
|
||||
gradleProperties.append("\nkapt.incremental.apt=false")
|
||||
|
||||
override fun defaultBuildOptions() =
|
||||
super.defaultBuildOptions().copy(
|
||||
androidHome = KtTestUtil.findAndroidSdk(),
|
||||
androidGradlePluginVersion = androidGradlePluginVersion,
|
||||
configurationCache = true,
|
||||
configurationCacheProblems = ConfigurationCacheProblems.FAIL
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testAndroidKaptProject() = with(Project("android-dagger", directoryPrefix = "kapt2")) {
|
||||
setupWorkingDir()
|
||||
projectDir.resolve("gradle.properties").appendText("\nkapt.incremental.apt=false")
|
||||
testConfigurationCacheOf(":app:compileDebugKotlin", ":app:kaptDebugKotlin", ":app:kaptGenerateStubsDebugKotlin")
|
||||
testConfigurationCacheOf(
|
||||
":app:compileDebugKotlin",
|
||||
":app:kaptDebugKotlin",
|
||||
":app:kaptGenerateStubsDebugKotlin"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinAndroidProject() = with(Project("AndroidProject")) {
|
||||
setupWorkingDir()
|
||||
testConfigurationCacheOf(":Lib:compileFlavor1DebugKotlin", ":Android:compileFlavor1DebugKotlin")
|
||||
@DisplayName("works in android project")
|
||||
@GradleTest
|
||||
fun testKotlinAndroidProject(gradleVersion: GradleVersion) {
|
||||
project("AndroidProject", gradleVersion) {
|
||||
testConfigurationCacheOf(
|
||||
":Lib:compileFlavor1DebugKotlin",
|
||||
":Android:compileFlavor1DebugKotlin"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinAndroidProjectTests() = with(Project("AndroidIncrementalMultiModule")) {
|
||||
setupWorkingDir()
|
||||
testConfigurationCacheOf(
|
||||
":app:compileDebugAndroidTestKotlin", ":app:compileDebugUnitTestKotlin",
|
||||
buildOptions = defaultBuildOptions().copy(warningMode = WarningMode.Summary)
|
||||
)
|
||||
@DisplayName("works with android tests")
|
||||
@GradleTest
|
||||
fun testKotlinAndroidProjectTests(gradleVersion: GradleVersion) {
|
||||
project("AndroidIncrementalMultiModule", gradleVersion) {
|
||||
testConfigurationCacheOf(
|
||||
":app:compileDebugAndroidTestKotlin",
|
||||
":app:compileDebugUnitTestKotlin"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+222
-169
@@ -5,214 +5,265 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dukat.ExternalsOutputFormat
|
||||
import org.jetbrains.kotlin.gradle.util.createTempDir
|
||||
import org.jetbrains.kotlin.gradle.util.findFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import java.net.URI
|
||||
import java.util.Arrays.asList
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.ExperimentalPathApi
|
||||
import kotlin.io.path.name
|
||||
import kotlin.test.fail
|
||||
|
||||
@DisplayName("Configuration cache")
|
||||
class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
|
||||
@Test
|
||||
fun testSimpleKotlinJvmProject() = with(Project("kotlinProject")) {
|
||||
testConfigurationCacheOf(":compileKotlin")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmWithMavenPublish() = with(Project("kotlinProject")) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().appendText("""
|
||||
apply plugin: "maven-publish"
|
||||
group = "com.example"
|
||||
version = "1.0"
|
||||
publishing.repositories {
|
||||
maven {
|
||||
url = "${'$'}buildDir/repo"
|
||||
}
|
||||
}
|
||||
publishing.publications {
|
||||
maven(MavenPublication) {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
testConfigurationCacheOf(":publishMavenPublicationToMavenRepository", checkUpToDateOnRebuild = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMppWithMavenPublish() = with(transformNativeTestProject("sample-lib", directoryPrefix = "new-mpp-lib-and-app")) {
|
||||
val publishedTargets = listOf("kotlinMultiplatform", "jvm6", "nodeJs")
|
||||
testConfigurationCacheOf(
|
||||
*(publishedTargets.map { ":publish${it.capitalize()}PublicationToMavenRepository" }.toTypedArray()),
|
||||
checkUpToDateOnRebuild = false
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementalKaptProject() = with(Project("kaptIncrementalCompilationProject")) {
|
||||
setupIncrementalAptProject("AGGREGATING")
|
||||
|
||||
testConfigurationCacheOf(
|
||||
":compileKotlin",
|
||||
":kaptKotlin",
|
||||
buildOptions = defaultBuildOptions().copy(
|
||||
incremental = true,
|
||||
kaptOptions = KaptOptions(
|
||||
verbose = true,
|
||||
useWorkers = true,
|
||||
incrementalKapt = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInstantExecution() =
|
||||
// Set min Gradle version to 6.8 because of using DependencyResolutionManagement API to add repositories.
|
||||
with(Project("instantExecution", gradleVersionRequirement = GradleVersionRequired.AtLeast("6.8"))) {
|
||||
testConfigurationCacheOf("assemble", executedTaskNames = asList(":lib-project:compileKotlin"))
|
||||
@DisplayName("works in simple Kotlin project")
|
||||
@GradleTest
|
||||
fun testSimpleKotlinJvmProject(gradleVersion: GradleVersion) {
|
||||
project("kotlinProject", gradleVersion) {
|
||||
testConfigurationCacheOf(":compileKotlin")
|
||||
}
|
||||
}
|
||||
|
||||
// KT-43605
|
||||
@Test
|
||||
fun testInstantExecutionWithBuildSrc() = with(Project("instantExecutionWithBuildSrc")) {
|
||||
setupWorkingDir()
|
||||
testConfigurationCacheOf(
|
||||
"build", executedTaskNames = listOf(
|
||||
@DisplayName("works with publishing")
|
||||
@GradleTest
|
||||
fun testJvmWithMavenPublish(gradleVersion: GradleVersion) {
|
||||
project("kotlinProject", gradleVersion) {
|
||||
buildGradle.modify {
|
||||
//language=Groovy
|
||||
"""
|
||||
plugins {
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
$it
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0"
|
||||
|
||||
publishing.repositories {
|
||||
maven {
|
||||
url = "${'$'}buildDir/repo"
|
||||
}
|
||||
}
|
||||
|
||||
publishing.publications {
|
||||
maven(MavenPublication) {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
testConfigurationCacheOf(":publishMavenPublicationToMavenRepository", checkUpToDateOnRebuild = false)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("works with MPP publishing")
|
||||
@GradleTest
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun testMppWithMavenPublish(gradleVersion: GradleVersion) {
|
||||
project("new-mpp-lib-and-app/sample-lib", gradleVersion) {
|
||||
val publishedTargets = listOf("kotlinMultiplatform", "jvm6", "nodeJs")
|
||||
|
||||
testConfigurationCacheOf(
|
||||
*(publishedTargets.map { ":publish${it.replaceFirstChar { it.uppercaseChar() }}PublicationToMavenRepository" }.toTypedArray()),
|
||||
checkUpToDateOnRebuild = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("with project using incremental kapt")
|
||||
@GradleTest
|
||||
fun testIncrementalKaptProject(gradleVersion: GradleVersion) {
|
||||
project("kaptIncrementalCompilationProject", gradleVersion) {
|
||||
setupIncrementalAptProject("AGGREGATING")
|
||||
|
||||
testConfigurationCacheOf(
|
||||
":compileKotlin",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInstantExecutionWithIncludedBuildPlugin() =
|
||||
with(Project("instantExecutionWithIncludedBuildPlugin", gradleVersionRequirement = GradleVersionRequired.AtLeast("6.8"))) {
|
||||
setupWorkingDir()
|
||||
testConfigurationCacheOf(
|
||||
"build", executedTaskNames = listOf(
|
||||
":compileKotlin",
|
||||
":kaptKotlin",
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
incremental = true,
|
||||
kaptOptions = BuildOptions.KaptOptions(
|
||||
verbose = true,
|
||||
useWorkers = true,
|
||||
incrementalKapt = true,
|
||||
includeCompileClasspath = false
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInstantExecutionForJs() = with(Project("instantExecutionToJs")) {
|
||||
testConfigurationCacheOf("assemble", executedTaskNames = asList(":compileKotlin2Js"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConfigurationCacheJsPlugin() = with(Project("kotlin-js-browser-project")) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
testConfigurationCacheOf(
|
||||
":app:build", executedTaskNames = asList(
|
||||
":app:packageJson",
|
||||
":app:publicPackageJson",
|
||||
":app:compileKotlinJs",
|
||||
":app:processDceKotlinJs",
|
||||
":app:browserProductionWebpack",
|
||||
// Set min Gradle version to 6.8 because of using DependencyResolutionManagement API to add repositories.
|
||||
@DisplayName("with instance execution")
|
||||
@GradleTestVersions(minVersion = "6.8.3")
|
||||
@GradleTest
|
||||
fun testInstantExecution(gradleVersion: GradleVersion) {
|
||||
project("instantExecution", gradleVersion) {
|
||||
testConfigurationCacheOf(
|
||||
"assemble",
|
||||
executedTaskNames = listOf(":lib-project:compileKotlin")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConfigurationCacheDukatSrc() = testConfigurationCacheDukat()
|
||||
@DisplayName("KT-43605: instant execution with buildSrc")
|
||||
@GradleTest
|
||||
fun testInstantExecutionWithBuildSrc(gradleVersion: GradleVersion) {
|
||||
project("instantExecutionWithBuildSrc", gradleVersion) {
|
||||
testConfigurationCacheOf(
|
||||
"build",
|
||||
executedTaskNames = listOf(":compileKotlin")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConfigurationCacheDukatBinaries() = testConfigurationCacheDukat {
|
||||
gradleProperties().modify {
|
||||
"""
|
||||
@DisplayName("instant execution works with included build plugin")
|
||||
@GradleTestVersions(minVersion = "6.8.3")
|
||||
@GradleTest
|
||||
fun testInstantExecutionWithIncludedBuildPlugin(gradleVersion: GradleVersion) {
|
||||
project("instantExecutionWithIncludedBuildPlugin", gradleVersion) {
|
||||
testConfigurationCacheOf(
|
||||
"build",
|
||||
executedTaskNames = listOf(":compileKotlin")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("instant execution is working for JS project")
|
||||
@GradleTest
|
||||
fun testInstantExecutionForJs(gradleVersion: GradleVersion) {
|
||||
project("instantExecutionToJs", gradleVersion) {
|
||||
testConfigurationCacheOf(
|
||||
"assemble",
|
||||
executedTaskNames = listOf(":compileKotlinJs")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("is working for JS project")
|
||||
@GradleTest
|
||||
fun testConfigurationCacheJsPlugin(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-browser-project", gradleVersion) {
|
||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
settingsGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
testConfigurationCacheOf(
|
||||
":app:build",
|
||||
executedTaskNames = listOf(
|
||||
":app:packageJson",
|
||||
":app:publicPackageJson",
|
||||
":app:compileKotlinJs",
|
||||
":app:processDceKotlinJs",
|
||||
":app:browserProductionWebpack",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("works with Dukat")
|
||||
@GradleTest
|
||||
fun testConfigurationCacheDukatSrc(gradleVersion: GradleVersion) {
|
||||
testConfigurationCacheDukat(gradleVersion)
|
||||
}
|
||||
|
||||
@DisplayName("works with Dukat binaries")
|
||||
@GradleTest
|
||||
fun testConfigurationCacheDukatBinaries(gradleVersion: GradleVersion) {
|
||||
testConfigurationCacheDukat(gradleVersion) {
|
||||
gradleProperties.modify {
|
||||
"""
|
||||
|
||||
${ExternalsOutputFormat.externalsOutputFormatProperty}=${ExternalsOutputFormat.BINARY}
|
||||
""".trimIndent()
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun testConfigurationCacheDukat(configure: Project.() -> Unit = {}) =
|
||||
with(Project("both", directoryPrefix = "dukat-integration")) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
configure(this)
|
||||
private fun testConfigurationCacheDukat(
|
||||
gradleVersion: GradleVersion,
|
||||
configure: TestProject.() -> Unit = {}
|
||||
) = project("dukat-integration/both", gradleVersion) {
|
||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
settingsGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
configure(this)
|
||||
testConfigurationCacheOf(
|
||||
"irGenerateExternalsIntegrated",
|
||||
executedTaskNames = listOf(":irGenerateExternalsIntegrated")
|
||||
)
|
||||
}
|
||||
|
||||
@DisplayName("works in MPP withJava project")
|
||||
@GradleTestVersions(minVersion = "7.0.2", maxVersion = "7.1.1")
|
||||
@GradleTest
|
||||
fun testJvmWithJavaConfigurationCache(gradleVersion: GradleVersion) {
|
||||
project("mppJvmWithJava", gradleVersion) {
|
||||
build("jar")
|
||||
|
||||
build("jar") {
|
||||
assertOutputContains("Reusing configuration cache.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-48241: works in JS with test dependencies")
|
||||
@GradleTest
|
||||
fun testConfigurationCacheJsWithTestDependencies(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-project-with-test-dependencies", gradleVersion) {
|
||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
testConfigurationCacheOf(
|
||||
"irGenerateExternalsIntegrated", executedTaskNames = listOf(
|
||||
":irGenerateExternalsIntegrated"
|
||||
)
|
||||
"assemble",
|
||||
executedTaskNames = listOf(":kotlinNpmInstall")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJvmWithJavaConfigurationCache() =
|
||||
with(Project("mppJvmWithJava", gradleVersionRequirement = GradleVersionRequired.AtLeast("7.1"))) {
|
||||
setupWorkingDir()
|
||||
|
||||
build("jar", options = defaultBuildOptions().copy(configurationCache = true)) {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
build("jar", options = defaultBuildOptions().copy(configurationCache = true)) {
|
||||
assertSuccessful()
|
||||
assertContains("Reusing configuration cache.")
|
||||
}
|
||||
}
|
||||
|
||||
// KT-48241
|
||||
@Test
|
||||
fun testConfigurationCacheJsWithTestDependencies() = with(transformProjectWithPluginsDsl("kotlin-js-project-with-test-dependencies")) {
|
||||
testConfigurationCacheOf("assemble", executedTaskNames = listOf(":kotlinNpmInstall"))
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractConfigurationCacheIT : BaseGradleIT() {
|
||||
override fun defaultBuildOptions() =
|
||||
super.defaultBuildOptions().copy(configurationCache = true)
|
||||
@SimpleGradlePluginTests
|
||||
@KGPBaseTest.GradleTestVersions(minVersion = "6.6.1")
|
||||
abstract class AbstractConfigurationCacheIT : KGPBaseTest() {
|
||||
override val defaultBuildOptions =
|
||||
super.defaultBuildOptions.copy(configurationCache = true)
|
||||
|
||||
override val defaultGradleVersion: GradleVersionRequired = GradleVersionRequired.AtLeast("6.6.1")
|
||||
|
||||
protected fun Project.testConfigurationCacheOf(
|
||||
protected fun TestProject.testConfigurationCacheOf(
|
||||
vararg taskNames: String,
|
||||
executedTaskNames: List<String>? = null,
|
||||
checkUpToDateOnRebuild: Boolean = true,
|
||||
buildOptions: BuildOptions = defaultBuildOptions()
|
||||
buildOptions: BuildOptions = defaultBuildOptions
|
||||
) {
|
||||
// First, run a build that serializes the tasks state for instant execution in further builds
|
||||
|
||||
val executedTask: List<String> = executedTaskNames ?: taskNames.toList()
|
||||
|
||||
build(*taskNames, options = buildOptions) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(executedTask)
|
||||
assertContains("Calculating task graph as no configuration cache is available for tasks: ${taskNames.joinToString(separator = " ")}")
|
||||
checkInstantExecutionSucceeded()
|
||||
build(*taskNames, buildOptions = buildOptions) {
|
||||
assertTasksExecuted(*executedTask.toTypedArray())
|
||||
assertOutputContains(
|
||||
"Calculating task graph as no configuration cache is available for tasks: ${taskNames.joinToString(separator = " ")}"
|
||||
)
|
||||
assertInstantExecutionSucceeded()
|
||||
}
|
||||
|
||||
build("clean", options = buildOptions) {
|
||||
assertSuccessful()
|
||||
}
|
||||
build("clean", buildOptions = buildOptions)
|
||||
|
||||
// Then run a build where tasks states are deserialized to check that they work correctly in this mode
|
||||
build(*taskNames, options = buildOptions) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(executedTask)
|
||||
assertContains("Reusing configuration cache.")
|
||||
build(*taskNames, buildOptions = buildOptions) {
|
||||
assertTasksExecuted(*executedTask.toTypedArray())
|
||||
assertOutputContains("Reusing configuration cache.")
|
||||
}
|
||||
|
||||
if (checkUpToDateOnRebuild) {
|
||||
build(*taskNames, options = buildOptions) {
|
||||
assertSuccessful()
|
||||
assertTasksUpToDate(executedTask)
|
||||
build(*taskNames, buildOptions = buildOptions) {
|
||||
assertTasksUpToDate(*executedTask.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.checkInstantExecutionSucceeded() {
|
||||
instantExecutionReportFile()?.let { htmlReportFile ->
|
||||
fail("Instant execution problems were found, check ${htmlReportFile.asClickableFileUrl()} for details.")
|
||||
private fun GradleProject.assertInstantExecutionSucceeded() {
|
||||
instantExecutionReportFile?.let { htmlReportFile ->
|
||||
fail("Instant execution problems were found, check ${htmlReportFile.asClickableFileUrl} for details.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,9 +272,10 @@ abstract class AbstractConfigurationCacheIT : BaseGradleIT() {
|
||||
* fresh temp dir and returns a reference to the copied [htmlReportFile] in the new
|
||||
* directory.
|
||||
*/
|
||||
private fun copyReportToTempDir(htmlReportFile: File): File =
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
private fun copyReportToTempDir(htmlReportFile: Path): Path =
|
||||
createTempDir("report").let { tempDir ->
|
||||
htmlReportFile.parentFile.copyRecursively(tempDir)
|
||||
htmlReportFile.parent.toFile().copyRecursively(tempDir.toFile())
|
||||
tempDir.resolve(htmlReportFile.name)
|
||||
}
|
||||
|
||||
@@ -231,11 +283,12 @@ abstract class AbstractConfigurationCacheIT : BaseGradleIT() {
|
||||
* The instant execution report file, if exists, indicates problems were
|
||||
* found while caching the task graph.
|
||||
*/
|
||||
private fun Project.instantExecutionReportFile() = projectDir
|
||||
.resolve("configuration-cache")
|
||||
.findFileByName("configuration-cache-report.html")
|
||||
?.let { copyReportToTempDir(it) }
|
||||
|
||||
private fun File.asClickableFileUrl(): String =
|
||||
URI("file", "", toURI().path, null, null).toString()
|
||||
private val GradleProject.instantExecutionReportFile
|
||||
get() = projectPath
|
||||
.resolve("build")
|
||||
.findInPath("configuration-cache-report.html")
|
||||
?.let { copyReportToTempDir(it) }
|
||||
|
||||
private val Path.asClickableFileUrl
|
||||
get() = URI("file", "", toUri().path, null, null).toString()
|
||||
}
|
||||
|
||||
+73
-4
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.gradle.incapt.IncrementalAggregatingReferencingClass
|
||||
import org.jetbrains.kotlin.gradle.incapt.IncrementalBinaryIsolatingProcessor
|
||||
import org.jetbrains.kotlin.gradle.incapt.IncrementalProcessor
|
||||
import org.jetbrains.kotlin.gradle.incapt.IncrementalProcessorReferencingClasspath
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestProject
|
||||
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -17,8 +18,12 @@ import org.junit.Assume
|
||||
import org.junit.Test
|
||||
import test.kt33617.MyClass
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import kotlin.io.path.ExperimentalPathApi
|
||||
import kotlin.io.path.readText
|
||||
import kotlin.io.path.writeText
|
||||
|
||||
class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
||||
|
||||
@@ -207,10 +212,16 @@ class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
||||
).apply {
|
||||
setupIncrementalAptProject("ISOLATING", procClass = IncrementalProcessorReferencingClasspath::class.java)
|
||||
}
|
||||
project.gradleSettingsScript().writeText("include ':', ':lib'")
|
||||
project.gradleSettingsScript().appendText("\ninclude ':', ':lib'")
|
||||
val classpathTypeSource = project.projectDir.resolve("lib").run {
|
||||
mkdirs()
|
||||
resolve("build.gradle").writeText("apply plugin: 'java'")
|
||||
resolve("build.gradle").writeText(
|
||||
"""
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
val source = resolve("src/main/java/" + IncrementalProcessorReferencingClasspath.CLASSPATH_TYPE.replace(".", "/") + ".java")
|
||||
source.parentFile.mkdirs()
|
||||
|
||||
@@ -306,10 +317,17 @@ class KaptIncrementalWithIsolatingApt : KaptIncrementalIT() {
|
||||
Pair("AGGREGATING", IncrementalAggregatingReferencingClasspathProcessor::class.java),
|
||||
)
|
||||
}
|
||||
project.gradleSettingsScript().writeText("include ':', ':lib'")
|
||||
project.gradleSettingsScript().appendText("\ninclude ':', ':lib'\n")
|
||||
val classpathTypeSource = project.projectDir.resolve("lib").run {
|
||||
mkdirs()
|
||||
resolve("build.gradle").writeText("apply plugin: 'java'")
|
||||
resolve("build.gradle").writeText(
|
||||
"""
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
val source =
|
||||
resolve("src/main/java/" + IncrementalAggregatingReferencingClasspathProcessor.CLASSPATH_TYPE.replace(".", "/") + ".java")
|
||||
source.parentFile.mkdirs()
|
||||
@@ -442,3 +460,54 @@ fun BaseGradleIT.Project.generateProcessor(vararg processors: Pair<String, Class
|
||||
}
|
||||
return processorPath
|
||||
}
|
||||
|
||||
fun TestProject.setupIncrementalAptProject(
|
||||
procType: String,
|
||||
buildFile: Path = buildGradle,
|
||||
procClass: Class<*> = IncrementalProcessor::class.java
|
||||
) {
|
||||
setupIncrementalAptProject(procType to procClass, buildFile = buildFile)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
fun TestProject.setupIncrementalAptProject(
|
||||
vararg processors: Pair<String, Class<*>>,
|
||||
buildFile: Path = buildGradle
|
||||
) {
|
||||
val content = buildFile.readText()
|
||||
val processorPath = generateProcessor(*processors)
|
||||
|
||||
val updatedContent = content.replace(
|
||||
Regex("^\\s*kapt\\s\"org\\.jetbrains\\.kotlin.*$", RegexOption.MULTILINE),
|
||||
" kapt files(\"${processorPath.invariantSeparatorsPath}\")"
|
||||
)
|
||||
buildFile.writeText(updatedContent)
|
||||
}
|
||||
|
||||
fun TestProject.generateProcessor(
|
||||
vararg processors: Pair<String, Class<*>>
|
||||
): File {
|
||||
val processorPath = projectPath.resolve("incrementalProcessor.jar").toFile()
|
||||
|
||||
ZipOutputStream(processorPath.outputStream()).use {
|
||||
for ((_, procClass) in processors) {
|
||||
val path = procClass.name.replace(".", "/") + ".class"
|
||||
procClass.classLoader.getResourceAsStream(path).use { inputStream ->
|
||||
it.putNextEntry(ZipEntry(path))
|
||||
it.write(inputStream.readBytes())
|
||||
it.closeEntry()
|
||||
}
|
||||
}
|
||||
it.putNextEntry(ZipEntry("META-INF/gradle/incremental.annotation.processors"))
|
||||
it.write(processors.joinToString("\n") { (procType, procClass) ->
|
||||
"${procClass.name},$procType"
|
||||
}.toByteArray())
|
||||
it.closeEntry()
|
||||
it.putNextEntry(ZipEntry("META-INF/services/javax.annotation.processing.Processor"))
|
||||
it.write(processors.joinToString("\n") { (_, procClass) ->
|
||||
procClass.name
|
||||
}.toByteArray())
|
||||
it.closeEntry()
|
||||
}
|
||||
return processorPath
|
||||
}
|
||||
|
||||
-1
@@ -1035,7 +1035,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
@Test
|
||||
fun testNonMppConsumersOfLibraryPublishedWithNoMetadataOptIn() {
|
||||
val repoDir = with(transformNativeTestProject("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
projectDir.resolve("settings.gradle").modify { it.replace("enableFeaturePreview", "// enableFeaturePreview") }
|
||||
build(
|
||||
"publish"
|
||||
) { assertSuccessful() }
|
||||
|
||||
+3
-9
@@ -1,9 +1,3 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" apply false
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,5 +1,3 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
apply plugin: 'kotlin'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation project(':lib-project')
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,37 +1,37 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
|
||||
apply plugin: 'kotlin2js'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.js"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||
}
|
||||
|
||||
task jarSources(type: Jar) {
|
||||
from sourceSets.main.allSource
|
||||
classifier = 'source'
|
||||
}
|
||||
artifacts {
|
||||
implementation jarSources
|
||||
def jsUseIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true
|
||||
|
||||
tasks.named("compileKotlinJs", Kotlin2JsCompile) {
|
||||
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||
if (jsUseIrBackend) {
|
||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
}
|
||||
}
|
||||
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||
compileTestKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
|
||||
|
||||
if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
tasks.named("compileTestKotlinJs", Kotlin2JsCompile) {
|
||||
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
|
||||
if (jsUseIrBackend) {
|
||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
}
|
||||
|
||||
+2
-10
@@ -1,15 +1,7 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
+2
-10
@@ -1,16 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
+1
-12
@@ -1,19 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("foo-plugin")
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
+1
-12
@@ -1,19 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java-gradle-plugin'
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
|
||||
}
|
||||
}
|
||||
+4
-12
@@ -1,17 +1,9 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
id 'org.jetbrains.kotlin.kapt'
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-kapt"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.kapt" version "$kotlin_version"
|
||||
}
|
||||
}
|
||||
+4
-15
@@ -1,30 +1,19 @@
|
||||
apply plugin: 'kotlin-multiplatform'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jcenter.bintray.com/") }
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jcenter.bintray.com/") }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm("jvmWithJava") {
|
||||
withJava()
|
||||
|
||||
compilations.all {
|
||||
compilations.configureEach {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.kapt" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.android" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.js" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "com.android.application" ||
|
||||
requested.id.id == "com.android.library" ||
|
||||
requested.id.id == "com.android.test" ||
|
||||
requested.id.id == "com.android.dynamic-feature" ||
|
||||
requested.id.id == "com.android.asset-pack" ||
|
||||
requested.id.id == "com.android.asset-pack-bundle" ||
|
||||
requested.id.id == "com.android.lint" ||
|
||||
requested.id.id == "com.android.instantapp" ||
|
||||
requested.id.id == "com.android.feature") {
|
||||
useModule("com.android.tools.build:gradle:$android_tools_version")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
enableFeaturePreview('GRADLE_METADATA')
|
||||
Reference in New Issue
Block a user