Skip to content

Commit 8b61b6e

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Use published :plugin and :runtime artifacts in integration tests
Adopt 0.5.0-SNAPSHOT version for local publications.
1 parent 96f0034 commit 8b61b6e

File tree

13 files changed

+31
-149
lines changed

13 files changed

+31
-149
lines changed

.teamcity/additionalConfiguration.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.GradleBuildStep
1111
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle
1212

1313
fun Project.additionalConfiguration() {
14+
knownBuilds.buildVersion.params {
15+
param(versionSuffixParameter, "")
16+
}
1417
platforms.forEach { platform ->
1518
val gradleBuild = knownBuilds.buildOn(platform).steps.items.single() as GradleBuildStep
1619
gradleBuild.tasks += " " + "fastBenchmark"

examples/java/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
dependencies {
3-
classpath "org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.8"
3+
classpath "org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.5.0-SNAPSHOT"
44
}
55
}
66

examples/kotlin-kts/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
java
1010
kotlin("jvm")
1111
kotlin("plugin.allopen") version "1.8.21"
12-
id("org.jetbrains.kotlinx.benchmark") version "0.4.8"
12+
id("org.jetbrains.kotlinx.benchmark") version "0.5.0-SNAPSHOT"
1313
}
1414

1515
sourceSets.all {

examples/kotlin-multiplatform/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import kotlinx.benchmark.gradle.JsBenchmarksExecutor
55
plugins {
66
id 'org.jetbrains.kotlin.multiplatform'
77
id 'org.jetbrains.kotlin.plugin.allopen' version "1.8.21"
8-
id 'org.jetbrains.kotlinx.benchmark' version "0.4.8"
8+
id 'org.jetbrains.kotlinx.benchmark' version "0.5.0-SNAPSHOT"
99
}
1010

1111
// how to apply plugin to a specific source set?

examples/kotlin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java'
33
id 'org.jetbrains.kotlin.jvm'
44
id 'org.jetbrains.kotlin.plugin.allopen' version "1.8.21"
5-
id 'org.jetbrains.kotlinx.benchmark' version '0.4.8'
5+
id 'org.jetbrains.kotlinx.benchmark' version '0.5.0-SNAPSHOT'
66
}
77

88

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=org.jetbrains.kotlinx
2-
version=0.4.8
2+
version=0.5.0-SNAPSHOT
33

44
kotlin_version=1.8.21
55
jmhVersion=1.21

integration/build.gradle.kts

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import org.jetbrains.kotlin.konan.target.*
2-
31
plugins {
42
kotlin("jvm")
53
}
@@ -10,75 +8,21 @@ repositories {
108

119
evaluationDependsOn(":kotlinx-benchmark-runtime")
1210

13-
val Gradle.isConfigurationCacheAvailable
14-
get() = try {
15-
val startParameters = gradle.startParameter
16-
startParameters.javaClass.getMethod("isConfigurationCache")
17-
.invoke(startParameters) as? Boolean
18-
} catch (_: Exception) {
19-
null
20-
} ?: false
21-
22-
fun Project.getSystemProperty(key: String): String? {
23-
return if (gradle.isConfigurationCacheAvailable) {
24-
providers.systemProperty(key).forUseAtConfigurationTime().orNull
25-
} else {
26-
System.getProperty(key)
27-
}
28-
}
29-
30-
val nativeTargetName
31-
get() = when {
32-
project.getSystemProperty("idea.active") == "true" -> if (HostManager.hostIsMac) "darwin" else "native"
33-
HostManager.hostIsLinux -> "linuxX64"
34-
HostManager.hostIsMingw -> "mingwX64"
35-
HostManager.host == KonanTarget.MACOS_X64 -> "macosX64"
36-
HostManager.host == KonanTarget.MACOS_ARM64 -> "macosArm64"
37-
else -> error("Unknown host: ${HostManager.host}")
38-
}
39-
4011
val runtime get() = project(":kotlinx-benchmark-runtime")
4112
val plugin get() = gradle.includedBuild("plugin")
4213

43-
val AbstractArchiveTask.archiveFilePath get() = archiveFile.get().asFile.path
44-
45-
fun artifactsTask(artifact: String) = runtime.tasks.getByName<AbstractArchiveTask>("${artifact}Jar")
46-
fun artifactsTaskNativeKlibs() = runtime.tasks.getByName("compileKotlin${nativeTargetName.capitalize()}")
47-
48-
fun Task.klibs(): String = outputs.files.filter { it.extension == "klib" }.joinToString("\n")
49-
50-
fun IncludedBuild.classpath() = projectDir.resolve("build/createClasspathManifest")
51-
52-
val createClasspathManifest by tasks.registering {
53-
dependsOn(plugin.task(":createClasspathManifest"))
54-
dependsOn(artifactsTask("jvm"))
55-
dependsOn(artifactsTask("jsIr"))
56-
dependsOn(artifactsTask("wasm"))
57-
dependsOn(artifactsTask("allMetadata"))
58-
dependsOn(artifactsTaskNativeKlibs())
59-
60-
val outputDir = file("$buildDir/$name")
61-
outputs.dir(outputDir)
62-
doLast {
63-
outputDir.apply {
64-
mkdirs()
65-
resolve("plugin-classpath.txt").writeText(plugin.classpath().resolve("plugin-classpath.txt").readText())
66-
resolve("runtime-metadata.txt").writeText(artifactsTask("allMetadata").archiveFilePath)
67-
resolve("runtime-jvm.txt").writeText(artifactsTask("jvm").archiveFilePath)
68-
resolve("runtime-jsIr.txt").writeText(artifactsTask("jsIr").archiveFilePath)
69-
resolve("runtime-wasm.txt").writeText(artifactsTask("wasm").archiveFilePath)
70-
resolve("runtime-native.txt").writeText(artifactsTaskNativeKlibs().klibs())
71-
}
72-
}
73-
}
74-
7514
dependencies {
76-
implementation(files(createClasspathManifest))
7715
implementation(gradleTestKit())
7816

7917
testImplementation(kotlin("test-junit"))
8018
}
8119

8220
tasks.test {
21+
dependsOn(plugin.task(":publishToBuildLocal"))
22+
dependsOn(runtime.tasks.getByName("publishToBuildLocal"))
23+
24+
systemProperty("plugin_repo_url", plugin.projectDir.resolve("build/maven").absoluteFile.invariantSeparatorsPath)
25+
systemProperty("runtime_repo_url", rootProject.buildDir.resolve("maven").absoluteFile.invariantSeparatorsPath)
8326
systemProperty("kotlin_repo_url", rootProject.properties["kotlin_repo_url"])
27+
systemProperty("kotlin_version", rootProject.properties["kotlin_version"]!!)
8428
}

integration/src/main/kotlin/kotlinx/benchmark/integration/ProjectBuilder.kt

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package kotlinx.benchmark.integration
22

3-
import java.io.*
4-
53
class ProjectBuilder {
64
private val configurations = mutableMapOf<String, BenchmarkConfiguration>()
75
private val targets = mutableMapOf<String, BenchmarkTarget>()
@@ -31,35 +29,30 @@ benchmark {
3129
}
3230
}
3331

34-
private val buildScript = run {
32+
private val kotlin_repo = System.getProperty("kotlin_repo_url").let {
33+
if (it.isNullOrBlank()) "" else "maven { url '$it' }"
34+
}
35+
36+
private val buildScript =
3537
"""
3638
buildscript {
39+
repositories {
40+
$kotlin_repo
41+
maven { url '${System.getProperty("plugin_repo_url")}' }
42+
mavenCentral()
43+
}
3744
dependencies {
38-
classpath files(${readFileList("plugin-classpath.txt")})
45+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:${System.getProperty("kotlin_version")}'
46+
classpath 'org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.5.0-SNAPSHOT'
3947
}
4048
}
4149
4250
apply plugin: 'kotlin-multiplatform'
4351
apply plugin: 'org.jetbrains.kotlinx.benchmark'
4452
4553
repositories {
54+
$kotlin_repo
55+
maven { url '${System.getProperty("runtime_repo_url")}' }
4656
mavenCentral()
47-
maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap' }
4857
}
49-
50-
def benchmarkRuntimeMetadata = files(${readFileList("runtime-metadata.txt")})
51-
def benchmarkRuntimeJvm = files(${readFileList("runtime-jvm.txt")})
52-
def benchmarkRuntimeJsIr = files(${readFileList("runtime-jsIr.txt")})
53-
def benchmarkRuntimeWasm = files(${readFileList("runtime-wasm.txt")})
54-
def benchmarkRuntimeNative = files(${readFileList("runtime-native.txt")})
5558
""".trimIndent()
56-
}
57-
58-
private fun readFileList(fileName: String): String {
59-
val resource = ProjectBuilder::class.java.classLoader.getResource(fileName)
60-
?: throw IllegalStateException("Could not find resource '$fileName'")
61-
val files = File(resource.toURI())
62-
.readLines()
63-
.map { File(it).absolutePath.replace("\\", "\\\\") } // escape backslashes in Windows paths
64-
return files.joinToString(", ") { "'$it'" }
65-
}

integration/src/test/kotlin/kotlinx/benchmark/integration/GradleTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ abstract class GradleTest {
2727
templates.resolve(name).copyRecursively(rootProjectDir)
2828
file("build.gradle").modify(builder::build)
2929
file("settings.gradle").writeText("") // empty settings file
30-
val kotlinDevUrl = System.getProperty("kotlin_repo_url")
31-
if (!kotlinDevUrl.isNullOrBlank()) {
32-
file("gradle.properties").appendText("\nkotlin_repo_url=$kotlinDevUrl")
33-
}
3430
return Runner(rootProjectDir, print, gradleVersion)
3531
}
3632
}

integration/src/test/resources/templates/kotlin-multiplatform/build.gradle

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,23 @@ kotlin {
1616
sourceSets {
1717
commonMain {
1818
dependencies {
19-
implementation(benchmarkRuntimeMetadata)
19+
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.5.0-SNAPSHOT")
2020
}
2121
}
2222
jvmMain {
23-
dependencies {
24-
implementation(benchmarkRuntimeJvm)
25-
}
2623
}
2724
jvmBenchmark {
2825
dependsOn(jvmMain)
29-
dependencies {
30-
implementation(benchmarkRuntimeJvm)
31-
}
3226
}
3327
jsIrMain {
34-
dependencies {
35-
implementation(benchmarkRuntimeJsIr)
36-
}
3728
}
3829
wasmMain {
39-
dependencies {
40-
implementation(benchmarkRuntimeWasm)
41-
}
4230
}
4331
nativeMain {
44-
dependsOn(commonMain)
45-
dependencies {
46-
implementation(benchmarkRuntimeNative)
47-
}
4832
}
4933
}
5034
}
5135

52-
repositories {
53-
def kotlinDevUrl = rootProject.properties["kotlin_repo_url"]
54-
if (kotlinDevUrl != null) {
55-
maven { url = kotlinDevUrl }
56-
}
57-
}
58-
5936
benchmark {
6037
targets {
6138
register("jvm")

0 commit comments

Comments
 (0)