Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/JLLeitschuhgh-562
Browse files Browse the repository at this point in the history
  • Loading branch information
JLLeitschuh authored Feb 7, 2022
2 parents a4d2d55 + 64ac251 commit 20b0d10
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
### Fixed
- Fix install hook action when git `hooks` folder doesn't exist [issue: #557](https://github.com/JLLeitschuh/ktlint-gradle/issues/557), [#563](https://github.com/JLLeitschuh/ktlint-gradle/pull/563)
- Fix pre-commit hook command not found error [issue: #562](https://github.com/JLLeitschuh/ktlint-gradle/issues/562), [#564](https://github.com/JLLeitschuh/ktlint-gradle/pull/564)
- Fix some resolution issues when a project using the plugin in some specific setups is depended upon by another project [issue: #523](https://github.com/JLLeitschuh/ktlint-gradle/issues/523), [#571](https://github.com/JLLeitschuh/ktlint-gradle/pull/571)

### Removed
- ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ internal fun createKtlintConfiguration(target: Project, extension: KtlintExtensi

description = KTLINT_CONFIGURATION_DESCRIPTION

isCanBeResolved = true
isCanBeConsumed = false
isVisible = false

// Starting from KtLint 0.41.0 version published artifact has two variants: "external" and "shadowed"
attributes {
it.attribute(Bundling.BUNDLING_ATTRIBUTE, target.objects.named(Bundling::class.java, Bundling.EXTERNAL))
Expand All @@ -51,6 +55,11 @@ internal fun createKtlintRulesetConfiguration(
): Configuration = target
.configurations.maybeCreate(KTLINT_RULESET_CONFIGURATION_NAME).apply {
description = KTLINT_RULESET_CONFIGURATION_DESCRIPTION

isCanBeResolved = true
isCanBeConsumed = false
isVisible = false

ensureConsistencyWith(target, ktLintConfiguration)
}

Expand All @@ -63,6 +72,11 @@ internal fun createKtLintReporterConfiguration(
.maybeCreate(KTLINT_REPORTER_CONFIGURATION_NAME)
.apply {
description = KTLINT_REPORTER_CONFIGURATION_DESCRIPTION

isCanBeResolved = true
isCanBeConsumed = false
isVisible = false

ensureConsistencyWith(target, ktLintConfiguration)

withDependencies {
Expand Down Expand Up @@ -92,6 +106,11 @@ internal fun createKtLintBaselineReporterConfiguration(
.maybeCreate(KTLINT_BASELINE_REPORTER_CONFIGURATION_NAME)
.apply {
description = KTLINT_BASELINE_REPORTER_CONFIGURATION_DESCRIPTION

isCanBeResolved = true
isCanBeConsumed = false
isVisible = false

ensureConsistencyWith(target, ktLintConfiguration)

withDependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,54 @@ class KtlintPluginTest : AbstractPluginTest() {
}
}

/**
* See: https://github.com/JLLeitschuh/ktlint-gradle/issues/523#issuecomment-1022522032
*/
@DisplayName("Should not leak KtLint as a variant into consuming projects")
@CommonTest
fun noLeakIntoConsumingProjects(gradleVersion: GradleVersion) {
project(gradleVersion) {
val producerDir = projectPath.resolve("producer").also { it.mkdirs() }
val consumerDir = projectPath.resolve("consumer").also { it.mkdirs() }
settingsGradle.appendText(
"""
include ":producer"
include ":consumer"
""".trimIndent()
)

//language=Groovy
producerDir.buildFile().writeText(
"""
plugins {
id "org.jlleitschuh.gradle.ktlint"
}
configurations.create('default')
artifacts {
add('default', buildFile)
}
""".trimIndent()
)

//language=Groovy
consumerDir.buildFile().writeText(
"""
plugins {
id 'java'
}
dependencies {
implementation project(':producer')
}
""".trimIndent()
)

build(":consumer:dependencies") {
assertThat(output).doesNotContain("com.pinterest:ktlint")
}
}
}

@DisplayName("Should print paths to the generated reports on code style violations")
@CommonTest
fun printReportsPaths(gradleVersion: GradleVersion) {
Expand Down

0 comments on commit 20b0d10

Please sign in to comment.