File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,32 @@ private val LOGGER: Logger = Logger.getLogger("Kotlin settings logger")
18
18
* are compatible with our libraries (aka "integration testing that substitues lack of unit testing").
19
19
*/
20
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
+ */
26
+ 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
+ */
39
+ 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
+
21
47
/* *
22
48
* Should be used for running against of non-released Kotlin compiler on a system test level
23
49
* Kotlin compiler artifacts are expected to be downloaded from maven central by default.
Original file line number Diff line number Diff line change 2
2
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
- import org.jetbrains.kotlin.gradle.tasks.*
5
+ import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
6
+ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
6
7
7
8
configure(subprojects) {
9
+ val project = this
8
10
if (name in sourceless) return @configure
9
11
apply (plugin = " kotlinx-atomicfu" )
10
- val projectName = name
11
- tasks.withType(KotlinCompile ::class ).all {
12
+ tasks.withType<KotlinCompile <* >>().configureEach {
12
13
val isMainTaskName = name == " compileKotlin" || name == " compileKotlinJvm"
13
14
kotlinOptions {
14
- if (isMainTaskName) {
15
+ languageVersion = getOverriddenKotlinLanguageVersion(project)
16
+ apiVersion = getOverriddenKotlinApiVersion(project)
17
+ if (isMainTaskName && versionsAreNotOverridden) {
15
18
allWarningsAsErrors = true
16
19
}
17
20
val newOptions =
@@ -23,3 +26,6 @@ configure(subprojects) {
23
26
}
24
27
}
25
28
}
29
+
30
+ val KotlinCommonOptions .versionsAreNotOverridden: Boolean
31
+ get() = languageVersion == null && apiVersion == null
You can’t perform that action at this time.
0 commit comments