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