Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move detekt-gradle-plugin to be a composite build #4751

Merged
merged 3 commits into from Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pre-merge.yaml
Expand Up @@ -82,4 +82,4 @@ jobs:
- name: Build and compile test snippets
uses: gradle/gradle-build-action@v2
with:
arguments: test -x :detekt-gradle-plugin:test -Pcompile-test-snippets=true
arguments: test -Pcompile-test-snippets=true
8 changes: 0 additions & 8 deletions build-logic/src/main/kotlin/releasing.gradle.kts
Expand Up @@ -69,12 +69,4 @@ tasks {
linePartToFind.set(" detektVersion:")
lineTransformation.set(" detektVersion: '${Versions.DETEKT}'")
}

register<UpdateVersionInFileTask>("applySelfAnalysisVersion") {
fileToUpdate.set(file("${rootProject.rootDir}/gradle/libs.versions.toml"))
linePartToFind.set("detekt = { id = \"io.gitlab.arturbosch.detekt\"")
lineTransformation.set(
"detekt = { id = \"io.gitlab.arturbosch.detekt\", version = \"${Versions.DETEKT}\" }"
)
}
}
6 changes: 5 additions & 1 deletion build.gradle.kts
Expand Up @@ -3,7 +3,7 @@ import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask

plugins {
id("releasing")
alias(libs.plugins.detekt)
id("io.gitlab.arturbosch.detekt")
alias(libs.plugins.gradleVersions)
alias(libs.plugins.sonarqube)
}
Expand Down Expand Up @@ -105,3 +105,7 @@ val detektProjectBaseline by tasks.registering(DetektCreateBaselineTask::class)
exclude(buildFiles)
baseline.set(baselineFile)
}

tasks.register("build") {
dependsOn(gradle.includedBuild("detekt-gradle-plugin").task(":build"))
}
7 changes: 3 additions & 4 deletions detekt-gradle-plugin/build.gradle.kts
Expand Up @@ -9,15 +9,14 @@ plugins {
alias(libs.plugins.pluginPublishing)
}

detekt {
source.from("src/functionalTest/kotlin")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to stay, there's no equivalent config anywhere else in the project to add src/functionalTest to the source checked by the detekt task.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, this can't stay. The detekt-gradle-plugin build can't use itself.

We would have to use again an older published version of the detekt-gradle-plugin which I would like to avoid frankly (as it's the problem we're trying to address here.

I would rather rely on the runWithArgsFile as it should handle also the src/functionalTest/kotlin folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runWithArgsFile checks the entire codebase, so it should cover all sources under src/functionalTest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I added this block to this build file is running :detekt-gradle-plugin:build doesn't check functionalTest sources without it, because none of the configured Gradle detekt tasks in detekt-gradle-plugin checked it, so CI would fail when I pushed and runWithArgsFile ran, and it became quite frustrating. Running runWithArgsFile locally is just another thing to remember to do before pushing, and it's poor DX.

detekt-gradle-plugin build can't use itself.

True, but we can add id("io.gitlab.arturbosch.detekt") version "1.20.0" to the plugins block in detekt-gradle-plugin. I assume renovate will notify about updates, and updating that version still won't be tied to the release process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for clarifying. I think it's ok to include the id("io.gitlab.arturbosch.detekt") version "1.20.0" and don't bump it as part of the release process (let's renovate do the job as you suggested).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you fine with me adding this in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you fine with me adding this in a separate PR?

Yep, LGTM!

}

repositories {
mavenCentral()
google()
}

group = "io.gitlab.arturbosch.detekt"
version = Versions.currentOrSnapshot()

testing {
suites {
getByName("test", JvmTestSuite::class) {
Expand Down
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Expand Up @@ -39,7 +39,6 @@ jcommander = "com.beust:jcommander:1.82"

[plugins]
binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.9.0" }
detekt = { id = "io.gitlab.arturbosch.detekt", version = "1.20.0" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
gradleVersions = { id = "com.github.ben-manes.versions", version = "0.42.0" }
pluginPublishing = { id = "com.gradle.plugin-publish", version = "0.21.0" }
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.sh
Expand Up @@ -4,5 +4,5 @@ gradle build || exit
gradle publishAllPublicationsToMavenCentralRepository --max-workers 1 || exit
gradle publishPlugins -DautomatePublishing=true || exit
gradle githubRelease || exit
gradle applyDocVersion applySelfAnalysisVersion || exit
gradle applyDocVersion || exit
gradle closeAndReleaseRepository || exit
2 changes: 1 addition & 1 deletion settings.gradle.kts
Expand Up @@ -4,6 +4,7 @@ rootProject.name = "detekt"

pluginManagement {
includeBuild("build-logic")
includeBuild("detekt-gradle-plugin")
}

include("code-coverage-report")
Expand All @@ -12,7 +13,6 @@ include("detekt-cli")
include("detekt-core")
include("detekt-formatting")
include("detekt-generator")
include("detekt-gradle-plugin")
include("detekt-metrics")
include("detekt-parser")
include("detekt-psi-utils")
Expand Down