-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KGP] Make kotlin.build.archivesTaskOutputAsFriendModule property public
Add functional test
- Loading branch information
1 parent
623edef
commit 5118405
Showing
4 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
kotlin.internal.suppressGradlePluginErrors=PreHMPPFlagsError | ||
kotlin.mpp.enableCompatibilityMetadataVariant=true | ||
kotlin.internal.mpp.createDefaultMultiplatformPublications=false | ||
kotlin.internal.archivesTaskOutputAsFriendModule=false | ||
kotlin.build.archivesTaskOutputAsFriendModule=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...brains/kotlin/gradle/regressionTests/KT69330StableFriendPathsArchiveTaskDependencyTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2010-2024 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. | ||
*/ | ||
|
||
@file:Suppress("FunctionName") | ||
|
||
package org.jetbrains.kotlin.gradle.regressionTests | ||
|
||
import org.gradle.api.internal.project.ProjectInternal | ||
import org.jetbrains.kotlin.gradle.dependencyResolutionTests.mavenCentralCacheRedirector | ||
import org.jetbrains.kotlin.gradle.dsl.kotlinJvmExtension | ||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_ARCHIVES_TASK_OUTPUT_AS_FRIEND_ENABLED | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.decoratedInstance | ||
import org.jetbrains.kotlin.gradle.util.* | ||
import kotlin.test.Test | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertTrue | ||
|
||
class KT69330StableFriendPathsArchiveTaskDependencyTest { | ||
@Test | ||
fun `test KT-69330 - Task dependency is created so friendPaths are stable at compile time`() { | ||
val project = setupProject() | ||
|
||
assertTrue(hasTestJarDependencyInTest(project), "Expected that test jar is part of the generated friendPath") | ||
|
||
project.tasks.getByName("compileTestKotlin").assertDependsOn(project.tasks.getByName("jar")) | ||
} | ||
|
||
|
||
@Test | ||
fun `test KT-69330 - archivesTaskOutputAsFriendModule=false disables the generation of friendPaths with associated archive`() { | ||
val project = setupProject() | ||
|
||
project.propertiesExtension[KOTLIN_ARCHIVES_TASK_OUTPUT_AS_FRIEND_ENABLED] = "false" | ||
|
||
assertFalse(hasTestJarDependencyInTest(project), "Expected that test jar is not a part of the generated friendPath") | ||
|
||
project.tasks.getByName("compileTestKotlin").assertNotDependsOn(project.tasks.getByName("jar")) | ||
} | ||
|
||
private fun setupProject(): ProjectInternal { | ||
val project = buildProject() | ||
project.plugins.apply("java-library") | ||
project.applyKotlinJvmPlugin() | ||
project.repositories.mavenLocal() | ||
project.repositories.mavenCentralCacheRedirector() | ||
return project | ||
} | ||
|
||
private fun hasTestJarDependencyInTest(project: ProjectInternal): Boolean { | ||
val testCompilationImpl = project.kotlinJvmExtension.target.compilations.getByName("test").decoratedInstance.compilation | ||
return testCompilationImpl.friendPaths.any { | ||
it.files.any { file -> | ||
file.invariantSeparatorsPath.endsWith("build/libs/test.jar") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters