diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b41ae6a..7250671 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,13 +15,14 @@ jobs: java-version: [ 1.8, 11, 17 ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: + distribution: 'zulu' java-version: ${{ matrix.java-version }} - name: Grant execute permission for gradlew @@ -29,33 +30,20 @@ jobs: - name: Cache SonarCloud packages if: matrix.java-version == env.SONAR_JDK - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Cache Gradle packages - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-${{ matrix.java-version }}- - - name: Test with Gradle - run: ./gradlew build check --stacktrace + uses: gradle/gradle-build-action@v2 + with: + arguments: build check --stacktrace - name: SonarCloud if: success() && matrix.java-version == env.SONAR_JDK env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew sonarqube - - - name: Cleanup Gradle Cache - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties + run: ./gradlew sonar --info diff --git a/.gitignore b/.gitignore index 5c25369..097f727 100644 --- a/.gitignore +++ b/.gitignore @@ -65,7 +65,6 @@ dist/ ehthumbs.db fabric.properties gen/ -gradle.properties hs_err_pid* kobaltBuild kobaltw*-test diff --git a/.idea/compiler.xml b/.idea/compiler.xml index d01a390..a857b2a 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index 0d340d7..b23fa44 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -31,5 +31,15 @@ \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 6d605b0..90755e7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -55,6 +55,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -71,12 +107,12 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt index 95f6892..3214597 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) +Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 06f05fd..84e3efc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Semantic Version Annotation Processor [![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause) [![release](https://img.shields.io/github/release/ethauvin/semver.svg)](https://github.com/ethauvin/semver/releases/latest) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver) -[![Known Vulnerabilities](https://snyk.io/test/github/ethauvin/semver/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/ethauvin/semver?targetFile=build.gradle) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_semver&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_semver) [![GitHub CI](https://github.com/ethauvin/semver/actions/workflows/gradle.yml/badge.svg)](https://github.com/ethauvin/semver/actions/workflows/gradle.yml) [![Build status](https://ci.appveyor.com/api/projects/status/nbv4mxd1gpxtx69o?svg=true)](https://ci.appveyor.com/project/ethauvin/semver) [![CircleCI](https://circleci.com/gh/ethauvin/semver/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/semver/tree/master) + +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_semver&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_semver) [![GitHub CI](https://github.com/ethauvin/semver/actions/workflows/gradle.yml/badge.svg)](https://github.com/ethauvin/semver/actions/workflows/gradle.yml) [![Build status](https://ci.appveyor.com/api/projects/status/nbv4mxd1gpxtx69o?svg=true)](https://ci.appveyor.com/project/ethauvin/semver) [![CircleCI](https://circleci.com/gh/ethauvin/semver/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/semver/tree/master) An [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html) that automatically generates a `GeneratedVersion` class based on a [Mustache](https://mustache.github.io/) template and containing the [semantic version](https://semver.org/) (major, minor, patch, etc.) that is read from a [Properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) file or defined in the [annotation](https://docs.oracle.com/javase/tutorial/java/annotations/basics.html). @@ -200,6 +201,10 @@ mvn verify To install and run from [Gradle](https://gradle.org/), add the following to [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle): ```gradle +repositories { + mavenCentral() +} + dependencies { annotationProcessor 'net.thauvin.erik:semver:1.2.0' compileOnly 'net.thauvin.erik:semver:1.2.0' diff --git a/build.gradle b/build.gradle index 50bd1db..6e7d0d4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,18 @@ +// import com.github.spotbugs.snom.SpotBugsTask +import org.apache.tools.ant.taskdefs.condition.Os + plugins { id 'java' id 'jacoco' id 'maven-publish' id 'pmd' id 'signing' - id 'com.github.ben-manes.versions' version '0.42.0' + id 'com.github.ben-manes.versions' version '0.47.0' id 'net.thauvin.erik.gradle.semver' version '1.0.4' - id 'com.github.spotbugs' version '5.0.3' - id 'org.sonarqube' version '3.3' + // id 'com.github.spotbugs' version '5.0.14' + id 'org.sonarqube' version '4.2.1.3168' } -import com.github.spotbugs.snom.SpotBugsTask -import org.apache.tools.ant.taskdefs.condition.Os - defaultTasks 'check' group = 'net.thauvin.erik' @@ -32,8 +32,8 @@ def isNonStable = { String version -> } ext.versions = [ - pmd: '6.44.0', - spotbugs: '4.5.3' + pmd: '6.54.0', + // spotbugs: '4.7.3' ] repositories { @@ -45,13 +45,13 @@ repositories { dependencies { implementation 'com.github.spullara.mustache.java:compiler:0.9.10' - spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0' - spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7' + // spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0' + // spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.6.0' - compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs" - testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs" + // compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs" + // testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs" - testImplementation 'org.testng:testng:7.5' + testImplementation 'org.testng:testng:7.8.0' } @@ -60,8 +60,8 @@ tasks.withType(JavaCompile) { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 withSourcesJar() withJavadocJar() } @@ -136,11 +136,11 @@ javadoc { title = "$mavenDescription $project.version API" } options.with { - source = '8' + source = '17' tags = ['created'] author = true //addBooleanOption('html4', true) - links('https://docs.oracle.com/javase/8/docs/api/') + links('https://docs.oracle.com/en/java/javase/17/docs/api/') //addStringOption('Xdoclint:none', '-quiet') } } @@ -154,19 +154,19 @@ test { useTestNG() } -spotbugs { - toolVersion.set("${versions.spotbugs}") - excludeFilter.set(file("$projectDir/config/spotbugs/excludeFilter.xml")) -} +// spotbugs { +// toolVersion.set("${versions.spotbugs}") +// excludeFilter.set(file("$projectDir/config/spotbugs/excludeFilter.xml")) +// } -tasks.withType(SpotBugsTask) { - reports { - xml.required = false - html.required = true - } -} +// tasks.withType(SpotBugsTask).configureEach { +// reports { +// xml.required = false +// html.required = true +// } +// } -task release { +tasks.register('release') { group = 'Publishing' description = 'Releases new version to local maven repository.' dependsOn(wrapper, clean, publishToMavenLocal) @@ -175,7 +175,7 @@ task release { } } -task pandoc(type: Exec) { +tasks.register('pandoc', Exec) { group = 'Documentation' def pandoc_args = ['--from', 'gfm', '--to', 'html5', @@ -197,7 +197,7 @@ task pandoc(type: Exec) { } jacoco { - toolVersion = '0.8.9-SNAPSHOT' + //toolVersion = '0.8.9' } jacocoTestReport { @@ -217,6 +217,6 @@ sonarqube { } } -tasks.sonarqube { +tasks.sonar { dependsOn 'jacocoTestReport' } diff --git a/config/pmd.xml b/config/pmd.xml index 890a490..e23c3fa 100644 --- a/config/pmd.xml +++ b/config/pmd.xml @@ -72,7 +72,6 @@ - diff --git a/examples/java/build.gradle b/examples/java/build.gradle index 7204d13..9c3c528 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'application' - id 'com.github.ben-manes.versions' version '0.42.0' + id 'com.github.ben-manes.versions' version '0.46.0' } // ./gradlew run diff --git a/examples/java/gradle/wrapper/gradle-wrapper.jar b/examples/java/gradle/wrapper/gradle-wrapper.jar index 7454180..033e24c 100644 Binary files a/examples/java/gradle/wrapper/gradle-wrapper.jar and b/examples/java/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/java/gradle/wrapper/gradle-wrapper.properties b/examples/java/gradle/wrapper/gradle-wrapper.properties index aa991fc..9f4197d 100644 --- a/examples/java/gradle/wrapper/gradle-wrapper.properties +++ b/examples/java/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/java/gradlew b/examples/java/gradlew index 1b6c787..fcb6fca 100755 --- a/examples/java/gradlew +++ b/examples/java/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +213,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/examples/java/gradlew.bat b/examples/java/gradlew.bat index 107acd3..93e3f59 100644 --- a/examples/java/gradlew.bat +++ b/examples/java/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts index 2c0f39d..9529c16 100644 --- a/examples/kotlin/build.gradle.kts +++ b/examples/kotlin/build.gradle.kts @@ -1,8 +1,8 @@ plugins { id("application") - id("com.github.ben-manes.versions") version "0.42.0" - kotlin("jvm") version "1.6.21" - kotlin("kapt") version "1.6.21" + id("com.github.ben-manes.versions") version "0.46.0" + kotlin("jvm") version "1.7.22" + kotlin("kapt") version "1.7.22" } // ./gradlew @@ -48,13 +48,13 @@ tasks { register("runJavaExample", JavaExec::class) { group = "application" - main = "com.example.JavaExample" + mainClass.set("com.example.JavaExample") classpath = sourceSets.main.get().runtimeClasspath } register("runExample", JavaExec::class) { group = "application" - main = "com.example.Example" + mainClass.set("com.example.Example") classpath = sourceSets.main.get().runtimeClasspath } } diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/kotlin/gradle/wrapper/gradle-wrapper.jar index 7454180..033e24c 100644 Binary files a/examples/kotlin/gradle/wrapper/gradle-wrapper.jar and b/examples/kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties index aa991fc..9f4197d 100644 --- a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/kotlin/gradlew b/examples/kotlin/gradlew index 1b6c787..fcb6fca 100755 --- a/examples/kotlin/gradlew +++ b/examples/kotlin/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +213,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/examples/kotlin/gradlew.bat b/examples/kotlin/gradlew.bat index 107acd3..93e3f59 100644 --- a/examples/kotlin/gradlew.bat +++ b/examples/kotlin/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/examples/test/build.gradle b/examples/test/build.gradle index 7ba6d12..9444d47 100644 --- a/examples/test/build.gradle +++ b/examples/test/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'application' - id 'com.github.ben-manes.versions' version '0.38.0' + id 'com.github.ben-manes.versions' version '0.46.0' } // ./gradlew run diff --git a/examples/test/gradle/wrapper/gradle-wrapper.properties b/examples/test/gradle/wrapper/gradle-wrapper.properties index aa991fc..9f4197d 100644 --- a/examples/test/gradle/wrapper/gradle-wrapper.properties +++ b/examples/test/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/test/gradlew b/examples/test/gradlew index 1b6c787..fcb6fca 100755 --- a/examples/test/gradlew +++ b/examples/test/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +213,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/examples/test/gradlew.bat b/examples/test/gradlew.bat index 107acd3..93e3f59 100644 --- a/examples/test/gradlew.bat +++ b/examples/test/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..033e24c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..9f4197d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..fcb6fca 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -205,6 +213,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/preflightcheck.sh b/preflightcheck.sh index 3642481..76c698d 100755 --- a/preflightcheck.sh +++ b/preflightcheck.sh @@ -13,7 +13,7 @@ declare -a examples=( # e.g: empty or javadoc, etc. gradle_doc="javadoc pandoc" # e.g. empty or sonarqube -gradle_sonar="sonarqube" +gradle_sonar="sonar" # gradle options for examples gradle_opts="--console=plain --no-build-cache --no-daemon" # maven arguments for examples diff --git a/src/main/java/net/thauvin/erik/semver/Constants.java b/src/main/java/net/thauvin/erik/semver/Constants.java index 70a0ca7..27c0733 100644 --- a/src/main/java/net/thauvin/erik/semver/Constants.java +++ b/src/main/java/net/thauvin/erik/semver/Constants.java @@ -1,7 +1,7 @@ /* * Constants.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/main/java/net/thauvin/erik/semver/Version.java b/src/main/java/net/thauvin/erik/semver/Version.java index e6ec6c1..98b18db 100644 --- a/src/main/java/net/thauvin/erik/semver/Version.java +++ b/src/main/java/net/thauvin/erik/semver/Version.java @@ -1,7 +1,7 @@ /* * Version.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/main/java/net/thauvin/erik/semver/VersionInfo.java b/src/main/java/net/thauvin/erik/semver/VersionInfo.java index 95b12b1..297dc08 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionInfo.java +++ b/src/main/java/net/thauvin/erik/semver/VersionInfo.java @@ -1,7 +1,7 @@ /* * VersionInfo.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java index bfc2b89..878f478 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java +++ b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java @@ -1,7 +1,7 @@ /* * VersionProcessor.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,6 @@ import com.github.mustachejava.DefaultMustacheFactory; import com.github.mustachejava.Mustache; import com.github.mustachejava.MustacheFactory; import com.github.mustachejava.MustacheNotFoundException; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import javax.annotation.processing.*; import javax.lang.model.SourceVersion; @@ -75,7 +74,6 @@ public class VersionProcessor extends AbstractProcessor { log(Diagnostic.Kind.ERROR, t != null ? t.toString() : s); } - @SuppressFBWarnings({"PATH_TRAVERSAL_IN"}) private VersionInfo findValues(final Version version) throws IOException { final VersionInfo versionInfo = new VersionInfo(version); @@ -125,7 +123,6 @@ public class VersionProcessor extends AbstractProcessor { return versionInfo; } - @SuppressFBWarnings("PATH_TRAVERSAL_IN") private File getLocalFile(final String fileName) { if (processingEnv != null) { // null when testing. final String prop = processingEnv.getOptions().get(Constants.SEMVER_PROJECT_DIR_ARG); @@ -227,25 +224,17 @@ public class VersionProcessor extends AbstractProcessor { log(Diagnostic.Kind.WARNING, s); } - @SuppressFBWarnings({"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"}) private void writeTemplate(final String type, final VersionInfo versionInfo, final String template) throws IOException { final File dir = getLocalFile(""); final MustacheFactory mf = new DefaultMustacheFactory(dir); final Mustache mustache = mf.compile(template); - final String templateName; - switch (mustache.getName()) { - case Constants.DEFAULT_JAVA_TEMPLATE: - templateName = "default (Java)"; - break; - case Constants.DEFAULT_KOTLIN_TEMPLATE: - templateName = "default (Kotlin)"; - break; - default: - templateName = mustache.getName() + " (" + dir.getAbsolutePath() + ')'; - break; - } + final String templateName = switch (mustache.getName()) { + case Constants.DEFAULT_JAVA_TEMPLATE -> "default (Java)"; + case Constants.DEFAULT_KOTLIN_TEMPLATE -> "default (Kotlin)"; + default -> mustache.getName() + " (" + dir.getAbsolutePath() + ')'; + }; note("Loaded template: " + templateName); final String fileName = versionInfo.getClassName() + '.' + type; diff --git a/src/test/java/net/thauvin/erik/semver/ConstantsTest.java b/src/test/java/net/thauvin/erik/semver/ConstantsTest.java index eb7fabf..0847819 100644 --- a/src/test/java/net/thauvin/erik/semver/ConstantsTest.java +++ b/src/test/java/net/thauvin/erik/semver/ConstantsTest.java @@ -1,7 +1,7 @@ /* * ConstantsTest.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java index 5de7828..47b0436 100644 --- a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java +++ b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java @@ -1,7 +1,7 @@ /* * VersionInfoTest.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,6 @@ package net.thauvin.erik.semver; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.testng.Assert; import org.testng.annotations.Test; @@ -47,7 +46,6 @@ import static org.testng.Assert.assertEquals; * @created 2016-02-03 * @since 1.0 */ -@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS") public class VersionInfoTest { private VersionInfo versionInfo = new VersionInfo(); diff --git a/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java b/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java index 8e2315d..5fe3e12 100644 --- a/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java +++ b/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java @@ -1,7 +1,7 @@ /* * VersionProcessorTest.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,6 @@ package net.thauvin.erik.semver; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.testng.annotations.Test; import java.lang.reflect.InvocationTargetException; @@ -52,7 +51,6 @@ public class VersionProcessorTest { private final VersionProcessor processor = new VersionProcessor(); private final Version version = new VersionTest(); - @SuppressFBWarnings("RFI_SET_ACCESSIBLE") @SuppressWarnings("PMD.AvoidAccessibilityAlteration") @Test public void testFindValues() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { @@ -64,7 +62,6 @@ public class VersionProcessorTest { assertEquals(versionInfo.getProject(), "James Bond", "getProject(James Bond)"); } - @SuppressFBWarnings("RFI_SET_ACCESSIBLE") @SuppressWarnings("PMD.AvoidAccessibilityAlteration") @Test public void testParseIntProperty() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { diff --git a/src/test/java/net/thauvin/erik/semver/VersionTest.java b/src/test/java/net/thauvin/erik/semver/VersionTest.java index ea311ac..8c2a76e 100644 --- a/src/test/java/net/thauvin/erik/semver/VersionTest.java +++ b/src/test/java/net/thauvin/erik/semver/VersionTest.java @@ -1,7 +1,7 @@ /* * VersionTest.java * - * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2023, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ import java.lang.annotation.Annotation; * @created 2019-04-02 * @since 1.2.0 */ -@SuppressWarnings({"ClassExplicitlyAnnotation", "SameReturnValue", "java:S2187"}) +@SuppressWarnings({"ClassExplicitlyAnnotation", "SameReturnValue", "java:S2187", "PMD.TestClassWithoutTestCases"}) class VersionTest implements Version { @Override public Class annotationType() {