Skip to content

Commit

Permalink
kotlin-compiler-embeddable dependencies should be compileOnly (#407)
Browse files Browse the repository at this point in the history
* Ktlint and kotlin compiler should be compileOnly dependencies.

* Introduce compileOnlyOrApi configuration that adds dependency as api if uberJar property is set.

* Make testImplementation extend compileOnlyOrApi.

* Add kotlin compiler explicitly to detekt rules testImplementation.
  • Loading branch information
dkostyrev authored Dec 21, 2024
1 parent 32a411a commit c9c5aec
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ allprojects {
if (project != rootProject) {
pluginManager.apply(libs.plugins.mavenPublish.get().pluginId)
}

project.configurations.create("compileOnlyOrApi") {
isCanBeConsumed = false
isCanBeResolved = true

project.configurations.configureEach {
when {
name == "api" && project.hasProperty("uberJar") -> extendsFrom(this@create)
name == "compileOnly" -> extendsFrom(this@create)
name == "testImplementation" -> extendsFrom(this@create)
}
}
}
}

tasks.register("printVersion") {
Expand Down
2 changes: 1 addition & 1 deletion rules/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

dependencies {
api(libs.kotlin.compiler)
compileOnlyOrApi(libs.kotlin.compiler)

testImplementation(libs.junit5)
testImplementation(libs.junit5.params)
Expand Down
3 changes: 2 additions & 1 deletion rules/detekt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tasks.shadowJar {

dependencies {
api(libs.detekt.core)
api(projects.rules.common)
compileOnlyOrApi(projects.rules.common)

testImplementation(libs.detekt.test)
testImplementation(libs.junit5)
Expand All @@ -34,4 +34,5 @@ dependencies {
testImplementation(libs.reflections)
testImplementation(libs.kaml)
testImplementation(libs.konsist)
testImplementation(libs.kotlin.compiler)
}
4 changes: 2 additions & 2 deletions rules/ktlint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ tasks.shadowJar {
}

dependencies {
api(libs.ktlint.rule.engine)
api(libs.ktlint.cli.ruleset.core)
compileOnlyOrApi(libs.ktlint.rule.engine)
compileOnlyOrApi(libs.ktlint.cli.ruleset.core)
api(projects.rules.common)

testImplementation(libs.ktlint.test)
Expand Down

0 comments on commit c9c5aec

Please # to comment.