From 06d78e762b1e84916684e17714fc0cde459422ff Mon Sep 17 00:00:00 2001 From: Amit Kumar Deohoria Date: Thu, 11 Sep 2025 10:33:42 +0530 Subject: [PATCH] Issue #957: Updating docker Script to Use Groovy5 --- .circleci/config.yml | 2 +- checkstyle-tester/diff.groovy | 26 ++++++++++++------- .../jdk-21-groovy-git-mvn-ant-jq/Dockerfile | 6 ++--- patch-diff-report-tool/pom.xml | 5 ++++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e0730777..1ecfc9ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,7 +51,7 @@ workflows: jobs: - validate-with-maven-script: name: "releasenotes-builder" - image-name: &custom_img "amitkumardeoghoria/jdk-17-groovy-git-mvn:v1.0" + image-name: &custom_img "amitkumardeoghoria/jdk-21-groovy5-git-mvn-ant-jq:latest" command: "./.ci/validation.sh releasenotes-builder" - validate-with-maven-script: name: "patch-diff-report-tool" diff --git a/checkstyle-tester/diff.groovy b/checkstyle-tester/diff.groovy index 5524949d..3c922e40 100644 --- a/checkstyle-tester/diff.groovy +++ b/checkstyle-tester/diff.groovy @@ -1,3 +1,5 @@ +import groovy.util.CliBuilder +import groovy.util.AntBuilder import static java.lang.System.err import static java.nio.file.StandardCopyOption.REPLACE_EXISTING @@ -50,32 +52,36 @@ static void main(String[] args) { def getCliOptions(args) { def cliOptionsDescLineLength = 120 - def cli = new CliBuilder(usage:'groovy diff.groovy [options]', header: 'options:', width: cliOptionsDescLineLength) + def cli = new CliBuilder( + usageMessage: 'groovy diff.groovy [options]', + headerHeading: 'Options:\n', + width: cliOptionsDescLineLength + ) cli.with { - r(longOpt: 'localGitRepo', args: 1, required: true, argName: 'path', + r(longOpt: 'localGitRepo', arity: "1", required: true, argName: 'path', 'Path to local git repository (required)') - b(longOpt: 'baseBranch', args: 1, required: false, argName: 'branch_name', + b(longOpt: 'baseBranch', arity: "1", required: false, argName: 'branch_name', 'Base branch name. Default is master (optional, default is master)') - p(longOpt: 'patchBranch', args: 1, required: true, argName: 'branch_name', + p(longOpt: 'patchBranch', arity: "1", required: true, argName: 'branch_name', 'Name of the patch branch in local git repository (required)') - bc(longOpt: 'baseConfig', args: 1, required: false, argName: 'path', 'Path to the base ' \ + bc(longOpt: 'baseConfig', arity: "1", required: false, argName: 'path', 'Path to the base ' \ + 'checkstyle config file (optional, if absent then the tool will use only ' \ + 'patchBranch in case the tool mode is \'single\', otherwise baseBranch ' \ + 'will be set to \'master\')') - pc(longOpt: 'patchConfig', args: 1, required: false, argName: 'path', + pc(longOpt: 'patchConfig', arity: "1", required: false, argName: 'path', 'Path to the patch checkstyle config file (required if baseConfig is specified)') - c(longOpt: 'config', args: 1, required: false, argName: 'path', 'Path to the checkstyle ' \ + c(longOpt: 'config', arity: "1", required: false, argName: 'path', 'Path to the checkstyle ' \ + 'config file (required if baseConfig and patchConfig are not secified)') g(longOpt: 'allowExcludes', required: false, 'Whether to allow excludes specified in the list of ' \ + 'projects (optional, default is false)') h(longOpt: 'useShallowClone', 'Enable shallow cloning') - l(longOpt: 'listOfProjects', args: 1, required: true, argName: 'path', + l(longOpt: 'listOfProjects', arity: "1", required: true, argName: 'path', 'Path to file which contains projects to test on (required)') s(longOpt: 'shortFilePaths', required: false, 'Whether to save report file paths' \ + ' as a shorter version to prevent long paths. (optional, default is false)') - m(longOpt: 'mode', args: 1, required: false, argName: 'mode', 'The mode of the tool:' \ + m(longOpt: 'mode', arity: "1", required: false, argName: 'mode', 'The mode of the tool:' \ + ' \'diff\' or \'single\'. (optional, default is \'diff\')') - xm(longOpt: 'extraMvnRegressionOptions', args: 1, required: false, 'Extra arguments to pass to Maven' \ + xm(longOpt: 'extraMvnRegressionOptions', arity: "1", required: false, 'Extra arguments to pass to Maven' \ + 'for Checkstyle Regression run (optional, ex: -Dmaven.prop=true)') } return cli.parse(args) diff --git a/devops/docker/no-exception-build-image/jdk-21-groovy-git-mvn-ant-jq/Dockerfile b/devops/docker/no-exception-build-image/jdk-21-groovy-git-mvn-ant-jq/Dockerfile index eadc46c0..a6c248f2 100644 --- a/devops/docker/no-exception-build-image/jdk-21-groovy-git-mvn-ant-jq/Dockerfile +++ b/devops/docker/no-exception-build-image/jdk-21-groovy-git-mvn-ant-jq/Dockerfile @@ -12,7 +12,7 @@ RUN curl -s "https://get.sdkman.io" | bash # Install Java 21, Groovy, Maven via SDKMAN RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && \ sdk install java 21.0.4-tem && \ - sdk install groovy 3.0.21 && \ + sdk install groovy 5.0.0 && \ sdk install maven 3.9.11" # Update PATH and setup environment @@ -24,6 +24,4 @@ ENV PATH=$GROOVY_HOME/bin:$SDKMAN_DIR/candidates/maven/current/bin:$JAVA_HOME/bi RUN bash -c "source $SDKMAN_DIR/bin/sdkman-init.sh && \ java -version && \ groovy --version && \ - mvn -version && \ - groovy -e 'new CliBuilder(); println \"CliBuilder OK\"' && \ - groovy -e 'new AntBuilder(); println \"AntBuilder OK\"'" + mvn -version" diff --git a/patch-diff-report-tool/pom.xml b/patch-diff-report-tool/pom.xml index fc67375c..08be6814 100644 --- a/patch-diff-report-tool/pom.xml +++ b/patch-diff-report-tool/pom.xml @@ -24,6 +24,11 @@ 4.13.2 test + + org.apache.groovy + groovy-ant + 4.0.23 + org.apache.maven maven-jxr