Skip to content

Commit 2b2de36

Browse files
committed
Add necessary properties according to KT-75078
1 parent 268f43b commit 2b2de36

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

build.gradle.kts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ group = "me.user"
99
version = "1.0-SNAPSHOT"
1010

1111
val kotlin_repo_url: String? = project.properties["kotlin_repo_url"] as String?
12-
val language_version: String? = project.properties["language_version"] as String?
12+
val kotlinLanguageVersionOverride = providers.gradleProperty("kotlin_language_version")
13+
.map(org.jetbrains.kotlin.gradle.dsl.KotlinVersion::fromVersion)
14+
.orNull
15+
val kotlinApiVersionOverride = providers.gradleProperty("kotlin_api_version")
16+
.map(org.jetbrains.kotlin.gradle.dsl.KotlinVersion::fromVersion)
17+
.orNull
18+
val kotlinAdditionalCliOptions = providers.gradleProperty("kotlin_additional_cli_options")
19+
.map { it.split(" ") }
20+
.orNull
1321

1422
repositories {
1523
mavenCentral()
@@ -32,8 +40,37 @@ kotlin {
3240

3341
compilations.configureEach {
3442
compileTaskProvider.configure {
35-
language_version?.let {
36-
compilerOptions.languageVersion.set(fromVersion(it))
43+
if (kotlinLanguageVersionOverride != null) {
44+
compilerOptions {
45+
languageVersion.set(kotlinLanguageVersionOverride)
46+
logger.info("[KUP] ${this@configure.path} : set LV to $kotlinLanguageVersionOverride")
47+
}
48+
}
49+
if (kotlinApiVersionOverride != null) {
50+
compilerOptions {
51+
apiVersion.set(kotlinApiVersionOverride)
52+
logger.info("[KUP] ${this@configure.path} : set APIV to $kotlinApiVersionOverride")
53+
}
54+
}
55+
if (kotlinAdditionalCliOptions != null) {
56+
compilerOptions {
57+
freeCompilerArgs.addAll(kotlinAdditionalCliOptions)
58+
logger.info(
59+
"[KUP] ${this@configure.path} : added ${
60+
kotlinAdditionalCliOptions.joinToString(
61+
" "
62+
)
63+
}"
64+
)
65+
}
66+
}
67+
compilerOptions {
68+
// output reported warnings even in the presence of reported errors
69+
freeCompilerArgs.add("-Xreport-all-warnings")
70+
logger.info("[KUP] ${this@configure.path} : added -Xreport-all-warnings")
71+
// output kotlin.git-searchable names of reported diagnostics
72+
freeCompilerArgs.add("-Xrender-internal-diagnostic-names")
73+
logger.info("[KUP] ${this@configure.path} : added -Xrender-internal-diagnostic-names")
3774
}
3875
}
3976
}

0 commit comments

Comments
 (0)