diff --git a/build.gradle.kts b/build.gradle.kts index 265d1793..46fffd5f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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") { diff --git a/rules/common/build.gradle.kts b/rules/common/build.gradle.kts index dc90783a..1ad45683 100644 --- a/rules/common/build.gradle.kts +++ b/rules/common/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } dependencies { - api(libs.kotlin.compiler) + compileOnlyOrApi(libs.kotlin.compiler) testImplementation(libs.junit5) testImplementation(libs.junit5.params) diff --git a/rules/detekt/build.gradle.kts b/rules/detekt/build.gradle.kts index d1b64658..67bafb70 100644 --- a/rules/detekt/build.gradle.kts +++ b/rules/detekt/build.gradle.kts @@ -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) @@ -34,4 +34,5 @@ dependencies { testImplementation(libs.reflections) testImplementation(libs.kaml) testImplementation(libs.konsist) + testImplementation(libs.kotlin.compiler) } diff --git a/rules/ktlint/build.gradle.kts b/rules/ktlint/build.gradle.kts index 8ccb2b87..556ce5d8 100644 --- a/rules/ktlint/build.gradle.kts +++ b/rules/ktlint/build.gradle.kts @@ -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)