From 0505d58c54871a8c2ffac446ab3bc90a4a1195d3 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Tue, 27 Apr 2021 20:10:37 +0200 Subject: [PATCH] Fix exposing provided by Gradle Kotlin dependencies. Ensure that Gradle plugin dependencies do not include kotlin-stdlib, kotlin-reflect and other dependencies that are provided by Gradle runtime. ^KT-41142 Fixed --- ...dle-plugin-common-configuration.gradle.kts | 49 ++++++++ .../kotlin/code/CodeConformanceTest.kt | 2 + compiler/util-io/build.gradle.kts | 2 +- .../build.gradle.kts | 9 +- .../kotlin-gradle-plugin-api/build.gradle.kts | 22 +--- .../kotlin/gradle/SimpleKotlinGradleIT.kt | 27 ++++ .../build.gradle.kts | 8 ++ .../buildSrc/build.gradle.kts | 12 ++ .../buildSrc/src/main/kotlin/ProjectExt.kt | 3 + .../src/main/kotlin/main.kt | 8 ++ .../build.gradle.kts | 23 +--- .../kotlin-gradle-plugin/build.gradle.kts | 25 +--- .../JvmAndAndroidIntermediateSourceSetTest.kt | 87 +++++++++---- .../gradle/KotlinAndroidDependsOnEdgesTest.kt | 40 +++--- .../kotlin/gradle/MppPublicationTest.kt | 11 +- .../SyncKotlinAndAndroidSourceSetsTest.kt | 80 +++++++----- .../mpp/CompilationSpecificPluginPath.kt | 115 ++++++++++++++---- .../jetbrains/kotlin/gradle/tasks/Tasks.kt | 25 ++-- ...TCServiceMessageOutputStreamHandlerTest.kt | 2 +- .../tcsmc/TCServiceMessagesClientTest.kt | 2 +- .../internal/testing/tcsmc/TestCrash.kt | 2 +- .../model/builder/KaptModelBuilderTest.kt | 4 +- .../KotlinAndroidExtensionModelBuilderTest.kt | 4 +- .../model/builder/KotlinModelBuilderTest.kt | 4 +- .../KotlinCompilationsModuleGroupsTest.kt | 2 +- .../SourceSetVisibilityInferenceTest.kt | 66 ++++++---- .../internal/NodeJsStackTraceParserKtTest.kt | 2 +- .../js/npm/GradleNodeModuleBuilderTest.kt | 12 +- .../gradle/targets/js/npm/NpmRangeTest.kt | 102 +++++++++------- .../kotlin/gradle/utils/GradleVersionTest.kt | 14 +-- .../kotlin-gradle-statistics/build.gradle.kts | 8 +- native/utils/build.gradle.kts | 6 +- 32 files changed, 496 insertions(+), 282 deletions(-) create mode 100644 buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/src/main/kotlin/ProjectExt.kt create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/src/main/kotlin/main.kt diff --git a/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts b/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts new file mode 100644 index 0000000000000..1fcb6cedc4223 --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2021 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. + */ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("jvm") +} + +publish() +standardPublicJars() + +extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false" + +dependencies { + compileOnly(kotlinStdlib()) + compileOnly(gradleApi()) +} + +// These dependencies will be provided by Gradle and we should prevent version conflict +fun Configuration.excludeGradleCommonDependencies() { + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime") +} +configurations { + "implementation" { + excludeGradleCommonDependencies() + } + "api" { + excludeGradleCommonDependencies() + } +} + +tasks.withType { + kotlinOptions.languageVersion = "1.3" + kotlinOptions.apiVersion = "1.3" + kotlinOptions.freeCompilerArgs += listOf( + "-Xskip-prerelease-check" + ) +} + +tasks.named("jar") { + callGroovy("manifestAttributes", manifest, project) +} diff --git a/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt b/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt index 7b65b6daf35e5..9a3cc916bcc92 100644 --- a/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt @@ -68,6 +68,7 @@ class CodeConformanceTest : TestCase() { File("."), listOf( "build", + "buildSrc/build/generated-sources", "buildSrc/prepare-deps/build", "compiler/ir/serialization.js/build/fullRuntime", "compiler/ir/serialization.js/build/reducedRuntime/src/libraries/stdlib/js-ir/runtime/longjs.kt", @@ -93,6 +94,7 @@ class CodeConformanceTest : TestCase() { "libraries/stdlib/js-v1/node_modules", "libraries/stdlib/wasm/build", "libraries/tools/kotlin-gradle-plugin-integration-tests/build", + "libraries/tools/kotlin-gradle-plugin-integration-tests/.testKitDir", "libraries/tools/kotlin-maven-plugin-test/target", "libraries/tools/kotlin-test-js-runner/.gradle", "libraries/tools/kotlin-test-js-runner/lib", diff --git a/compiler/util-io/build.gradle.kts b/compiler/util-io/build.gradle.kts index 2c6453178c6ef..bf8125d701a0d 100644 --- a/compiler/util-io/build.gradle.kts +++ b/compiler/util-io/build.gradle.kts @@ -6,7 +6,7 @@ plugins { description = "Kotlin/Native utils" dependencies { - compile(kotlinStdlib()) + implementation(kotlinStdlib()) testImplementation(commonDep("junit:junit")) } diff --git a/libraries/tools/kotlin-gradle-build-metrics/build.gradle.kts b/libraries/tools/kotlin-gradle-build-metrics/build.gradle.kts index 23ab92f255cc2..18ceba29f1da2 100644 --- a/libraries/tools/kotlin-gradle-build-metrics/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-build-metrics/build.gradle.kts @@ -1,13 +1,11 @@ description = "kotlin-gradle-statistics" plugins { - kotlin("jvm") + id("gradle-plugin-common-configuration") id("jps-compatible") } dependencies { - compileOnly(kotlinStdlib()) - testImplementation(project(":kotlin-test:kotlin-test-junit")) testImplementation("junit:junit:4.12") } @@ -20,8 +18,3 @@ sourceSets { projectTest { workingDir = rootDir } - -publish() - -sourcesJar() -javadocJar() \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts index f1e62d4b56907..cd67ed16b5b8a 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts @@ -1,34 +1,14 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.pill.PillExtension plugins { - kotlin("jvm") + id("gradle-plugin-common-configuration") id("jps-compatible") } -publish() - -standardPublicJars() - dependencies { - compile(kotlinStdlib()) - - compileOnly(gradleApi()) compileOnly("com.android.tools.build:gradle:3.4.0") } pill { variant = PillExtension.Variant.FULL } - -tasks { - withType { - kotlinOptions.languageVersion = "1.3" - kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check") - } - - named("jar") { - callGroovy("manifestAttributes", manifest, project) - } -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt index 6276fb2973467..3b456d5664273 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt @@ -151,4 +151,31 @@ class SimpleKotlinGradleIT : BaseGradleIT() { assertSuccessful() } } + + // Should not produce kotlin-stdlib version conflict on Kotlin files compilation in 'buildSrc' module" + @Test + internal fun testKotlinDslStdlibVersionConflict() { + val project = Project(projectName = "buildSrcUsingKotlinCompilationAndKotlinPlugin") + listOf( + "compileClasspath", + "compileOnly", + "runtimeClasspath" + ).forEach { configuration -> + project.build("-p", "buildSrc", "dependencies", "--configuration", configuration) { + assertSuccessful() + listOf( + "org.jetbrains.kotlin:kotlin-stdlib:${defaultBuildOptions().kotlinVersion}", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${defaultBuildOptions().kotlinVersion}", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${defaultBuildOptions().kotlinVersion}", + "org.jetbrains.kotlin:kotlin-stdlib-common:${defaultBuildOptions().kotlinVersion}", + "org.jetbrains.kotlin:kotlin-reflect:${defaultBuildOptions().kotlinVersion}", + "org.jetbrains.kotlin:kotlin-script-runtime:${defaultBuildOptions().kotlinVersion}" + ).forEach { + assertNotContains(it) + } + } + } + + project.build("assemble") { assertSuccessful() } + } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/build.gradle.kts new file mode 100644 index 0000000000000..274be350f5a94 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + kotlin("jvm") +} + +repositories { + mavenLocal() + mavenCentral() +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/build.gradle.kts new file mode 100644 index 0000000000000..f23198d06170a --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${property("kotlin_version")}") +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/src/main/kotlin/ProjectExt.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/src/main/kotlin/ProjectExt.kt new file mode 100644 index 0000000000000..0f5e46e641094 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/buildSrc/src/main/kotlin/ProjectExt.kt @@ -0,0 +1,3 @@ +import org.gradle.api.Project + +fun Project.nameLength() = name.length diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/src/main/kotlin/main.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/src/main/kotlin/main.kt new file mode 100644 index 0000000000000..0f4f205330fa1 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/buildSrcUsingKotlinCompilationAndKotlinPlugin/src/main/kotlin/main.kt @@ -0,0 +1,8 @@ +/* + * Copyright 2010-2021 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. + */ + +fun main() { + println("Hello World!") +} diff --git a/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts index cd28b8da42a77..3baa3c8c19ff0 100644 --- a/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts @@ -1,31 +1,10 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.pill.PillExtension plugins { - kotlin("jvm") + id("gradle-plugin-common-configuration") id("jps-compatible") } -publish() - -standardPublicJars() - -dependencies { - compile(kotlinStdlib()) -} - pill { variant = PillExtension.Variant.FULL } - -tasks { - withType { - kotlinOptions.languageVersion = "1.3" - kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check") - } - - named("jar") { - callGroovy("manifestAttributes", manifest, project) - } -} diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts index 87b031f926d92..3506f2a2b5353 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts @@ -1,11 +1,10 @@ import org.jetbrains.dokka.gradle.DokkaTask -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.pill.PillExtension plugins { java - kotlin("jvm") `java-gradle-plugin` + id("gradle-plugin-common-configuration") id("org.jetbrains.dokka") id("jps-compatible") } @@ -17,13 +16,8 @@ configure { isAutomatedPublishing = false } -publish() - val jarContents by configurations.creating -sourcesJar() -javadocJar() - repositories { google() maven("https://plugins.gradle.org/m2/") @@ -40,7 +34,6 @@ dependencies { compileOnly(project(":compiler:incremental-compilation-impl")) compileOnly(project(":daemon-common")) - implementation(kotlinStdlib()) implementation(project(":kotlin-util-klib")) compileOnly(project(":native:kotlin-native-utils")) compileOnly(project(":kotlin-reflect-api")) @@ -66,8 +59,7 @@ dependencies { compileOnly("com.android.tools.build:builder:3.4.0") compileOnly("com.android.tools.build:builder-model:3.4.0") compileOnly("org.codehaus.groovy:groovy-all:2.4.12") - compileOnly(gradleApi()) - + compileOnly(project(":kotlin-reflect")) compileOnly(intellijCoreDep()) { includeJars("intellij-core") } runtimeOnly(projectRuntimeJar(":kotlin-compiler-embeddable")) @@ -76,7 +68,6 @@ dependencies { runtimeOnly(projectRuntimeJar(":kotlin-compiler-runner")) runtimeOnly(projectRuntimeJar(":kotlin-scripting-compiler-embeddable")) runtimeOnly(projectRuntimeJar(":kotlin-scripting-compiler-impl-embeddable")) - runtimeOnly(project(":kotlin-reflect")) jarContents(compileOnly(intellijDep()) { includeJars("asm-all", "gson", "serviceMessages", rootProject = rootProject) @@ -96,7 +87,6 @@ dependencies { testImplementation(projectTests(":kotlin-build-common")) testImplementation(project(":kotlin-android-extensions")) testImplementation(project(":kotlin-compiler-runner")) - testImplementation(project(":kotlin-test::kotlin-test-junit")) testImplementation("junit:junit:4.12") testImplementation(project(":kotlin-gradle-statistics")) testCompileOnly(project(":kotlin-reflect-api")) @@ -120,13 +110,6 @@ runtimeJar(rewriteDefaultJarDepsToShadedCompiler()).configure { } tasks { - withType { - kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String - kotlinOptions.languageVersion = "1.3" - kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check") - } - named("processResources") { val propertiesToExpand = mapOf( "projectVersion" to project.version, @@ -140,10 +123,6 @@ tasks { } } - named("jar") { - callGroovy("manifestAttributes", manifest, project) - } - withType().configureEach { failOnWarning.set(true) enableStricterValidation.set(true) diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/JvmAndAndroidIntermediateSourceSetTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/JvmAndAndroidIntermediateSourceSetTest.kt index 8d2f5ec2039b5..41beb8779a1cb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/JvmAndAndroidIntermediateSourceSetTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/JvmAndAndroidIntermediateSourceSetTest.kt @@ -9,17 +9,19 @@ package org.jetbrains.kotlin.gradle import com.android.build.gradle.LibraryExtension -import org.gradle.api.Project import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.plugins.ExtraPropertiesExtension import org.gradle.testfixtures.ProjectBuilder +import org.hamcrest.MatcherAssert.assertThat import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.buildKotlinProjectStructureMetadata -import kotlin.test.* +import org.junit.Before +import org.junit.Test + class JvmAndAndroidIntermediateSourceSetTest { @@ -27,7 +29,7 @@ class JvmAndAndroidIntermediateSourceSetTest { private lateinit var kotlin: KotlinMultiplatformExtension private lateinit var jvmAndAndroidMain: KotlinSourceSet - @BeforeTest + @Before fun setup() { project = ProjectBuilder.builder().build() as ProjectInternal project.extensions.getByType(ExtraPropertiesExtension::class.java).set("kotlin.mpp.enableGranularSourceSetsMetadata", "true") @@ -66,34 +68,60 @@ class JvmAndAndroidIntermediateSourceSetTest { .filterIsInstance>() .filter { it.name == jvmAndAndroidMain.name } - assertEquals( - 1, jvmAndAndroidMainMetadataCompilations.size, - "Expected exactly one metadata compilation created for jvmAndAndroidMain source set" + assertThat( + "Expected exactly one metadata compilation created for jvmAndAndroidMain source set", + 1 == jvmAndAndroidMainMetadataCompilations.size ) val compilation = jvmAndAndroidMainMetadataCompilations.single() - assertFalse( - compilation.compileKotlinTaskProvider.get().enabled, - "Expected compilation task to be disabled, because not supported yet" + assertThat( + "Expected compilation task to be disabled, because not supported yet", + !compilation.compileKotlinTaskProvider.get().enabled ) } @Test fun `KotlinProjectStructureMetadata jvmAndAndroidMain exists in jvm variants`() { project.evaluate() - val metadata = assertNotNull(buildKotlinProjectStructureMetadata(project)) - assertTrue("jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["jvmApiElements"].orEmpty()) - assertTrue("jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["jvmRuntimeElements"].orEmpty()) + val metadata = buildKotlinProjectStructureMetadata(project) + assertThat( + "Kotlin project structure metadata is null", + metadata != null + ) + assertThat( + "'jvmAndAndroidMain' source set is not included into 'jvmApiElements' variant metadata", + "jvmAndAndroidMain" in metadata!!.sourceSetNamesByVariantName["jvmApiElements"].orEmpty() + ) + assertThat( + "'jvmAndAndroidName' source set is not included into 'jvmRuntimeElements' variant metadata", + "jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["jvmRuntimeElements"].orEmpty() + ) } @Test fun `KotlinProjectStructureMetadata jvmAndAndroidMain exists in android variants`() { project.evaluate() - val metadata = assertNotNull(buildKotlinProjectStructureMetadata(project)) - assertTrue("jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["debugApiElements"].orEmpty()) - assertTrue("jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["debugRuntimeElements"].orEmpty()) - assertTrue("jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["releaseApiElements"].orEmpty()) - assertTrue("jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["releaseRuntimeElements"].orEmpty()) + val metadata = buildKotlinProjectStructureMetadata(project) + assertThat( + "Kotlin project structure metadata is null", + metadata != null + ) + assertThat( + "'jvmAndAndroidMain' source set is not included into 'debugApiElements' variant metadata", + "jvmAndAndroidMain" in metadata!!.sourceSetNamesByVariantName["debugApiElements"].orEmpty() + ) + assertThat( + "'jvmAndAndroidMain' source set is not included into 'debugRuntimeElements' variant metadata", + "jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["debugRuntimeElements"].orEmpty() + ) + assertThat( + "'jvmAndAndroidMain' source set is not included into 'releaseApiElements' variant metadata", + "jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["releaseApiElements"].orEmpty() + ) + assertThat( + "'jvmAndAndroidMain' source set is not included into 'releaseRuntimeElements' variant metadata", + "jvmAndAndroidMain" in metadata.sourceSetNamesByVariantName["releaseRuntimeElements"].orEmpty() + ) } @Test @@ -102,10 +130,16 @@ class JvmAndAndroidIntermediateSourceSetTest { target.publishLibraryVariants = emptyList() project.evaluate() val kotlinComponents = target.kotlinComponents - assertTrue(kotlinComponents.isNotEmpty(), "Expected at least one KotlinComponent to be present") + assertThat( + "Expected at least one KotlinComponent to be present", + kotlinComponents.isNotEmpty() + ) kotlinComponents.forEach { component -> - assertFalse(component.publishable, "Expected component to not publishable, because no publication is configured") + assertThat( + "Expected component to not publishable, because no publication is configured", + !component.publishable + ) } } @@ -115,14 +149,23 @@ class JvmAndAndroidIntermediateSourceSetTest { target.publishLibraryVariants = listOf("release") project.evaluate() val kotlinComponents = target.kotlinComponents - assertTrue(kotlinComponents.isNotEmpty(), "Expected at least one KotlinComponent to be present") + assertThat( + "Expected at least one KotlinComponent to be present", + kotlinComponents.isNotEmpty() + ) kotlinComponents.forEach { component -> val isReleaseComponent = "release" in component.name.toLowerCase() if (isReleaseComponent) { - assertTrue(component.publishable, "Expected release component to be marked as publishable") + assertThat( + "Expected release component to be marked as publishable", + component.publishable + ) } else { - assertFalse(component.publishable, "Expected non-release component to be marked as not publishable") + assertThat( + "Expected non-release component to be marked as not publishable", + !component.publishable + ) } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidDependsOnEdgesTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidDependsOnEdgesTest.kt index ed3c60e7f6ace..ef31be623a20b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidDependsOnEdgesTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidDependsOnEdgesTest.kt @@ -10,11 +10,11 @@ package org.jetbrains.kotlin.gradle import com.android.build.gradle.LibraryExtension import org.gradle.api.internal.project.ProjectInternal import org.gradle.testfixtures.ProjectBuilder +import org.hamcrest.MatcherAssert.assertThat import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.kotlinExtension import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -import kotlin.test.Test -import kotlin.test.assertEquals +import org.junit.Test class KotlinAndroidDependsOnEdgesTest { @Test @@ -41,19 +41,19 @@ class KotlinAndroidDependsOnEdgesTest { val androidTest = kotlin.sourceSets.getByName("androidTest") val androidAndroidTest = kotlin.sourceSets.getByName("androidAndroidTest") - assertEquals( - setOf(commonMain), androidMain.dependsOn, - "Expected androidMain to dependOn commonMain" + assertThat( + "Expected androidMain to dependOn commonMain", + setOf(commonMain) == androidMain.dependsOn ) - assertEquals( - setOf(commonTest), androidTest.dependsOn, - "Expected androidTest to dependOn commonTest" + assertThat( + "Expected androidTest to dependOn commonTest", + setOf(commonTest) == androidTest.dependsOn ) - assertEquals( - setOf(commonTest), androidAndroidTest.dependsOn, - "Expected androidAndroidTest to dependOn commonTest" + assertThat( + "Expected androidAndroidTest to dependOn commonTest", + setOf(commonTest) == androidAndroidTest.dependsOn ) } @@ -90,19 +90,19 @@ class KotlinAndroidDependsOnEdgesTest { val androidTest = kotlin.sourceSets.getByName("androidTest") val androidAndroidTest = kotlin.sourceSets.getByName("androidAndroidTest") - assertEquals( - setOf(commonMain, jvmMain).sorted(), androidMain.dependsOn.sorted(), - "Expected androidMain to depend on commonMain and jvmMain" + assertThat( + "Expected androidMain to depend on commonMain and jvmMain", + setOf(commonMain, jvmMain).sorted() == androidMain.dependsOn.sorted() ) - assertEquals( - setOf(commonTest), androidTest.dependsOn, - "Expected androidTest to only depend on commonTest" + assertThat( + "Expected androidTest to only depend on commonTest", + setOf(commonTest) == androidTest.dependsOn ) - assertEquals( - setOf(commonTest), androidAndroidTest.dependsOn, - "Expected androidAndroidTest to only depend on commonTest" + assertThat( + "Expected androidAndroidTest to only depend on commonTest", + setOf(commonTest) == androidAndroidTest.dependsOn ) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt index 60ba7cf5a9a68..0d615f191e4e5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/MppPublicationTest.kt @@ -11,10 +11,10 @@ import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication import org.gradle.testfixtures.ProjectBuilder +import org.hamcrest.MatcherAssert.assertThat import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import kotlin.test.Test -import kotlin.test.assertTrue -import kotlin.test.fail +import org.junit.Assert.fail +import org.junit.Test class MppPublicationTest { @@ -50,7 +50,10 @@ class MppPublicationTest { .filterIsInstance() .forEach { publication -> val sources = publication.artifacts.filter { artifact -> artifact.classifier == "sources" } - assertTrue(sources.isNotEmpty(), "Expected at least one sources artifact for ${publication.name}") + assertThat( + "Expected at least one sources artifact for ${publication.name}", + sources.isNotEmpty() + ) } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/SyncKotlinAndAndroidSourceSetsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/SyncKotlinAndAndroidSourceSetsTest.kt index dd0bc6c5eec24..f82391abfcbb7 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/SyncKotlinAndAndroidSourceSetsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/SyncKotlinAndAndroidSourceSetsTest.kt @@ -11,10 +11,12 @@ package org.jetbrains.kotlin.gradle import com.android.build.gradle.LibraryExtension import org.gradle.api.internal.project.ProjectInternal import org.gradle.testfixtures.ProjectBuilder +import org.hamcrest.MatcherAssert.assertThat import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension import org.jetbrains.kotlin.gradle.plugin.mpp.kotlinSourceSet -import kotlin.test.* +import org.junit.Before +import org.junit.Test class SyncKotlinAndAndroidSourceSetsTest { @@ -22,7 +24,7 @@ class SyncKotlinAndAndroidSourceSetsTest { private lateinit var kotlin: KotlinMultiplatformExtension private lateinit var android: LibraryExtension - @BeforeTest + @Before fun setup() { project = ProjectBuilder.builder().build() as ProjectInternal project.plugins.apply("kotlin-multiplatform") @@ -45,11 +47,11 @@ class SyncKotlinAndAndroidSourceSetsTest { val kotlinAndroidMainSourceSet = kotlin.sourceSets.getByName("androidMain") val androidMainSourceSet = android.sourceSets.getByName("main") - assertTrue( - kotlinAndroidMainSourceSet.kotlin.srcDirs.containsAll(androidMainSourceSet.java.srcDirs), + assertThat( "Expected all Android java srcDirs in Kotlin source set.\n" + "Kotlin=${kotlinAndroidMainSourceSet.kotlin.srcDirs}\n" + - "Android=${androidMainSourceSet.java.srcDirs}" + "Android=${androidMainSourceSet.java.srcDirs}", + kotlinAndroidMainSourceSet.kotlin.srcDirs.containsAll(androidMainSourceSet.java.srcDirs) ) } @@ -60,11 +62,11 @@ class SyncKotlinAndAndroidSourceSetsTest { val kotlinAndroidTestSourceSet = kotlin.sourceSets.getByName("androidTest") val testSourceSet = android.sourceSets.getByName("test") - assertTrue( - kotlinAndroidTestSourceSet.kotlin.srcDirs.containsAll(testSourceSet.java.srcDirs), + assertThat( "Expected all Android java srcDirs in Kotlin source set.\n" + "Kotlin=${kotlinAndroidTestSourceSet.kotlin.srcDirs}\n" + - "Android=${testSourceSet.java.srcDirs}" + "Android=${testSourceSet.java.srcDirs}", + kotlinAndroidTestSourceSet.kotlin.srcDirs.containsAll(testSourceSet.java.srcDirs) ) } @@ -75,16 +77,16 @@ class SyncKotlinAndAndroidSourceSetsTest { val kotlinAndroidAndroidTestSourceSet = kotlin.sourceSets.getByName("androidAndroidTest") val androidTestSourceSet = android.sourceSets.getByName("androidTest") - assertTrue( - project.file("src/androidTest/kotlin") !in kotlinAndroidAndroidTestSourceSet.kotlin.srcDirs, + assertThat( "Expected no source directory of 'androidTest' kotlin source set (Unit Test) " + - "being present in 'androidAndroidTest' kotlin source set (Instrumented Test)" + "being present in 'androidAndroidTest' kotlin source set (Instrumented Test)", + project.file("src/androidTest/kotlin") !in kotlinAndroidAndroidTestSourceSet.kotlin.srcDirs ) - assertTrue( - project.file("src/androidTest/kotlin") !in androidTestSourceSet.java.srcDirs, + assertThat( "Expected no source directory of 'androidTest' kotlin source set (Unit Test) " + - "being present in 'androidTest' Android source set (Instrumented Test)" + "being present in 'androidTest' Android source set (Instrumented Test)", + project.file("src/androidTest/kotlin") !in androidTestSourceSet.java.srcDirs ) } @@ -101,9 +103,20 @@ class SyncKotlinAndAndroidSourceSetsTest { project.evaluate() fun assertSourceSetsExist(androidName: String, kotlinName: String) { - val androidSourceSet = assertNotNull(android.sourceSets.findByName(androidName), "Expected Android source set '$androidName'") - val kotlinSourceSet = assertNotNull(kotlin.sourceSets.findByName(kotlinName), "Expected Kotlin source set '$kotlinName'") - assertSame(kotlinSourceSet, androidSourceSet.kotlinSourceSet) + val androidSourceSet = android.sourceSets.findByName(androidName) + assertThat( + "Expected Android source set '$androidName'", + androidSourceSet != null + ) + val kotlinSourceSet = kotlin.sourceSets.findByName(kotlinName) + assertThat( + "Expected Kotlin source set '$kotlinName'", + kotlinSourceSet != null + ) + assertThat( + "Kotlin source set is not the same as android source set", + kotlinSourceSet === androidSourceSet?.kotlinSourceSet + ) } assertSourceSetsExist("freeBetaDebug", "androidFreeBetaDebug") @@ -135,20 +148,20 @@ class SyncKotlinAndAndroidSourceSetsTest { kotlin.sourceSets.toSet().allPairs() .forEach { (sourceSetA, sourceSetB) -> val sourceDirsInBothSourceSets = sourceSetA.kotlin.srcDirs.intersect(sourceSetB.kotlin.srcDirs) - assertTrue( - sourceDirsInBothSourceSets.isEmpty(), + assertThat( "Expected disjoint source directories in source sets. " + - "Found $sourceDirsInBothSourceSets present in ${sourceSetA.name}(Kotlin) and ${sourceSetB.name}(Kotlin)" + "Found $sourceDirsInBothSourceSets present in ${sourceSetA.name}(Kotlin) and ${sourceSetB.name}(Kotlin)", + sourceDirsInBothSourceSets.isEmpty() ) } android.sourceSets.toSet().allPairs() .forEach { (sourceSetA, sourceSetB) -> val sourceDirsInBothSourceSets = sourceSetA.java.srcDirs.intersect(sourceSetB.java.srcDirs) - assertTrue( - sourceDirsInBothSourceSets.isEmpty(), + assertThat( "Expected disjoint source directories in source sets. " + - "Found $sourceDirsInBothSourceSets present in ${sourceSetA.name}(Android) and ${sourceSetB.name}(Android)" + "Found $sourceDirsInBothSourceSets present in ${sourceSetA.name}(Android) and ${sourceSetB.name}(Android)", + sourceDirsInBothSourceSets.isEmpty() ) } } @@ -165,9 +178,9 @@ class SyncKotlinAndAndroidSourceSetsTest { project.evaluate() - assertTrue( - kotlinAndroidMain.kotlin.srcDirs.containsAll(setOf(project.file("fromKotlin"), project.file("fromAndroid"))), - "Expected custom configured source directories being present on kotlin source set after evaluation" + assertThat( + "Expected custom configured source directories being present on kotlin source set after evaluation", + kotlinAndroidMain.kotlin.srcDirs.containsAll(setOf(project.file("fromKotlin"), project.file("fromAndroid"))) ) } @@ -176,13 +189,22 @@ class SyncKotlinAndAndroidSourceSetsTest { kotlin.android() val main = android.sourceSets.getByName("main") - assertSame(kotlin.sourceSets.getByName("androidMain"), main.kotlinSourceSet) + assertThat( + "'androidMain' source set is not the same as 'main.kotlinSourceSet'", + kotlin.sourceSets.getByName("androidMain") === main.kotlinSourceSet + ) val test = android.sourceSets.getByName("test") - assertSame(kotlin.sourceSets.getByName("androidTest"), test.kotlinSourceSet) + assertThat( + "'androidTest' source set is not the same as 'test.kotlinSourceSet'", + kotlin.sourceSets.getByName("androidTest") === test.kotlinSourceSet + ) val androidTest = android.sourceSets.getByName("androidTest") - assertSame(kotlin.sourceSets.getByName("androidAndroidTest"), androidTest.kotlinSourceSet) + assertThat( + "'androidAndroidTest' source set is not the same as 'androidTest.kotlinSourceSet'", + kotlin.sourceSets.getByName("androidAndroidTest") === androidTest.kotlinSourceSet + ) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/mpp/CompilationSpecificPluginPath.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/mpp/CompilationSpecificPluginPath.kt index e322aec359763..ed56f06fd70a1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/mpp/CompilationSpecificPluginPath.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/mpp/CompilationSpecificPluginPath.kt @@ -11,12 +11,13 @@ import org.gradle.api.artifacts.Configuration import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.plugins.ExtraPropertiesExtension import org.gradle.api.provider.Provider +import org.gradle.internal.impldep.org.hamcrest.MatcherAssert.assertThat import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.kotlinExtension import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.tasks.* -import kotlin.test.* +import org.junit.Test internal class CompilationSpecificPluginPath { @Test @@ -54,11 +55,26 @@ internal class CompilationSpecificPluginPath { project.evaluate() // Then expect native artifact to be used for nativeMain metadata compilation - assertEquals(setOf("native"), project.compileTaskSubplugins("compileNativeMainKotlinMetadata")) - assertEquals(setOf("common"), project.compileTaskSubplugins("compileKotlinMetadata")) - assertEquals(setOf("common"), project.compileTaskSubplugins("compileCommonMainKotlinMetadata")) - assertEquals(setOf("common"), project.compileTaskSubplugins("compileKotlinJvm")) - assertEquals(setOf("native"), project.compileTaskSubplugins("compileKotlinLinuxX64")) + assertThat( + "'compileNativeMainKotlinMetadata' task does not have 'native' subplugin", + setOf("native") == project.compileTaskSubplugins("compileNativeMainKotlinMetadata") + ) + assertThat( + "'compileKotlinMetadata' task does not have 'common' task subplugin", + setOf("common") == project.compileTaskSubplugins("compileKotlinMetadata") + ) + assertThat( + "'compileCommonMainKotlinMetadata' task does not have 'common' task subplugin", + setOf("common") == project.compileTaskSubplugins("compileCommonMainKotlinMetadata") + ) + assertThat( + "'compileKotlinJvm' task does not have 'common' task subplugin", + setOf("common") == project.compileTaskSubplugins("compileKotlinJvm") + ) + assertThat( + "'compileKotlinLinuxX64' task does not have 'native' task subplugin", + setOf("native") == project.compileTaskSubplugins("compileKotlinLinuxX64") + ) } @Test @@ -76,7 +92,12 @@ internal class CompilationSpecificPluginPath { .map(String::capitalize) .flatMap { listOf(pluginClassPathConfiguration(it, "main"), pluginClassPathConfiguration(it, "test")) } .plus(pluginClassPathConfiguration("metadata", "main")) // and also one for metadata - .forEach { assertNotNull(project.configurations.findByName(it), "Configuration $it should exist") } + .forEach { + assertThat( + "Configuration $it should exist", + project.configurations.findByName(it) != null + ) + } } @Test @@ -100,13 +121,22 @@ internal class CompilationSpecificPluginPath { project.evaluate() // Then each plugin classpath should have its own dependency - assertEquals(listOf("jvmOnly"), project.subplugins("desktop")) - assertEquals(listOf("jsOnly"), project.subplugins("web")) + assertThat( + "'desktop' subplugin does not have only 'jvmOnly' dependency", + listOf("jvmOnly") == project.subplugins("desktop") + ) + assertThat( + "'web' subplugin does not have only 'jsOnly' dependency", + listOf("jsOnly") == project.subplugins("web") + ) // And each compilation task should have its own plugin classpath val compileDesktop = project.tasks.getByName("compileKotlinDesktop") as KotlinCompile val expectedConfig = project.configurations.getByName(pluginClassPathConfiguration("desktop", "main")) - assertEquals(expectedConfig, compileDesktop.pluginClasspath) + assertThat( + "'compileKotlinDesktop' does not equals expected classpath", + expectedConfig == compileDesktop.pluginClasspath + ) } @Test @@ -130,10 +160,16 @@ internal class CompilationSpecificPluginPath { project.evaluate() // Expect jvm target have both artifacts - assertEquals(listOf("common1", "common2"), project.subplugins("jvm")) + assertThat( + "'jvm' target does not have expected artifacts", + listOf("common1", "common2") == project.subplugins("jvm") + ) // And native target should have only NativeSpecificPlugin artifacts - assertEquals(listOf("native"), project.subplugins("linuxX64")) + assertThat( + "'native' target does not have expected artifacts", + listOf("native") == project.subplugins("linuxX64") + ) } @Test @@ -149,7 +185,10 @@ internal class CompilationSpecificPluginPath { .configurations .getByName(pluginClassPathConfiguration("linuxX64", "main")) - assertFalse(nativeConfig.isTransitive) + assertThat( + "Native configuration is transitive", + !nativeConfig.isTransitive + ) } @Test @@ -168,11 +207,26 @@ internal class CompilationSpecificPluginPath { project.evaluate() // Then ALL compilations should have shared plugin EXCEPT native - assertTrue("shared" in project.subplugins("jvm")) - assertTrue("shared" in project.subplugins("js")) - assertTrue("shared" in project.subplugins("js", "test")) - assertTrue("shared" in project.subplugins("metadata")) - assertTrue("shared" !in project.subplugins("native")) + assertThat( + "'jvm' compilation does not contain 'shared' dependency", + "shared" in project.subplugins("jvm") + ) + assertThat( + "'js' compilation does not contain 'shared' dependency", + "shared" in project.subplugins("js") + ) + assertThat( + "'js' test compilation does not contain 'shared' dependency", + "shared" in project.subplugins("js", "test") + ) + assertThat( + "'metadata' compilation does not contain 'shared' dependency", + "shared" in project.subplugins("metadata") + ) + assertThat( + "'native' compilation does not contain 'shared' dependency", + "shared" !in project.subplugins("native") + ) } @Test @@ -191,13 +245,28 @@ internal class CompilationSpecificPluginPath { project.evaluate() // Then ALL native compilations should have shared plugin - assertTrue("shared" in project.subplugins("linux")) - assertTrue("shared" in project.subplugins("mac")) - assertTrue("shared" in project.subplugins("mac", "test")) + assertThat( + "'linux' compilation does not contain 'shared' dependency", + "shared" in project.subplugins("linux") + ) + assertThat( + "'mac' compilation does not contain 'shared' dependency", + "shared" in project.subplugins("mac") + ) + assertThat( + "'mac' test compilation does not contain 'shared' dependency", + "shared" in project.subplugins("mac", "test") + ) // And all non-native should not have it - assertTrue("shared" !in project.subplugins("metadata")) - assertTrue("shared" !in project.subplugins("jvm")) + assertThat( + "'metadata' compilation does not contain 'shared' dependency", + "shared" !in project.subplugins("metadata") + ) + assertThat( + "'jvm' compilation does not contain 'shared' dependency", + "shared" !in project.subplugins("jvm") + ) } private fun pluginClassPathConfiguration(target: String, compilation: String) = diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 1f7f981ecff66..9a0c2f349c5a6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -102,26 +102,29 @@ abstract class AbstractKotlinCompileTool @get:InputFiles internal val computedCompilerClasspath: List by lazy { compilerClasspath?.takeIf { it.isNotEmpty() } - ?: compilerJarFile?.let { + ?: compilerJarFile?.let { compilerJarFile -> // a hack to remove compiler jar from the cp, will be dropped when compilerJarFile will be removed - listOf(it) + findKotlinCompilerClasspath(project).filter { !it.name.startsWith("kotlin-compiler") } + listOf(compilerJarFile) + getCompilerConfigurationFiles() + .filter { !it.name.startsWith("kotlin-compiler") } } ?: if (!useFallbackCompilerSearch) { - try { - project.configurations.getByName(COMPILER_CLASSPATH_CONFIGURATION_NAME).resolve().toList() - } catch (e: Exception) { - logger.error( - "Could not resolve compiler classpath. " + - "Check if Kotlin Gradle plugin repository is configured in $project." - ) - throw e - } + getCompilerConfigurationFiles() } else { findKotlinCompilerClasspath(project) } ?: throw IllegalStateException("Could not find Kotlin Compiler classpath") } + private fun getCompilerConfigurationFiles() = try { + project.configurations.getByName(COMPILER_CLASSPATH_CONFIGURATION_NAME).resolve().toList() + } catch (e: Exception) { + logger.error( + "Could not resolve compiler classpath. " + + "Check if Kotlin Gradle plugin repository is configured in $project." + ) + throw e + } + protected abstract fun findKotlinCompilerClasspath(project: Project): List } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/TCServiceMessageOutputStreamHandlerTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/TCServiceMessageOutputStreamHandlerTest.kt index 944280d09d4f0..1aa1dca7ae8d2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/TCServiceMessageOutputStreamHandlerTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/TCServiceMessageOutputStreamHandlerTest.kt @@ -8,13 +8,13 @@ package org.jetbrains.kotlin.gradle.internal.testing import jetbrains.buildServer.messages.serviceMessages.ServiceMessage import jetbrains.buildServer.messages.serviceMessages.ServiceMessageParserCallback import jetbrains.buildServer.messages.serviceMessages.TestFailed +import org.junit.Assert.assertEquals import org.junit.Test import org.slf4j.event.EventRecodingLogger import org.slf4j.event.SubstituteLoggingEvent import org.slf4j.helpers.SubstituteLogger import java.text.ParseException import java.util.concurrent.ArrayBlockingQueue -import kotlin.test.assertEquals class TCServiceMessageOutputStreamHandlerTest { private val client = Mock() diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TCServiceMessagesClientTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TCServiceMessagesClientTest.kt index 2461407257a6d..bc44492c010b8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TCServiceMessagesClientTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TCServiceMessagesClientTest.kt @@ -6,8 +6,8 @@ import org.jetbrains.kotlin.gradle.internal.testing.RecordingTestResultProcessor import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesClient import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesClientSettings import org.jetbrains.kotlin.test.util.trimTrailingWhitespaces +import org.junit.Assert.assertEquals import org.slf4j.LoggerFactory -import kotlin.test.assertEquals open class TCServiceMessagesClientTest { protected var rootNodeName: String = "root" diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TestCrash.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TestCrash.kt index 873e53b5c024e..4ea4f71ac2cf0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TestCrash.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/internal/testing/tcsmc/TestCrash.kt @@ -7,8 +7,8 @@ package org.jetbrains.kotlin.gradle.internal.testing.tcsmc import jetbrains.buildServer.messages.serviceMessages.TestStarted import jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted +import org.junit.Assert.assertEquals import org.junit.Test -import kotlin.test.assertEquals class TestCrash : TCServiceMessagesClientTest() { @Test diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KaptModelBuilderTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KaptModelBuilderTest.kt index 555c1718ff5df..c43860fc1784a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KaptModelBuilderTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KaptModelBuilderTest.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.gradle.model.builder import org.jetbrains.kotlin.gradle.model.Kapt +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Test -import kotlin.test.assertFalse -import kotlin.test.assertTrue class KaptModelBuilderTest { @Test diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinAndroidExtensionModelBuilderTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinAndroidExtensionModelBuilderTest.kt index e716e81cd528b..a456b338f9da3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinAndroidExtensionModelBuilderTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinAndroidExtensionModelBuilderTest.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.gradle.model.builder import org.jetbrains.kotlin.gradle.model.KotlinAndroidExtension +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Test -import kotlin.test.assertFalse -import kotlin.test.assertTrue class KotlinAndroidExtensionModelBuilderTest { @Test diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt index b0c9ca7b1c565..0ad81a756b0bc 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilderTest.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.gradle.model.builder import org.jetbrains.kotlin.gradle.model.KotlinProject +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Test -import kotlin.test.assertFalse -import kotlin.test.assertTrue class KotlinModelBuilderTest { @Test diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/KotlinCompilationsModuleGroupsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/KotlinCompilationsModuleGroupsTest.kt index 69b8bdaa0165d..3f05bf0c6ca54 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/KotlinCompilationsModuleGroupsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/internal/KotlinCompilationsModuleGroupsTest.kt @@ -8,9 +8,9 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.internal import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.sources.MockKotlinCompilation import org.jetbrains.kotlin.gradle.plugin.sources.MockKotlinSourceSet +import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test -import kotlin.test.assertEquals class KotlinCompilationsModuleGroupsTest { private lateinit var instance: KotlinCompilationsModuleGroups diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetVisibilityInferenceTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetVisibilityInferenceTest.kt index 0d7d1e67a97c7..1a81f2deb9a39 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetVisibilityInferenceTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetVisibilityInferenceTest.kt @@ -13,9 +13,9 @@ import org.gradle.api.tasks.TaskProvider import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions import org.jetbrains.kotlin.gradle.dsl.KotlinCompile import org.jetbrains.kotlin.gradle.plugin.* -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith +import org.junit.Assert.assertEquals +import org.junit.Assert.fail +import org.junit.Test class SourceSetVisibilityTest { @Test @@ -56,22 +56,28 @@ class SourceSetVisibilityTest { checkInferredSourceSetsVisibility("jvmTest", *arrayOf()) - assertFailsWith { + try { checkSourceSetVisibilityRequirements(setOf(jvmTest), compilationsBySourceSets) - }.apply { - assertEquals(jvmTest, sourceSet) - assertEquals(emptyList(), visibleSourceSets) - assertEquals(setOf(jvmMain), requiredButNotVisible) - assertEquals(setOf(jvmTestCompilation), compilations) + fail() + } catch (e: UnsatisfiedSourceSetVisibilityException) { + with(e) { + assertEquals(jvmTest, sourceSet) + assertEquals(emptyList(), visibleSourceSets) + assertEquals(setOf(jvmMain), requiredButNotVisible) + assertEquals(setOf(jvmTestCompilation), compilations) + } } - assertFailsWith { + try { checkSourceSetVisibilityRequirements(setOf(commonTest), compilationsBySourceSets) - }.apply { - assertEquals(commonTest, sourceSet) - assertEquals(emptyList(), visibleSourceSets) - assertEquals(setOf(commonMain), requiredButNotVisible) - assertEquals(setOf(jvmTestCompilation), compilations) + fail() + } catch (e: UnsatisfiedSourceSetVisibilityException) { + with(e) { + assertEquals(commonTest, sourceSet) + assertEquals(emptyList(), visibleSourceSets) + assertEquals(setOf(commonMain), requiredButNotVisible) + assertEquals(setOf(jvmTestCompilation), compilations) + } } } @@ -151,13 +157,16 @@ class SourceSetVisibilityTest { val commonIntegrationTest = sourceSetsByName.getValue("commonIntegrationTest") commonIntegrationTest.requiresVisibilityOf(sourceSetsByName.getValue("commonMain")) - assertFailsWith { + try { checkSourceSetVisibilityRequirements(setOf(commonIntegrationTest), compilationsBySourceSets) - }.apply { - assertEquals(commonIntegrationTest, this.sourceSet) - assertEquals(setOf("commonTest"), visibleSourceSets.map { it.name }.toSet()) - assertEquals(setOf("commonMain"), requiredButNotVisible.map { it.name }.toSet()) - assertEquals(setOf("jvm / IntegrationTest", "js / IntegrationTest"), compilations.map { it.name }.toSet()) + fail() + } catch (e: UnsatisfiedSourceSetVisibilityException) { + with(e) { + assertEquals(commonIntegrationTest, this.sourceSet) + assertEquals(setOf("commonTest"), visibleSourceSets.map { it.name }.toSet()) + assertEquals(setOf("commonMain"), requiredButNotVisible.map { it.name }.toSet()) + assertEquals(setOf("jvm / IntegrationTest", "js / IntegrationTest"), compilations.map { it.name }.toSet()) + } } } @@ -182,13 +191,16 @@ class SourceSetVisibilityTest { val jvmTestCompilation = compilation("jvm / test", jvmTest, jvmMainCompilation) val jsTestCompilation = compilation("js / test", jsTest, jsMainCompilation) - assertFailsWith { + try { checkSourceSetVisibilityRequirements(setOf(commonTest), compilationsBySourceSets) - }.apply { - assertEquals(commonTest, this.sourceSet) - assertEquals(listOf(commonMain), visibleSourceSets) - assertEquals(setOf(jvmMain), requiredButNotVisible) - assertEquals(setOf(jvmTestCompilation, jsTestCompilation), compilations) + fail() + } catch (e: UnsatisfiedSourceSetVisibilityException) { + with(e) { + assertEquals(commonTest, this.sourceSet) + assertEquals(listOf(commonMain), visibleSourceSets) + assertEquals(setOf(jvmMain), requiredButNotVisible) + assertEquals(setOf(jvmTestCompilation, jsTestCompilation), compilations) + } } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/NodeJsStackTraceParserKtTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/NodeJsStackTraceParserKtTest.kt index ba61ffb0f3762..c374d672ff378 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/NodeJsStackTraceParserKtTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/NodeJsStackTraceParserKtTest.kt @@ -5,8 +5,8 @@ package org.jetbrains.kotlin.gradle.targets.js.internal +import org.junit.Assert.assertEquals import org.junit.Test -import kotlin.test.assertEquals class NodeJsStackTraceParserKtTest { @Test diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilderTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilderTest.kt index 51c9210123044..75536e3414932 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilderTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilderTest.kt @@ -5,9 +5,9 @@ package org.jetbrains.kotlin.gradle.targets.js.npm +import org.junit.Assert.assertNotNull import org.junit.Test import java.io.File -import kotlin.test.assertNotNull class GradleNodeModuleBuilderTest { @@ -18,7 +18,10 @@ class GradleNodeModuleBuilderTest { val packageJson = fromSrcPackageJson( File("libraries/tools/kotlin-gradle-plugin/src/test/resources/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilderTest/package.json") ) - assertNotNull(packageJson, "package.json should be deserialized") + assertNotNull( + "package.json should be deserialized", + packageJson + ) with(packageJson!!) { listOf( @@ -28,7 +31,10 @@ class GradleNodeModuleBuilderTest { optionalDependencies, bundledDependencies ).forEach { - assertNotNull(it, "Dependencies should deserialized correctly without null") + assertNotNull( + "Dependencies should deserialized correctly without null", + it + ) } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRangeTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRangeTest.kt index 5e85d60151717..e7e8e36d153e2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRangeTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmRangeTest.kt @@ -5,23 +5,24 @@ package org.jetbrains.kotlin.gradle.targets.js.npm -import kotlin.test.Test -import kotlin.test.assertTrue - +import org.junit.Assert.assertTrue +import org.junit.Test class NpmRangeTest { @Test fun intersectTest() { fun assertIntersect(range1: NpmRange, range2: NpmRange, expected: NpmRange?) { val intersection = range1 intersect range2 - assertTrue("Range $range1 and $range2 expected to have intersection $expected, but actual is $intersection") { + assertTrue( + "Range $range1 and $range2 expected to have intersection $expected, but actual is $intersection", intersection == expected - } + ) val symIntersection = range2 intersect range1 - assertTrue("Range $range2 and $range1 expected to have union $expected, but actual is $symIntersection") { + assertTrue( + "Range $range2 and $range1 expected to have union $expected, but actual is $symIntersection", symIntersection == expected - } + ) } val range1 = npmRange(startMajor = 1, endMajor = 2) @@ -91,14 +92,16 @@ class NpmRangeTest { fun unionTest() { fun assertUnion(range1: NpmRange, range2: NpmRange, expected: Set) { val union = (range1 union range2) - assertTrue("Range $range1 and $range2 expected to have union $expected, but actual is $union") { + assertTrue( + "Range $range1 and $range2 expected to have union $expected, but actual is $union", union == expected - } + ) val symUnion = range2 union range1 - assertTrue("Range $range2 and $range1 expected to have union $expected, but actual is $symUnion") { + assertTrue( + "Range $range2 and $range1 expected to have union $expected, but actual is $symUnion", symUnion == expected - } + ) } val range1 = npmRange(startMajor = 1, endMajor = 2) @@ -185,9 +188,10 @@ class NpmRangeTest { fun rangeInvertTest() { fun assertInvert(invertible: NpmRange, expected: Set) { val invert = invertible.invert() - assertTrue("Inverted $invertible should be $expected but found $invert") { + assertTrue( + "Inverted $invertible should be $expected but found $invert", invert == expected - } + ) } assertInvert(npmRange(), emptySet()) @@ -209,9 +213,10 @@ class NpmRangeTest { @Test fun hasIntersectionTest() { fun assertHasIntersection(range1: NpmRange, range2: NpmRange) = - assertTrue("Range $range1 and $range2 expected to have intersection, but actual is not") { + assertTrue( + "Range $range1 and $range2 expected to have intersection, but actual is not", (range1 hasIntersection range2) && (range2 hasIntersection range1) - } + ) assertHasIntersection(npmRange(endMajor = 1), npmRange(endMajor = 2)) assertHasIntersection(npmRange(startMajor = 1), npmRange(startMajor = 2)) @@ -234,9 +239,10 @@ class NpmRangeTest { @Test fun hasNoIntersectionTest() { fun assertHasNoIntersection(range1: NpmRange, range2: NpmRange) = - assertTrue("Range $range1 and $range2 expected to not have intersection, but actual is") { + assertTrue( + "Range $range1 and $range2 expected to not have intersection, but actual is", !(range1 hasIntersection range2) && !(range2 hasIntersection range1) - } + ) assertHasNoIntersection(npmRange(endMajor = 1), npmRange(startMajor = 2)) assertHasNoIntersection(npmRange(startMajor = 1, endMajor = 2), npmRange(startMajor = 3, endMajor = 4)) @@ -288,9 +294,10 @@ class NpmRangeTest { nullRange1, nullRange2 ) - assertTrue("Max start should be ${nullRange2.startVersion} but $maxStart1 found") { + assertTrue( + "Max start should be ${nullRange2.startVersion} but $maxStart1 found", maxStart1 == nullRange2.startVersion - } + ) val startRange1 = npmRange( startMajor = 1 @@ -299,18 +306,20 @@ class NpmRangeTest { startRange1, npmRange() ) - assertTrue("Max start should be ${startRange1.startVersion} but $maxStart2 found") { + assertTrue( + "Max start should be ${startRange1.startVersion} but $maxStart2 found", maxStart2 == startRange1.startVersion - } + ) val startRange2 = npmRange(startMajor = 2) val maxStart3 = maxStart( startRange1, startRange2 ) - assertTrue("Max start should be ${startRange2.startVersion} but $maxStart3 found") { + assertTrue( + "Max start should be ${startRange2.startVersion} but $maxStart3 found", maxStart3 == startRange2.startVersion - } + ) } @Test @@ -321,9 +330,10 @@ class NpmRangeTest { nullRange1, nullRange2 ) - assertTrue("Min start should be ${null} but $minStart1 found") { + assertTrue( + "Min start should be ${null} but $minStart1 found", minStart1 == null - } + ) val startRange1 = npmRange( startMajor = 1 @@ -332,18 +342,20 @@ class NpmRangeTest { startRange1, npmRange() ) - assertTrue("Min start should be ${null} but $minStart2 found") { + assertTrue( + "Min start should be ${null} but $minStart2 found", minStart2 == null - } + ) val startRange2 = npmRange(startMajor = 2) val minStart3 = minStart( startRange1, startRange2 ) - assertTrue("Min start should be ${startRange1.startVersion} but $minStart3 found") { + assertTrue( + "Min start should be ${startRange1.startVersion} but $minStart3 found", minStart3 == startRange1.startVersion - } + ) } @Test @@ -354,9 +366,10 @@ class NpmRangeTest { nullRange1, nullRange2 ) - assertTrue("Max end should be ${null} but $maxEnd1 found") { + assertTrue( + "Max end should be ${null} but $maxEnd1 found", maxEnd1 == null - } + ) val endRange1 = npmRange( endMajor = 1 @@ -365,18 +378,20 @@ class NpmRangeTest { endRange1, npmRange() ) - assertTrue("Max end should be ${null} but $maxEnd2 found") { + assertTrue( + "Max end should be ${null} but $maxEnd2 found", maxEnd2 == null - } + ) val endRange2 = npmRange(endMajor = 2) val maxEnd3 = maxEnd( endRange1, endRange2 ) - assertTrue("Max end should be ${endRange2.endVersion} but $maxEnd3 found") { + assertTrue( + "Max end should be ${endRange2.endVersion} but $maxEnd3 found", maxEnd3 == endRange2.endVersion - } + ) } @Test @@ -387,9 +402,10 @@ class NpmRangeTest { nullRange1, nullRange2 ) - assertTrue("Min end should be ${nullRange1.endVersion} but $minEnd1 found") { + assertTrue( + "Min end should be ${nullRange1.endVersion} but $minEnd1 found", minEnd1 == nullRange1.endVersion - } + ) val endRange1 = npmRange( endMajor = 1 @@ -398,18 +414,20 @@ class NpmRangeTest { endRange1, npmRange() ) - assertTrue("Min end should be ${endRange1.endVersion} but $minEnd2 found") { + assertTrue( + "Min end should be ${endRange1.endVersion} but $minEnd2 found", minEnd2 == endRange1.endVersion - } + ) val endRange2 = npmRange(endMajor = 2) val minEnd3 = minEnd( endRange1, endRange2 ) - assertTrue("Min end should be ${endRange1.endVersion} but $minEnd3 found") { + assertTrue( + "Min end should be ${endRange1.endVersion} but $minEnd3 found", minEnd3 == endRange1.endVersion - } + ) } } @@ -443,4 +461,4 @@ private fun semVer( (minor ?: 0).toBigInteger(), (patch ?: 0).toBigInteger() ) - } \ No newline at end of file + } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/GradleVersionTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/GradleVersionTest.kt index 06441c0ad556d..5a71c8dece7aa 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/GradleVersionTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/GradleVersionTest.kt @@ -16,20 +16,20 @@ package org.jetbrains.kotlin.gradle.utils +import org.hamcrest.MatcherAssert.assertThat import org.junit.Test -import kotlin.test.assertEquals class GradleVersionTest { @Test fun testParse() { fun String.parseToPair() = ParsedGradleVersion.parse(this)?.let { it.major to it.minor } - assertEquals(2 to 1, "2.1".parseToPair()) - assertEquals(2 to 10, "2.10".parseToPair()) - assertEquals(2 to 14, "2.14.1".parseToPair()) - assertEquals(3 to 2, "3.2-rc-1".parseToPair()) - assertEquals(3 to 2, "3.2".parseToPair()) - assertEquals(4 to 0, "4.0".parseToPair()) + assertThat("", 2 to 1 == "2.1".parseToPair()) + assertThat("", 2 to 10 == "2.10".parseToPair()) + assertThat("", 2 to 14 == "2.14.1".parseToPair()) + assertThat("", 3 to 2 == "3.2-rc-1".parseToPair()) + assertThat("", 3 to 2 == "3.2".parseToPair()) + assertThat("", 4 to 0 == "4.0".parseToPair()) } @Test diff --git a/libraries/tools/kotlin-gradle-statistics/build.gradle.kts b/libraries/tools/kotlin-gradle-statistics/build.gradle.kts index 87462cdb2da82..18ceba29f1da2 100644 --- a/libraries/tools/kotlin-gradle-statistics/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-statistics/build.gradle.kts @@ -1,15 +1,13 @@ description = "kotlin-gradle-statistics" plugins { - kotlin("jvm") + id("gradle-plugin-common-configuration") id("jps-compatible") } dependencies { - compileOnly(kotlinStdlib()) - - testCompile(project(":kotlin-test:kotlin-test-junit")) - testCompile("junit:junit:4.12") + testImplementation(project(":kotlin-test:kotlin-test-junit")) + testImplementation("junit:junit:4.12") } sourceSets { diff --git a/native/utils/build.gradle.kts b/native/utils/build.gradle.kts index 1fbf58a862270..c28af3975c518 100644 --- a/native/utils/build.gradle.kts +++ b/native/utils/build.gradle.kts @@ -7,11 +7,11 @@ description = "Kotlin/Native utils" dependencies { compileOnly(kotlinStdlib()) - compile(project(":kotlin-util-io")) + api(project(":kotlin-util-io")) - testCompile(commonDep("junit:junit")) + testImplementation(commonDep("junit:junit")) testCompileOnly(project(":kotlin-reflect-api")) - testRuntime(project(":kotlin-reflect")) + testImplementation(project(":kotlin-reflect")) } sourceSets {