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