From 24bed46f651882baac2c2f8c26f436f0ee4b9467 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:26:40 +0800 Subject: [PATCH 01/13] Use javadoc task directly --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2edec043..f46757e3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,7 +61,7 @@ tasks { withType().configureEach { dependsOn(processResources) } - named("javadoc") { + javadoc { enabled = false } } From 9ae6ebcf086db86cd1c85a842840de4d50c1dd2e Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:26:54 +0800 Subject: [PATCH 02/13] No need to apply java-gradle-plugin --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f46757e3..91bf44bf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ plugins { groovy - `java-gradle-plugin` jacoco signing kotlin("jvm") version "1.9.21" From ef9980fe4be16956c749db5aed1c1e8feda4aeb0 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:27:24 +0800 Subject: [PATCH 03/13] Simple property assignment for toolchain --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 91bf44bf..80d22192 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,7 @@ plugins { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion = JavaLanguageVersion.of(11) } } From 4f5870166cb64e125b8f39bac182efe6e671b20e Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:28:20 +0800 Subject: [PATCH 04/13] Compile only AGP API --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 80d22192..ed1c708d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ val androidGradlePluginVersion = "8.2.0" dependencies { compileOnly(localGroovy()) compileOnly("com.github.spotbugs:spotbugs:$spotBugsVersion") - compileOnly("com.android.tools.build:gradle:$androidGradlePluginVersion") + compileOnly("com.android.tools.build:gradle-api:$androidGradlePluginVersion") testImplementation("com.tngtech.archunit:archunit:1.2.0") } From 28d511c4276b96348c1cc2a178b6b4eb5b03ae4d Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:30:10 +0800 Subject: [PATCH 05/13] Import Detekt --- build.gradle.kts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index ed1c708d..0c3961fc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import io.gitlab.arturbosch.detekt.Detekt + plugins { groovy jacoco @@ -43,7 +45,7 @@ signing { } tasks { - named("detekt") { + named("detekt") { reports { sarif.required = true } From d9d07a0ed22206c21268d038952945cf7922746d Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:33:12 +0800 Subject: [PATCH 06/13] User infix styles --- settings.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index e74ba51c..2094ec82 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,8 +5,8 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version("3.15.1") - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.enterprise") version "3.15.1" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" } dependencyResolutionManagement { From abda07d61b4c6b2ee698204d80398dfadf88db35 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:33:49 +0800 Subject: [PATCH 07/13] Use regex for google maven repo --- settings.gradle.kts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 2094ec82..d6781b12 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,7 +12,11 @@ plugins { dependencyResolutionManagement { repositories { // To download the Android Gradle Plugin - google() + google { + content { + includeGroupByRegex(".*android.*") + } + } // To download trove4j required by the Android Gradle Plugin mavenCentral() } From 09ae191809eadff938a6cd7a55d727366b285579 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:35:56 +0800 Subject: [PATCH 08/13] Enable config cache --- gradle.properties | 1 + settings.gradle.kts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/gradle.properties b/gradle.properties index 9affcefb..9a77dc81 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4g org.gradle.parallel=true org.gradle.caching=true +org.gradle.configuration-cache=true diff --git a/settings.gradle.kts b/settings.gradle.kts index d6781b12..5ae8a2ab 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,3 +33,5 @@ gradleEnterprise { publishAlwaysIf(isCiBuild) } } + +enableFeaturePreview("STABLE_CONFIGURATION_CACHE") From 58c65614cc949c062c5f2a38e7fa198877790cc5 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 15:36:33 +0800 Subject: [PATCH 09/13] Revert "Compile only AGP API" This reverts commit 4f5870166cb64e125b8f39bac182efe6e671b20e. --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0c3961fc..c9faa7a0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,7 +28,7 @@ val androidGradlePluginVersion = "8.2.0" dependencies { compileOnly(localGroovy()) compileOnly("com.github.spotbugs:spotbugs:$spotBugsVersion") - compileOnly("com.android.tools.build:gradle-api:$androidGradlePluginVersion") + compileOnly("com.android.tools.build:gradle:$androidGradlePluginVersion") testImplementation("com.tngtech.archunit:archunit:1.2.0") } From 8e72d8ad1baa58d4776b79fa8e9560929b738008 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 16:03:56 +0800 Subject: [PATCH 10/13] Re-enable Spotless check for Groovy files --- .../spotbugs/com.github.spotbugs.gradle-plugin.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buildSrc/src/main/kotlin/com/github/spotbugs/com.github.spotbugs.gradle-plugin.gradle.kts b/buildSrc/src/main/kotlin/com/github/spotbugs/com.github.spotbugs.gradle-plugin.gradle.kts index 93b2f870..5b612dd8 100644 --- a/buildSrc/src/main/kotlin/com/github/spotbugs/com.github.spotbugs.gradle-plugin.gradle.kts +++ b/buildSrc/src/main/kotlin/com/github/spotbugs/com.github.spotbugs.gradle-plugin.gradle.kts @@ -3,6 +3,12 @@ plugins { } spotless { + groovy { + licenseHeaderFile(rootProject.file("gradle/HEADER.txt")) + target("**/*.groovy") + greclipse() + indentWithSpaces() + } kotlin { ktlint() } From 08cfe48f1ba1f127d9d8395b8db1f85d95764900 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 16:06:52 +0800 Subject: [PATCH 11/13] Fix styles --- .../github/spotbugs/snom/CacheabilityFunctionalTest.groovy | 3 ++- .../spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy index d440d443..5fbcbb92 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy @@ -26,7 +26,8 @@ class CacheabilityFunctionalTest extends BaseFunctionalTest { */ @IgnoreIf({ def current = System.getProperty('gradleVersion', GradleVersion.current().version) - return GradleVersion.version(current) < GradleVersion.version("8.1") }) + return GradleVersion.version(current) < GradleVersion.version("8.1") + }) def 'spotbugsMain task runs with configuration cache'() { given: initializeBuildFile(rootDir) diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy index f056e8c8..753726eb 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy @@ -52,7 +52,8 @@ public class Foo { @IgnoreIf({ def current = System.getProperty('gradleVersion', GradleVersion.current().version) - return GradleVersion.version(current) < GradleVersion.version("8.2") }) + return GradleVersion.version(current) < GradleVersion.version("8.2") + }) def "can set params to SpotBugsExtension"() { setup: buildFile << """ @@ -126,7 +127,8 @@ dependencies { @IgnoreIf({ def current = System.getProperty('gradleVersion', GradleVersion.current().version) - return GradleVersion.version(current) < GradleVersion.version("8.2") }) + return GradleVersion.version(current) < GradleVersion.version("8.2") + }) def "can generate spotbugs.html in configured outputLocation"() { buildFile << """ tasks.spotbugsMain { From dbc138c49e982bb3c66586b687dc893182366323 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 16:42:24 +0800 Subject: [PATCH 12/13] Kotlin cleanups --- src/main/kotlin/com/github/spotbugs/snom/SpotBugsExtension.kt | 2 +- src/main/kotlin/com/github/spotbugs/snom/SpotBugsReport.kt | 1 + src/main/kotlin/com/github/spotbugs/snom/SpotBugsTask.kt | 4 ++-- .../kotlin/com/github/spotbugs/snom/internal/OutputScanner.kt | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsExtension.kt b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsExtension.kt index 206440ad..e4a1c9e6 100644 --- a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsExtension.kt +++ b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsExtension.kt @@ -81,7 +81,7 @@ interface SpotBugsExtension { /** * Property to set the directory to generate report files. Default is `"$buildDir/reports/spotbugs"`. * - * Note that each [SpotBugsTask] creates own sub-directory in this directory. + * Note that each [SpotBugsTask] creates own subdirectory in this directory. */ val reportsDir: DirectoryProperty diff --git a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsReport.kt b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsReport.kt index 368c97bb..29bb8126 100644 --- a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsReport.kt +++ b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsReport.kt @@ -97,6 +97,7 @@ abstract class SpotBugsReport } } + @Suppress("MemberVisibilityCanBePrivate") fun configure(action: Action): Report { action.execute(this) return this diff --git a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsTask.kt b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsTask.kt index dae3e4f9..f59062e1 100644 --- a/src/main/kotlin/com/github/spotbugs/snom/SpotBugsTask.kt +++ b/src/main/kotlin/com/github/spotbugs/snom/SpotBugsTask.kt @@ -312,8 +312,8 @@ abstract class SpotBugsTask : DefaultTask(), VerificationTask { else -> throw InvalidUserDataException("$name is invalid as the report name") } } - setDescription("Run SpotBugs analysis.") - setGroup(JavaBasePlugin.VERIFICATION_GROUP) + description = "Run SpotBugs analysis." + group = JavaBasePlugin.VERIFICATION_GROUP } /** diff --git a/src/main/kotlin/com/github/spotbugs/snom/internal/OutputScanner.kt b/src/main/kotlin/com/github/spotbugs/snom/internal/OutputScanner.kt index 0aab98a3..12dd558a 100644 --- a/src/main/kotlin/com/github/spotbugs/snom/internal/OutputScanner.kt +++ b/src/main/kotlin/com/github/spotbugs/snom/internal/OutputScanner.kt @@ -24,7 +24,6 @@ import java.io.OutputStream internal class OutputScanner(out: OutputStream) : FilterOutputStream(out) { private val builder = ByteArrayOutputStream() var isFailedToReport = false - get() = field override fun write( b: ByteArray, From 9a9efd2c2e93dac05105ce460e9358803744338a Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 3 Dec 2023 16:43:10 +0800 Subject: [PATCH 13/13] Disable trim_trailing_whitespace for md files --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.editorconfig b/.editorconfig index 328a07fc..203d331c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,5 +7,8 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true +[*.md] +trim_trailing_whitespace = false + [*.{yml,yaml}] indent_size = 2 \ No newline at end of file