diff --git a/build.sh b/build.sh index 4ef55dc..ba1ca0c 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -./gradlew clean cE eclipse build publishToMavenLocal || exit 1 +./gradlew publishToMavenLocal -Pversion=latest-SNAPSHOT || exit 1 cd violations-gradle-plugin-example -./gradlew violations violationsMaxAsProperty +./gradlew violations diff --git a/gradle.properties b/gradle.properties index 64c4ba4..1e9f402 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # -#Thu Nov 07 16:53:40 CET 2024 +#Sat Nov 09 05:57:23 CET 2024 description=Find report files from static code analysis, present and optionally fail the build. group=se.bjurr.violations implementationClass=se.bjurr.violations.gradle.plugin.ViolationsGradlePlugin @@ -9,4 +9,4 @@ sourceCompatibility=11 stripGradlePluginSuffix=false tags=violation,static code analysis,Checkstyle,CPPLint,CPPCheck,CSSLint,Findbugs,Flake8,PyLint,Pep8,Mccabe,PyFlakes,JSHint,Lint,PerlCritic,PMD,ReSharper,XMLLint targetCompatibility=11 -version=2.3.0 +version=2.3.1 diff --git a/src/main/java/se/bjurr/violations/gradle/plugin/ViolationsTask.java b/src/main/java/se/bjurr/violations/gradle/plugin/ViolationsTask.java index 2e21073..d3ed197 100644 --- a/src/main/java/se/bjurr/violations/gradle/plugin/ViolationsTask.java +++ b/src/main/java/se/bjurr/violations/gradle/plugin/ViolationsTask.java @@ -57,10 +57,6 @@ public class ViolationsTask extends DefaultTask { public File violationsFile; public ViolationsLogger violationsLogger; - public void setMaxViolations(final Integer maxViolations) { - this.maxViolations.set(maxViolations); - } - @TaskAction public void violationsPluginTasks() throws Exception { this.violationsLogger = diff --git a/violations-gradle-plugin-example/build.gradle b/violations-gradle-plugin-example/build.gradle index 373b37a..8349fe4 100644 --- a/violations-gradle-plugin-example/build.gradle +++ b/violations-gradle-plugin-example/build.gradle @@ -95,17 +95,23 @@ task violations(type: se.bjurr.violations.gradle.plugin.ViolationsTask) { ] } +/** + * Test lazy loaded value. + */ +interface ViolationsTestExtension { + Property getMaxViolations() +} -task violationsMaxAsProperty(type: se.bjurr.violations.gradle.plugin.ViolationsTask) { - // Lazy loading - maxViolations = 99999999 +def extension = project.extensions.create("violationsTestExtension", ViolationsTestExtension) +extension.maxViolations.convention(Integer.MAX_VALUE) - violations = [ - [ - "FINDBUGS", - projectDir.path, - ".*/findbugs/.*\\.xml\$", - "Findbugs" - ] - ] +task violationsWithTestExtension(type: se.bjurr.violations.gradle.plugin.ViolationsTask) { + maxViolations = extension.maxViolations.get() +} + +/** + * Run all tests on build + */ +project.tasks.withType(se.bjurr.violations.gradle.plugin.ViolationsTask) { vt -> + build.dependsOn vt }