-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternative solution how to add compiler plugin dependency to the project #386
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bab9117
Added a test that reproduces the plugin order problem.
mvicsokolova 4910c1e
Add a transitive dependency to the compiler plugin by atomicfu-gradle…
mvicsokolova 88050c2
fixup
mvicsokolova ae80eb2
Remove tasks that used to log classpath of the plugin for atomicfu-gr…
mvicsokolova 0e75ddc
Removed another part of atomicfu-gradle-plugin configuration used for…
mvicsokolova df22b88
Passed the old valid version to the kotlin:atomicfu dependency, so th…
mvicsokolova d2f3126
plugin-order-bug project builds now
mvicsokolova 5b50be2
Dropped a comment about runtime dependency
mvicsokolova 9ee25be
Do not pass IR parameter to JS target
mvicsokolova 6a066e2
Added a test for resolution of the compiler plugin dependency
mvicsokolova e6206c5
This commit resolves the warning when compileOnly dependencies are us…
mvicsokolova 20306e3
README: Remove the requirement to add a compiler plugin dependency ma…
mvicsokolova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
integration-testing/examples/plugin-order-bug/build.gradle
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,45 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlinVersion.get()}") | ||
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${libs.versions.atomicfuVersion.get()}") | ||
} | ||
} | ||
// Apply KGP via buildscript to check this issue: #384 | ||
apply plugin: 'org.jetbrains.kotlin.multiplatform' | ||
apply plugin: 'kotlinx-atomicfu' | ||
|
||
repositories { | ||
mavenCentral() | ||
maven{ url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } | ||
mavenLocal() | ||
} | ||
|
||
kotlin { | ||
jvm() | ||
|
||
js() | ||
|
||
wasmJs {} | ||
wasmWasi {} | ||
|
||
macosArm64() | ||
macosX64() | ||
linuxArm64() | ||
linuxX64() | ||
mingwX64() | ||
|
||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
implementation(kotlin("stdlib")) | ||
implementation(kotlin("test-junit")) | ||
} | ||
} | ||
commonTest {} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
integration-testing/examples/plugin-order-bug/gradle.properties
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,5 @@ | ||
## | ||
## Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
## | ||
kotlin_version=1.9.20 | ||
atomicfu_version=0.23.1-SNAPSHOT |
19 changes: 19 additions & 0 deletions
19
integration-testing/examples/plugin-order-bug/settings.gradle.kts
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,19 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
version("atomicfuVersion", providers.gradleProperty("atomicfu_version").orNull) | ||
version("kotlinVersion", providers.gradleProperty("kotlin_version").orNull) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "plugin-order-bug" |
27 changes: 27 additions & 0 deletions
27
integration-testing/examples/plugin-order-bug/src/commonMain/kotlin/AtomicSampleClass.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,27 @@ | ||
/* | ||
* Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package examples.mpp_sample | ||
|
||
import kotlinx.atomicfu.* | ||
import kotlinx.atomicfu.locks.* | ||
import kotlin.test.* | ||
|
||
public class AtomicSampleClass { | ||
private val _x = atomic(0) | ||
val x get() = _x.value | ||
|
||
public fun doWork(finalValue: Int) { | ||
assertEquals(0, x) | ||
assertEquals(0, _x.getAndSet(3)) | ||
assertEquals(3, x) | ||
assertTrue(_x.compareAndSet(3, finalValue)) | ||
} | ||
|
||
private val lock = reentrantLock() | ||
|
||
public fun synchronizedFoo(value: Int): Int { | ||
return lock.withLock { value } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
integration-testing/examples/plugin-order-bug/src/commonTest/kotlin/AtomicSampleTest.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,17 @@ | ||
/* | ||
* Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import kotlin.test.* | ||
import examples.mpp_sample.* | ||
|
||
class AtomicSampleTest { | ||
|
||
@Test | ||
fun testInt() { | ||
val a = AtomicSampleClass() | ||
a.doWork(1234) | ||
assertEquals(1234, a.x) | ||
assertEquals(42, a.synchronizedFoo(42)) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...src/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/cases/PluginOrderBugTest.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,46 @@ | ||
package kotlinx.atomicfu.gradle.plugin.test.cases | ||
|
||
import kotlinx.atomicfu.gradle.plugin.test.framework.checker.getProjectClasspath | ||
import kotlinx.atomicfu.gradle.plugin.test.framework.runner.* | ||
import kotlinx.atomicfu.gradle.plugin.test.framework.runner.GradleBuild | ||
import kotlinx.atomicfu.gradle.plugin.test.framework.runner.cleanAndBuild | ||
import kotlinx.atomicfu.gradle.plugin.test.framework.runner.createGradleBuildFromSources | ||
import kotlin.test.* | ||
|
||
/** | ||
* This test reproduces and tracks the issue #384. | ||
*/ | ||
class PluginOrderBugTest { | ||
private val pluginOrderBugProject: GradleBuild = createGradleBuildFromSources("plugin-order-bug") | ||
|
||
@Test | ||
fun testUserProjectBuild() { | ||
val buildResult = pluginOrderBugProject.cleanAndBuild() | ||
assertTrue(buildResult.isSuccessful, buildResult.output) | ||
} | ||
|
||
/** | ||
* Ensures that the version of atomicfu compiler plugin in the project's classpath equals the version of KGP used in the project. | ||
*/ | ||
@Test | ||
fun testResolvedCompilerPluginDependency() { | ||
val classpath = pluginOrderBugProject.getProjectClasspath() | ||
assertTrue(classpath.contains("org.jetbrains.kotlin:atomicfu:${pluginOrderBugProject.getKotlinVersion()}")) | ||
} | ||
|
||
/** | ||
* kotlin-stdlib is an implementation dependency of :atomicfu module, | ||
* because compileOnly dependencies are not applicable for Native targets (#376). | ||
* | ||
* This test ensures that kotlin-stdlib of the Kotlin version used to build kotlinx-atomicfu library is not "required" in the user's project. | ||
* The user project should use kotlin-stdlib version that is present in it's classpath. | ||
*/ | ||
@Test | ||
fun testTransitiveKotlinStdlibDependency() { | ||
val dependencies = pluginOrderBugProject.dependencies() | ||
assertFalse(dependencies.output.contains("org.jetbrains.kotlin:kotlin-stdlib:{strictly $libraryKotlinVersion}"), | ||
"Strict requirement for 'org.jetbrains.kotlin:kotlin-stdlib:{strictly $libraryKotlinVersion}' was found in the project ${pluginOrderBugProject.projectName} dependencies, " + | ||
"while Kotlin version used in the project is ${pluginOrderBugProject.getKotlinVersion()}" | ||
) | ||
} | ||
} |
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some check that there is
org.jetbrains.kotlin:atomicfu:1.9.20
dependency in the project classpath.In the buildEnvironment we can also find the resolution string:
org.jetbrains.kotlin:atomicfu:1.6.20 -> 1.9.20
but probably just checking for the kotlin version is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to covering such a scenario!