Skip to content

Commit dabdd28

Browse files
committed
Chore(infra): Prepare atomicfu for including to the Kotlin Aggregate build //KTI-1016
Parametrize kotlin api version, kotlin language version. Support sapping an url for a kotlin compiler repository, drop space kotlin/dev repo from dependencies: Kotlin compiler artifacts should b downloaded from maven central by default. In case of compiling with not-published into the MC kotlin compiler artifacts, a kotlin_repo_url parameter should be specified (E.g. space kotlin/dev repo).
1 parent 89a8859 commit dabdd28

File tree

6 files changed

+72
-18
lines changed

6 files changed

+72
-18
lines changed

atomicfu-gradle-plugin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if (rootProject.ext.jvm_ir_enabled) {
1414
// Gradle plugin must be compiled targeting the same Kotlin version as used by Gradle
1515
kotlin.sourceSets.all {
1616
languageSettings {
17-
apiVersion = "1.4"
18-
languageVersion = "1.4"
17+
apiVersion = KotlinAggregateBuild.getKotlinApiVersion(project) ?: "1.4"
18+
languageVersion = KotlinAggregateBuild.getKotlinLanguageVersion(project) ?: "1.4"
1919
}
2020
}
2121

atomicfu-maven-plugin/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def buildSnapshots = rootProject.properties['build_snapshot_train'] != null
2323

2424
evaluationDependsOn(':atomicfu-transformer')
2525

26+
def kotlinDevRepoUrl = KotlinAggregateBuild.getKotlinDevRepositoryUrl(project) as String
27+
2628
task generatePomFile(dependsOn: [compileKotlin, ':atomicfu-transformer:publishToMavenLocal']) {
2729
def buildDir = project.buildDir // because Maven model also has "project"
2830
outputs.file(pomFile)
@@ -43,11 +45,12 @@ task generatePomFile(dependsOn: [compileKotlin, ':atomicfu-transformer:publishTo
4345
appendNode('project.build.sourceEncoding', 'UTF-8')
4446
}
4547
appendNode('repositories').with {
46-
appendNode('repository').with {
47-
appendNode('id', 'dev')
48-
appendNode('url', 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev')
48+
if (kotlinDevRepoUrl != "") {
49+
appendNode('repository').with {
50+
appendNode('id', 'dev')
51+
appendNode('url', kotlinDevRepoUrl)
52+
}
4953
}
50-
5154
if (buildSnapshots) {
5255
appendNode('repository').with {
5356
appendNode('id', 'kotlin-snapshots')

build.gradle

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.jetbrains.kotlin.konan.target.HostManager
66

77
buildscript {
8+
9+
810
/*
911
* These property group is used to build kotlinx.atomicfu against Kotlin compiler snapshot.
1012
* How does it work:
@@ -29,14 +31,16 @@ buildscript {
2931
ext.jvm_ir_enabled = rootProject.properties['enable_jvm_ir'] != null
3032
ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null
3133

34+
def kotlinDevRepoUrl = KotlinAggregateBuild.getKotlinDevRepositoryUrl(project) as String
35+
3236
repositories {
3337
mavenCentral()
3438
maven { url "https://plugins.gradle.org/m2/" }
35-
// Future replacement for kotlin-dev, with cache redirector
36-
maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
37-
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
39+
if (kotlinDevRepoUrl != "") {
40+
maven { url kotlinDevRepoUrl }
41+
}
3842
}
39-
43+
4044
dependencies {
4145
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
4246
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
@@ -54,12 +58,15 @@ allprojects {
5458
}
5559
}
5660

57-
println "Using Kotlin $kotlin_version for project $it"
61+
logger.info("Using Kotlin compiler $kotlin_version for $it")
62+
63+
def kotlinDevRepoUrl = KotlinAggregateBuild.getKotlinDevRepositoryUrl(project) as String
64+
5865
repositories {
5966
mavenCentral()
60-
// Future replacement for kotlin-dev, with cache redirector
61-
maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
62-
maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
67+
if (kotlinDevRepoUrl!= "") {
68+
maven { url kotlinDevRepoUrl }
69+
}
6370
}
6471

6572
def deployVersion = properties['DeployVersion']
@@ -79,7 +86,7 @@ allprojects {
7986
}
8087
}
8188

82-
println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
89+
logger.info("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
8390
if (build_snapshot_train) {
8491
afterEvaluate {
8592
println "Manifest of kotlin-compiler-embeddable.jar for atomicfu"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@file:JvmName("KotlinAggregateBuild")
2+
3+
import org.gradle.api.Project
4+
import java.util.logging.Logger
5+
6+
val LOGGER: Logger = Logger.getLogger("Kotlin settings logger")
7+
8+
/*
9+
* Should be used for running against of non-released Kotlin compiler on a system test level
10+
* @return a Kotlin API version parametrized from command line nor gradle.properties, null otherwise
11+
* */
12+
fun getKotlinApiVersion(project: Project): String? {
13+
val apiVersion = project.rootProject.properties["kotlin_api_version"] as? String
14+
if (apiVersion != null)
15+
LOGGER.info("""Configured Kotlin API version: '$apiVersion' for project $${project.name}""")
16+
return apiVersion
17+
}
18+
19+
/*
20+
* Should be used for running against of non-released Kotlin compiler on a system test level
21+
* @return a Kotlin Language version parametrized from command line nor gradle.properties, null otherwise
22+
* */
23+
fun getKotlinLanguageVersion(project: Project): String? {
24+
val languageVersion = project.rootProject.properties["kotlin_language_version"] as? String
25+
if (languageVersion != null)
26+
LOGGER.info("""Configured Kotlin Language version: '$languageVersion' for project ${project.name}""")
27+
return languageVersion
28+
}
29+
30+
/*
31+
* Should be used for running against of non-released Kotlin compiler on a system test level
32+
* Kotlin compiler artifacts are expected to be downloaded from maven central by default.
33+
* In case of compiling with not-published into the MC kotlin compiler artifacts, a kotlin_repo_url gradle parameter should be specified.
34+
* To reproduce a build locally, a kotlin/dev repo should be passed
35+
* @return an url for a kotlin compiler repository parametrized from command line nor gradle.properties, empty string otherwise
36+
* */
37+
fun getKotlinDevRepositoryUrl(project: Project): String {
38+
val url = (project.rootProject.properties["kotlin_repo_url"] ?: "") as String
39+
if (url != "")
40+
LOGGER.info("""Configured Kotlin Compiler repository url: '$url' for project ${project.name}""")
41+
return url
42+
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ version=0.18.5-SNAPSHOT
66
group=org.jetbrains.kotlinx
77

88
kotlin_version=1.7.20
9+
kotlin_api_version=1.4
10+
kotlin_language_version=1.4
11+
912
asm_version=9.3
1013
slf4j_version=1.8.0-alpha2
1114
junit_version=4.12

gradle/compile-options.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
43
*/
@@ -19,8 +18,8 @@ ext.configureKotlin = { isMultiplatform ->
1918

2019
kotlin.sourceSets.all {
2120
languageSettings {
22-
apiVersion = "1.4"
23-
languageVersion = "1.4"
21+
apiVersion = KotlinAggregateBuild.getKotlinApiVersion(project) ?: "1.4"
22+
languageVersion = KotlinAggregateBuild.getKotlinLanguageVersion(project) ?: "1.4"
2423
}
2524
}
2625
}

0 commit comments

Comments
 (0)