From b7fdd3fa6d3c5b178b50a33a3b9c04465ef8abb1 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Thu, 28 Mar 2024 19:33:59 +0100 Subject: [PATCH] Align CLI with Groovy2Java migration --- build.gradle | 10 +++++----- htmlSanityCheck-cli/build.gradle | 2 ++ .../org/aim42/htmlsanitycheck/cli/Main.groovy | 12 +++++++----- htmlSanityCheck-core/build.gradle | 2 -- .../org/aim42/htmlsanitycheck/Configuration.java | 15 ++++++++++----- htmlSanityCheck-gradle-plugin/build.gradle | 2 ++ integration-test/gradle-plugin/build.gradle | 2 +- 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index 900d1500..9ea3107d 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,6 @@ allprojects { configure(subprojects) { apply plugin: 'java' - apply plugin: 'groovy' apply plugin: 'maven-publish' apply plugin: 'jacoco' @@ -51,7 +50,8 @@ configure(subprojects) { description "${rootProject.description} - Module ${project.name}" dependencies { - implementation platform (libs.slf4j.bom) + implementation platform(libs.groovy.bom) + implementation platform(libs.slf4j.bom) testImplementation platform(libs.spock) testImplementation "org.spockframework:spock-core" @@ -72,7 +72,7 @@ configure(subprojects) { name = 'myLocalRepositoryForFullIntegrationTests' //noinspection GrDeprecatedAPIUsage File baseDir = file(project.parent.buildDir) - url = new File (baseDir, "maven-repo") + url = new File(baseDir, "maven-repo") } mavenLocal() } @@ -90,10 +90,10 @@ configure(subprojects) { } } -tasks.register("integrationTestOnly") { final String INTEGRATION_TEST_DIRECTORY = "integration-test" final String INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN = "${INTEGRATION_TEST_DIRECTORY}/gradle-plugin" final String INTEGRATION_TEST_DIRECTORY_CLI = "${INTEGRATION_TEST_DIRECTORY}/cli" + static void cleanBuild(String baseDirectory) { File integrationTestBuildDir = new File("${baseDirectory}/${Project.DEFAULT_BUILD_DIR_NAME}") if (integrationTestBuildDir.exists()) { @@ -157,7 +157,7 @@ integrationTestCli.dependsOn( ':htmlSanityCheck-cli:installDist' ) integrationTestCli.configure { - shouldRunAfter (':htmlSanityCheck-cli:check') + shouldRunAfter(':htmlSanityCheck-cli:check') } tasks.register("cleanIntegrationTestCli", Delete) { group("Build") diff --git a/htmlSanityCheck-cli/build.gradle b/htmlSanityCheck-cli/build.gradle index 3fdcdf4b..edf797ee 100644 --- a/htmlSanityCheck-cli/build.gradle +++ b/htmlSanityCheck-cli/build.gradle @@ -1,11 +1,13 @@ plugins { id 'application' + id 'groovy' } dependencies { implementation libs.picocli.impl annotationProcessor libs.picocli.annotationprocessor + implementation 'org.codehaus.groovy:groovy' implementation 'org.slf4j:slf4j-api' implementation 'org.slf4j:slf4j-simple' diff --git a/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy b/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy index ed5b080e..09dcc169 100644 --- a/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy +++ b/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy @@ -2,6 +2,7 @@ package org.aim42.htmlsanitycheck.cli import org.aim42.htmlsanitycheck.AllChecksRunner import org.aim42.htmlsanitycheck.Configuration +import org.aim42.htmlsanitycheck.check.AllCheckers import org.slf4j.Logger import org.slf4j.LoggerFactory import picocli.CommandLine @@ -87,12 +88,13 @@ class Main implements Runnable { System.exit(1) } - var configuration = new Configuration() - configuration.addConfigurationItem(Configuration.ITEM_NAME_sourceDir, main.srcDir) - configuration.addConfigurationItem(Configuration.ITEM_NAME_sourceDocuments, srcDocuments) - var resultsDirectory = new File(main.resultsDirectoryName) - configuration.addConfigurationItem((Configuration.ITEM_NAME_checkingResultsDir), resultsDirectory) + var configuration = Configuration.builder() + .sourceDir(main.srcDir) + .sourceDocuments(srcDocuments as Set) + .checkingResultsDir(resultsDirectory) + .checksToExecute(AllCheckers.CHECKER_CLASSES) + .build() if (configuration.isValid()) { // create output directory for checking results diff --git a/htmlSanityCheck-core/build.gradle b/htmlSanityCheck-core/build.gradle index 94bc3e44..b98ec12a 100644 --- a/htmlSanityCheck-core/build.gradle +++ b/htmlSanityCheck-core/build.gradle @@ -5,8 +5,6 @@ dependencies { // Having a vulnerability here ... exclude group: 'commons-collections', module: 'commons-collections' } - implementation libs.slf4j.api - testImplementation libs.slf4j.nop implementation 'org.slf4j:slf4j-api' testImplementation 'org.slf4j:slf4j-nop' // jsoup is our awesome html parser, see jsoup.org diff --git a/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/Configuration.java b/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/Configuration.java index 098bcd6c..80c4426c 100644 --- a/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/Configuration.java +++ b/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/Configuration.java @@ -32,11 +32,16 @@ public class Configuration { File sourceDir; File checkingResultsDir; File junitResultsDir; - Boolean consoleReport; - Boolean failOnErrors; - Integer httpConnectionTimeout; - Boolean ignoreLocalhost; - Boolean ignoreIPAddresses; + @Builder.Default + Boolean consoleReport = false; + @Builder.Default + Boolean failOnErrors = false; + @Builder.Default + Integer httpConnectionTimeout = 5000; + @Builder.Default + Boolean ignoreLocalhost = false; + @Builder.Default + Boolean ignoreIPAddresses = false; /* * Explanation for configuring http status codes: * The standard http status codes are defined in class @link NetUtil and can diff --git a/htmlSanityCheck-gradle-plugin/build.gradle b/htmlSanityCheck-gradle-plugin/build.gradle index e0a8e9d8..aeded95e 100755 --- a/htmlSanityCheck-gradle-plugin/build.gradle +++ b/htmlSanityCheck-gradle-plugin/build.gradle @@ -1,4 +1,6 @@ plugins { + id 'groovy' + id 'java-gradle-plugin' id 'jacoco-report-aggregation' diff --git a/integration-test/gradle-plugin/build.gradle b/integration-test/gradle-plugin/build.gradle index b8770ed0..e7cc2c3c 100644 --- a/integration-test/gradle-plugin/build.gradle +++ b/integration-test/gradle-plugin/build.gradle @@ -12,7 +12,7 @@ plugins { } htmlSanityCheck { - sourceDir = file("src/test/resources") + sourceDir = file("../common/src/test/resources") // where to put results of sanityChecks... checkingResultsDir = file("build/reports")