Introduce GradleProject class.
This allows to split concepts of TestProject(whole build and options) and actual Gradle project, which could be one of the main project subprojects. ^KT-45745 In Progress
This commit is contained in:
+3
-3
@@ -77,7 +77,7 @@ class BuildCacheIT : KGPBaseTest() {
|
|||||||
assertTasksPackedToCache(":compileKotlin")
|
assertTasksPackedToCache(":compileKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourceFile = projectPath.resolve("src/main/kotlin/helloWorld.kt")
|
val sourceFile = kotlinSourcesDir().resolve("helloWorld.kt")
|
||||||
val originalSource: String = sourceFile.readText()
|
val originalSource: String = sourceFile.readText()
|
||||||
val modifiedSource: String = originalSource.replace(" and ", " + ")
|
val modifiedSource: String = originalSource.replace(" and ", " + ")
|
||||||
sourceFile.writeText(modifiedSource)
|
sourceFile.writeText(modifiedSource)
|
||||||
@@ -187,7 +187,7 @@ class BuildCacheIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Change the return type of foo() from Int to String in foo.kt, and check that fooUsage.kt is recompiled as well:
|
// Change the return type of foo() from Int to String in foo.kt, and check that fooUsage.kt is recompiled as well:
|
||||||
val fooKtSourceFile = secondProject.projectPath.resolve("src/main/kotlin/foo.kt")
|
val fooKtSourceFile = secondProject.kotlinSourcesDir().resolve("foo.kt")
|
||||||
fooKtSourceFile.modify { it.replace("Int = 1", "String = \"abc\"") }
|
fooKtSourceFile.modify { it.replace("Int = 1", "String = \"abc\"") }
|
||||||
secondProject.build("assemble") {
|
secondProject.build("assemble") {
|
||||||
assertIncrementalCompilation(modifiedFiles = setOf(fooKtSourceFile))
|
assertIncrementalCompilation(modifiedFiles = setOf(fooKtSourceFile))
|
||||||
@@ -224,7 +224,7 @@ class BuildCacheIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make changes to annotated class and check kapt tasks are re-executed
|
// Make changes to annotated class and check kapt tasks are re-executed
|
||||||
val appClassKtSourceFile = secondProject.projectPath.resolve("app/src/main/kotlin/AppClass.kt")
|
val appClassKtSourceFile = secondProject.subProject("app").kotlinSourcesDir().resolve("AppClass.kt")
|
||||||
appClassKtSourceFile.modify {
|
appClassKtSourceFile.modify {
|
||||||
it.replace("val testVal: String = \"text\"", "val testVal: Int = 1")
|
it.replace("val testVal: String = \"text\"", "val testVal: Int = 1")
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-12
@@ -8,12 +8,9 @@ package org.jetbrains.kotlin.gradle
|
|||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import kotlin.io.path.ExperimentalPathApi
|
|
||||||
import kotlin.io.path.appendText
|
|
||||||
|
|
||||||
@DisplayName("Tasks configuration avoidance")
|
@DisplayName("Tasks configuration avoidance")
|
||||||
@SimpleGradlePluginTests
|
@SimpleGradlePluginTests
|
||||||
@OptIn(ExperimentalPathApi::class)
|
|
||||||
class ConfigurationAvoidanceIT : KGPBaseTest() {
|
class ConfigurationAvoidanceIT : KGPBaseTest() {
|
||||||
|
|
||||||
@DisplayName("Unrelated tasks are not configured")
|
@DisplayName("Unrelated tasks are not configured")
|
||||||
@@ -24,7 +21,7 @@ class ConfigurationAvoidanceIT : KGPBaseTest() {
|
|||||||
val expensivelyConfiguredTaskName = "expensivelyConfiguredTask"
|
val expensivelyConfiguredTaskName = "expensivelyConfiguredTask"
|
||||||
|
|
||||||
@Suppress("GroovyAssignabilityCheck")
|
@Suppress("GroovyAssignabilityCheck")
|
||||||
rootBuildGradle.appendText(
|
buildGradle.append(
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -48,10 +45,9 @@ class ConfigurationAvoidanceIT : KGPBaseTest() {
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
listOf("Android", "Test").forEach { subproject ->
|
listOf("Android", "Test").forEach { subproject ->
|
||||||
projectPath
|
subProject(subproject)
|
||||||
.resolve(subproject)
|
.buildGradle
|
||||||
.resolve("build.gradle")
|
.append(
|
||||||
.appendText(
|
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -66,10 +62,9 @@ class ConfigurationAvoidanceIT : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath
|
subProject("Lib")
|
||||||
.resolve("Lib")
|
.buildGradle
|
||||||
.resolve("build.gradle")
|
.append(
|
||||||
.appendText(
|
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -25,7 +25,7 @@ class JavaUpToDateIT : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify {
|
kotlinSourcesDir().resolve("foo/MainKotlinClass.kt").modify {
|
||||||
it.replace(
|
it.replace(
|
||||||
"fun number(): Int = 0",
|
"fun number(): Int = 0",
|
||||||
"fun number(): Int = 1"
|
"fun number(): Int = 1"
|
||||||
@@ -52,7 +52,7 @@ class JavaUpToDateIT : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify { "\n$it" }
|
kotlinSourcesDir().resolve("foo/MainKotlinClass.kt").modify { "\n$it" }
|
||||||
|
|
||||||
build("build") {
|
build("build") {
|
||||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||||
@@ -74,7 +74,7 @@ class JavaUpToDateIT : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify {
|
kotlinSourcesDir().resolve("foo/MainKotlinClass.kt").modify {
|
||||||
it.replace(
|
it.replace(
|
||||||
"private fun privateMethod() = 0",
|
"private fun privateMethod() = 0",
|
||||||
"private fun privateMethod() = \"0\""
|
"private fun privateMethod() = \"0\""
|
||||||
|
|||||||
+6
-6
@@ -131,7 +131,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
|
|||||||
|
|
||||||
JavaVersion.VERSION_1_8
|
JavaVersion.VERSION_1_8
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tasks
|
tasks
|
||||||
@@ -168,7 +168,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
|
|||||||
gradleVersion = gradleVersion
|
gradleVersion = gradleVersion
|
||||||
) {
|
) {
|
||||||
//language=groovy
|
//language=groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -208,7 +208,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
|
|||||||
kotlin.jvm.target.validation.mode = error
|
kotlin.jvm.target.validation.mode = error
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
projectPath.resolve("src/main/kotlin").toFile().deleteRecursively()
|
kotlinSourcesDir().toFile().deleteRecursively()
|
||||||
|
|
||||||
buildAndFail("assemble") {
|
buildAndFail("assemble") {
|
||||||
assertOutputContains(
|
assertOutputContains(
|
||||||
@@ -269,7 +269,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath.resolve("src/main/java/demo").run {
|
javaSourcesDir().resolve("demo").run {
|
||||||
createDirectories()
|
createDirectories()
|
||||||
resolve("HelloWorld.java").writeText(
|
resolve("HelloWorld.java").writeText(
|
||||||
//language=Java
|
//language=Java
|
||||||
@@ -297,7 +297,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
|
|||||||
target: JavaVersion
|
target: JavaVersion
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tasks.withType(JavaCompile.class).configureEach {
|
tasks.withType(JavaCompile.class).configureEach {
|
||||||
@@ -313,7 +313,7 @@ class JvmTargetValidationTest : KGPBaseTest() {
|
|||||||
jdkVersion: Int
|
jdkVersion: Int
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -12,7 +12,6 @@ import org.gradle.util.GradleVersion
|
|||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
|
||||||
|
|
||||||
@DaemonsGradlePluginTests
|
@DaemonsGradlePluginTests
|
||||||
@DisplayName("Kotlin daemon JVM args")
|
@DisplayName("Kotlin daemon JVM args")
|
||||||
@@ -92,7 +91,7 @@ class KotlinDaemonJvmArgsTest : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
@@ -125,7 +124,7 @@ class KotlinDaemonJvmArgsTest : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
|
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
|
||||||
@@ -162,7 +161,7 @@ class KotlinDaemonJvmArgsTest : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|||||||
+9
-9
@@ -312,7 +312,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
gradleVersion = gradleVersion
|
gradleVersion = gradleVersion
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
gradleVersion = gradleVersion
|
gradleVersion = gradleVersion
|
||||||
) {
|
) {
|
||||||
//language=groovy
|
//language=groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -498,7 +498,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
useToolchainToCompile(11)
|
useToolchainToCompile(11)
|
||||||
|
|
||||||
//language=groovy
|
//language=groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
@@ -568,7 +568,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
buildJdk = getJdk11().javaHome
|
buildJdk = getJdk11().javaHome
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
tasks.named("compileKotlin") {
|
tasks.named("compileKotlin") {
|
||||||
doLast {
|
doLast {
|
||||||
@@ -659,7 +659,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
jvmTarget: String
|
jvmTarget: String
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
@@ -676,7 +676,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
target: JavaVersion
|
target: JavaVersion
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tasks.withType(JavaCompile.class).configureEach {
|
tasks.withType(JavaCompile.class).configureEach {
|
||||||
@@ -693,7 +693,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
jdkVersion: JavaVersion
|
jdkVersion: JavaVersion
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
import org.gradle.api.JavaVersion
|
import org.gradle.api.JavaVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
||||||
@@ -714,7 +714,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
jdkVersion: Int
|
jdkVersion: Int
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
||||||
|
|
||||||
@@ -742,7 +742,7 @@ class KotlinJavaToolchainTest : KGPBaseTest() {
|
|||||||
jdkVersion: Int
|
jdkVersion: Int
|
||||||
) {
|
) {
|
||||||
//language=Groovy
|
//language=Groovy
|
||||||
rootBuildGradle.append(
|
buildGradle.append(
|
||||||
"""
|
"""
|
||||||
import org.gradle.api.plugins.JavaPluginExtension
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
|||||||
project("kotlinProject", gradleVersion) {
|
project("kotlinProject", gradleVersion) {
|
||||||
// Change the build directory in the end of the build script:
|
// Change the build directory in the end of the build script:
|
||||||
val customBuildDirName = "customBuild"
|
val customBuildDirName = "customBuild"
|
||||||
appendToBuildFile(
|
buildGradle.append(
|
||||||
"buildDir = '$customBuildDirName'"
|
"buildDir = '$customBuildDirName'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ class SourceFileIsModifiedIT : KGPBaseTest() {
|
|||||||
assertTasksNoSource(":compileTestKotlin")
|
assertTasksNoSource(":compileTestKotlin")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dummyFile = projectPath.resolve("src/main/java/kotlinPackage/Dummy.kt")
|
val dummyFile = javaSourcesDir().resolve("kotlinPackage/Dummy.kt")
|
||||||
transformDummy(dummyFile)
|
transformDummy(dummyFile)
|
||||||
|
|
||||||
build("build", buildOptions = buildOptions) {
|
build("build", buildOptions = buildOptions) {
|
||||||
|
|||||||
+4
-4
@@ -11,7 +11,7 @@ import java.nio.file.Path
|
|||||||
/**
|
/**
|
||||||
* Asserts file under [file] path exists and is a regular file.
|
* Asserts file under [file] path exists and is a regular file.
|
||||||
*/
|
*/
|
||||||
fun TestProject.assertFileExists(
|
fun GradleProject.assertFileExists(
|
||||||
file: Path
|
file: Path
|
||||||
) {
|
) {
|
||||||
assert(Files.exists(file)) {
|
assert(Files.exists(file)) {
|
||||||
@@ -26,7 +26,7 @@ fun TestProject.assertFileExists(
|
|||||||
/**
|
/**
|
||||||
* Asserts file under [pathToFile] relative to the test project exists and is a regular file.
|
* Asserts file under [pathToFile] relative to the test project exists and is a regular file.
|
||||||
*/
|
*/
|
||||||
fun TestProject.assertFileInProjectExists(
|
fun GradleProject.assertFileInProjectExists(
|
||||||
pathToFile: String
|
pathToFile: String
|
||||||
) {
|
) {
|
||||||
assertFileExists(projectPath.resolve(pathToFile))
|
assertFileExists(projectPath.resolve(pathToFile))
|
||||||
@@ -35,7 +35,7 @@ fun TestProject.assertFileInProjectExists(
|
|||||||
/**
|
/**
|
||||||
* Asserts file under [pathToFile] relative to the test project does not exist.
|
* Asserts file under [pathToFile] relative to the test project does not exist.
|
||||||
*/
|
*/
|
||||||
fun TestProject.assertFileNotExists(
|
fun GradleProject.assertFileNotExists(
|
||||||
pathToFile: String
|
pathToFile: String
|
||||||
) {
|
) {
|
||||||
val filePath = projectPath.resolve(pathToFile)
|
val filePath = projectPath.resolve(pathToFile)
|
||||||
@@ -47,7 +47,7 @@ fun TestProject.assertFileNotExists(
|
|||||||
/**
|
/**
|
||||||
* Asserts directory under [pathToDir] relative to the test project exists and is a directory.
|
* Asserts directory under [pathToDir] relative to the test project exists and is a directory.
|
||||||
*/
|
*/
|
||||||
fun TestProject.assertDirectoryExists(
|
fun GradleProject.assertDirectoryExists(
|
||||||
pathToDir: String
|
pathToDir: String
|
||||||
) {
|
) {
|
||||||
val dirPath = projectPath.resolve(pathToDir)
|
val dirPath = projectPath.resolve(pathToDir)
|
||||||
|
|||||||
+28
-13
@@ -57,8 +57,8 @@ fun KGPBaseTest.project(
|
|||||||
val testProject = TestProject(
|
val testProject = TestProject(
|
||||||
gradleRunner,
|
gradleRunner,
|
||||||
projectName,
|
projectName,
|
||||||
buildOptions,
|
|
||||||
projectPath,
|
projectPath,
|
||||||
|
buildOptions,
|
||||||
gradleVersion,
|
gradleVersion,
|
||||||
enableGradleDebug,
|
enableGradleDebug,
|
||||||
forceOutput,
|
forceOutput,
|
||||||
@@ -151,20 +151,15 @@ fun TestProject.enableLocalBuildCache(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestProject(
|
open class GradleProject(
|
||||||
val gradleRunner: GradleRunner,
|
|
||||||
val projectName: String,
|
val projectName: String,
|
||||||
val buildOptions: KGPBaseTest.BuildOptions,
|
val projectPath: Path
|
||||||
val projectPath: Path,
|
|
||||||
val gradleVersion: GradleVersion,
|
|
||||||
val enableGradleDebug: Boolean,
|
|
||||||
val forceOutput: Boolean,
|
|
||||||
val enableBuildScan: Boolean
|
|
||||||
) {
|
) {
|
||||||
val rootBuildGradle: Path get() = projectPath.resolve("build.gradle")
|
val buildGradle: Path get() = projectPath.resolve("build.gradle")
|
||||||
|
val buildGradleKts: Path get() = projectPath.resolve("build.gradle.kts")
|
||||||
val settingsGradle: Path get() = projectPath.resolve("settings.gradle")
|
val settingsGradle: Path get() = projectPath.resolve("settings.gradle")
|
||||||
|
val settingsGradleKts: Path get() = projectPath.resolve("settings.gradle.kts")
|
||||||
val gradleProperties: Path get() = projectPath.resolve("gradle.properties")
|
val gradleProperties: Path get() = projectPath.resolve("gradle.properties")
|
||||||
val localProperties: Path get() = projectPath.resolve("local.properties")
|
|
||||||
|
|
||||||
fun classesDir(
|
fun classesDir(
|
||||||
sourceSet: String = "main",
|
sourceSet: String = "main",
|
||||||
@@ -174,6 +169,27 @@ class TestProject(
|
|||||||
fun kotlinClassesDir(
|
fun kotlinClassesDir(
|
||||||
sourceSet: String = "main"
|
sourceSet: String = "main"
|
||||||
): Path = classesDir(sourceSet, language = "kotlin")
|
): Path = classesDir(sourceSet, language = "kotlin")
|
||||||
|
|
||||||
|
fun kotlinSourcesDir(
|
||||||
|
sourceSet: String = "main"
|
||||||
|
): Path = projectPath.resolve("src/$sourceSet/kotlin")
|
||||||
|
|
||||||
|
fun javaSourcesDir(
|
||||||
|
sourceSet: String = "main"
|
||||||
|
): Path = projectPath.resolve("src/$sourceSet/java")
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestProject(
|
||||||
|
val gradleRunner: GradleRunner,
|
||||||
|
projectName: String,
|
||||||
|
projectPath: Path,
|
||||||
|
val buildOptions: KGPBaseTest.BuildOptions,
|
||||||
|
val gradleVersion: GradleVersion,
|
||||||
|
val enableGradleDebug: Boolean,
|
||||||
|
val forceOutput: Boolean,
|
||||||
|
val enableBuildScan: Boolean
|
||||||
|
) : GradleProject(projectName, projectPath) {
|
||||||
|
fun subProject(name: String) = GradleProject(name, projectPath.resolve(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun commonBuildSetup(
|
private fun commonBuildSetup(
|
||||||
@@ -264,9 +280,8 @@ private fun Path.addDefaultBuildFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalPathApi::class)
|
|
||||||
private fun TestProject.agreeToBuildScanService() {
|
private fun TestProject.agreeToBuildScanService() {
|
||||||
settingsGradle.appendText(
|
settingsGradle.append(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
gradleEnterprise {
|
gradleEnterprise {
|
||||||
|
|||||||
-9
@@ -34,12 +34,3 @@ fun Path.append(
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Append [textToAppend] to the current [TestProject] 'build.gradle' file.
|
|
||||||
*/
|
|
||||||
fun TestProject.appendToBuildFile(
|
|
||||||
textToAppend: String
|
|
||||||
) {
|
|
||||||
projectPath.resolve("build.gradle").append(textToAppend)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user