-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test project with legacy kotlin-gradle-plugin application.
And a README note. #384
- Loading branch information
1 parent
520d81c
commit 6b16944
Showing
7 changed files
with
200 additions
and
0 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
52 changes: 52 additions & 0 deletions
52
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,52 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// If the order of adding atomicfu-gradle-plugin and kotlin-gradle-pluin to the classpath is changed, | ||
// then atomicfu dependency is not added to the classpath | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlinVersion.get()}") | ||
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${libs.versions.atomicfuVersion.get()}") | ||
classpath("org.jetbrains.kotlin:atomicfu:${libs.versions.kotlinVersion.get()}") | ||
} | ||
} | ||
|
||
apply plugin: 'org.jetbrains.kotlin.multiplatform' | ||
// The issue is described in #384. Application of kotlin-gradle-plugin by id fixes the compilation error. | ||
//plugins { | ||
// id 'org.jetbrains.kotlin.multiplatform' version '1.9.21' | ||
//} | ||
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.21 | ||
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)) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...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,22 @@ | ||
package kotlinx.atomicfu.gradle.plugin.test.cases | ||
|
||
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 e = assertFailsWith<IllegalArgumentException> { | ||
pluginOrderBugProject.cleanAndBuild() | ||
} | ||
check(e.message?.contains("unresolved reference: kotlinx") == true) | ||
} | ||
} |