Skip to content

Commit

Permalink
Use Detekt with type resolution (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbmartin authored Aug 28, 2024
1 parent 075d5cb commit 4e9540e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion plugin-build/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ gradlePlugin {
version = property("VERSION").toString()
description = property("DESCRIPTION").toString()
displayName = property("DISPLAY_NAME").toString()
tags.set(listOf("plugin", "gradle", "sample", "template"))
// Note: tags cannot include "plugin" or "gradle" when publishing
tags.set(listOf("sample", "template"))
}
}
}
Expand All @@ -42,6 +43,15 @@ gradlePlugin {
vcsUrl.set(property("VCS_URL").toString())
}

// Use Detekt with type resolution for check
tasks.named("check").configure {
this.setDependsOn(
this.dependsOn.filterNot {
it is TaskProvider<*> && it.name == "detekt"
} + tasks.named("detektMain"),
)
}

tasks.create("setupPluginUploadFromEnvironment") {
doLast {
val key = System.getenv("GRADLE_PUBLISH_KEY")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class TemplateExampleTask : DefaultTask() {

@TaskAction
fun sampleAction() {
val prettyTag = tag.orNull?.let { "[$it]" } ?: ""
val prettyTag = tag.orNull?.let { "[$it]" }.orEmpty()

logger.lifecycle("$prettyTag message is: ${message.orNull}")
logger.lifecycle("$prettyTag tag is: ${tag.orNull}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.gradle.api.Project
const val EXTENSION_NAME = "templateExampleConfig"
const val TASK_NAME = "templateExample"

@Suppress("UnnecessaryAbstractClass")
abstract class TemplatePlugin : Plugin<Project> {
override fun apply(project: Project) {
// Add the 'template' extension object
Expand Down

0 comments on commit 4e9540e

Please sign in to comment.