-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathCommunityProjectsBuild.kt
72 lines (64 loc) · 2.85 KB
/
CommunityProjectsBuild.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@file:JvmName("CommunityProjectsBuild")
import org.gradle.api.*
import org.gradle.api.artifacts.dsl.*
import java.net.*
import java.util.logging.*
private val LOGGER: Logger = Logger.getLogger("Kotlin settings logger")
/**
* Functions in this file are responsible for configuring kotlinx.coroutines build against a custom dev version
* of Kotlin compiler.
* Such configuration is used in a composite community build of Kotlin in order to check whether not-yet-released changes
* are compatible with our libraries (aka "integration testing that substitutes lack of unit testing").
*/
/**
* Should be used for running against of non-released Kotlin compiler on a system test level.
*
* @return a Kotlin API version parametrized from command line nor gradle.properties, null otherwise
*/
fun getOverriddenKotlinApiVersion(project: Project): String? {
val apiVersion = project.rootProject.properties["kotlin_api_version"] as? String
if (apiVersion != null) {
LOGGER.info("""Configured Kotlin API version: '$apiVersion' for project $${project.name}""")
}
return apiVersion
}
/**
* Should be used for running against of non-released Kotlin compiler on a system test level
*
* @return a Kotlin Language version parametrized from command line nor gradle.properties, null otherwise
*/
fun getOverriddenKotlinLanguageVersion(project: Project): String? {
val languageVersion = project.rootProject.properties["kotlin_language_version"] as? String
if (languageVersion != null) {
LOGGER.info("""Configured Kotlin Language version: '$languageVersion' for project ${project.name}""")
}
return languageVersion
}
/**
* Should be used for running against of non-released Kotlin compiler on a system test level
* Kotlin compiler artifacts are expected to be downloaded from maven central by default.
* In case of compiling with not-published into the MC kotlin compiler artifacts, a kotlin_repo_url gradle parameter should be specified.
* To reproduce a build locally, a kotlin/dev repo should be passed
*
* @return an url for a kotlin compiler repository parametrized from command line nor gradle.properties, empty string otherwise
*/
fun getKotlinDevRepositoryUrl(project: Project): URI? {
val url: String? = project.rootProject.properties["kotlin_repo_url"] as? String
if (url != null) {
LOGGER.info("""Configured Kotlin Compiler repository url: '$url' for project ${project.name}""")
return URI.create(url)
}
return null
}
/**
* Adds a kotlin-dev space repository with dev versions of Kotlin if Kotlin aggregate build is enabled
*/
fun addDevRepositoryIfEnabled(rh: RepositoryHandler, project: Project) {
val devRepoUrl = getKotlinDevRepositoryUrl(project) ?: return
rh.maven {
url = devRepoUrl
}
}