|
| 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 org.gradle.api.artifacts.repositories.* |
| 9 | +import org.gradle.kotlin.dsl.* |
| 10 | +import java.util.logging.* |
| 11 | + |
| 12 | +private val LOGGER: Logger = Logger.getLogger("Kotlin settings logger") |
| 13 | + |
| 14 | +/** |
| 15 | + * Functions in this file are responsible for configuring kotlinx-datetime 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 | + * Three parameters are used to configure the build: |
| 21 | + * 1. `build_snapshot_train` - if true, the build is run against a snapshot train of Kotlin compiler |
| 22 | + * 2. `kotlin_snapshot_version` - if specified, the build uses a custom Kotlin compiler version |
| 23 | + * 3. `kotlin_repo_url` - if specified, the build uses a custom Kotlin compiler repository |
| 24 | + * |
| 25 | + * If `build_snapshot_train` is true, `kotlin_snapshot_version` must be present. |
| 26 | + */ |
| 27 | + |
| 28 | +/** |
| 29 | + * Adds all the repositories that are needed for the Kotlin aggregate build. |
| 30 | + */ |
| 31 | +fun RepositoryHandler.addTrainRepositories(project: Project) { |
| 32 | + if (project.rootProject.properties["build_snapshot_train"]?.toString()?.toBoolean() == true) { |
| 33 | + mavenLocal() |
| 34 | + } |
| 35 | + // A kotlin-dev space repository with dev versions of Kotlin. |
| 36 | + val devRepoUrl = project.rootProject.properties["kotlin_repo_url"] as? String ?: return |
| 37 | + LOGGER.info("""Configured Kotlin Compiler repository url: '$devRepoUrl' for project ${project.name}""") |
| 38 | + maven(devRepoUrl) |
| 39 | +} |
| 40 | + |
| 41 | +/** |
| 42 | + * The version of Kotlin compiler to use in the Kotlin aggregate build. |
| 43 | + */ |
| 44 | +// unused, but may be useful in the future |
| 45 | +val Project.kotlinVersion: String |
| 46 | + get() = if (rootProject.properties["build_snapshot_train"]?.toString()?.toBoolean() == true) { |
| 47 | + rootProject.properties["kotlin_snapshot_version"] as? String ?: error("kotlin_snapshot_version must be specified") |
| 48 | + } else { |
| 49 | + rootProject.properties["defaultKotlinVersion"] as String |
| 50 | + } |
0 commit comments