From e01ea7882f013e62a388cb22f6879f377e65386a Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 3 Jan 2022 14:35:44 -0800 Subject: [PATCH] Updated dependencies and copyright. --- .circleci/config.yml | 64 +++-- .github/workflows/gradle.yml | 4 +- .gitignore | 39 +-- .idea/copyright/profiles_settings.xml | 6 +- .../inspectionProfiles/profiles_settings.xml | 2 +- .idea/runConfigurations.xml | 10 + LICENSE.txt | 2 +- appveyor.yml | 6 +- build.gradle | 22 +- examples/java/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- examples/java/gradlew | 269 +++++++++++------- examples/kotlin/build.gradle.kts | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- examples/kotlin/gradlew | 269 +++++++++++------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- examples/test/gradlew | 269 +++++++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 269 +++++++++++------- preflightcheck.sh | 264 ++++++++--------- .../net/thauvin/erik/semver/Constants.java | 2 +- .../java/net/thauvin/erik/semver/Version.java | 2 +- .../net/thauvin/erik/semver/VersionInfo.java | 2 +- .../thauvin/erik/semver/VersionProcessor.java | 4 +- .../java/net/thauvin/erik/semver/package.html | 32 +++ .../thauvin/erik/semver/ConstantsTest.java | 2 +- .../thauvin/erik/semver/VersionInfoTest.java | 2 +- .../erik/semver/VersionProcessorTest.java | 4 +- .../net/thauvin/erik/semver/VersionTest.java | 4 +- updatewrappers.sh | 54 ++-- 30 files changed, 933 insertions(+), 686 deletions(-) create mode 100644 .idea/runConfigurations.xml diff --git a/.circleci/config.yml b/.circleci/config.yml index 4690865..d753e7d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,44 +1,54 @@ version: 2 defaults: &defaults working_directory: ~/repo - docker: - - image: circleci/openjdk:8-jdk environment: JVM_OPTS: -Xmx3200m TERM: dumb + CI: true -jobs: - build_gradle: - <<: *defaults - - steps: - - checkout - - restore_cache: - keys: - - gradle-dependencies-{{ checksum "build.gradle" }} +defaults_gradle: &defaults_gradle + steps: + - checkout + - restore_cache: + keys: + - gradle-dependencies-{{ checksum "build.gradle.kts" }} # fallback to using the latest cache if no exact match is found - gradle-dependencies- + - run: + name: Gradle Dependencies + command: ./gradlew dependencies + - save_cache: + paths: ~/.m2 + key: gradle-dependencies-{{ checksum "build.gradle.kts" }} + - run: + name: Run All Checks + command: ./gradlew check + - store_artifacts: + path: build/reports/ + destination: reports + - store_test_results: + path: build/reports/ - - run: - name: Gradle Dependencies - command: ./gradlew dependencies +jobs: + build_gradle_jdk17: + <<: *defaults - - save_cache: - paths: ~/.m2 - key: gradle-dependencies-{{ checksum "build.gradle" }} + docker: + - image: cimg/openjdk:17.0 - - run: - name: Run All Checks - command: ./gradlew check + <<: *defaults_gradle - - store_artifacts: - path: build/reports/ - destination: reports - - store_test_results: - path: build/reports/ + build_gradle_jdk8: + <<: *defaults + + docker: + - image: cimg/openjdk:8.0 + + <<: *defaults_gradle workflows: version: 2 - build_gradle_jdk8: + gradle: jobs: - - build_gradle + - build_gradle_jdk8 + - build_gradle_jdk17 diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 251e704..b41ae6a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,6 +1,6 @@ name: gradle-ci -on: [push, pull_request, workflow_dispatch] +on: [ push, pull_request, workflow_dispatch ] jobs: build: @@ -12,7 +12,7 @@ jobs: strategy: matrix: - java-version: [ 1.8, 11, 15 ] + java-version: [ 1.8, 11, 17 ] steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index f007981..5c25369 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,8 @@ -.vscode/* + !.vscode/extensions.json !.vscode/launch.json !.vscode/settings.json !.vscode/tasks.json - -__pycache__ -.classpath -.DS_Store -.gradle -.history -.kobalt -.mtj.tmp/ -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.nb-gradle -.project -.scannerwork -.settings *.class *.code-workspace *.ctxt @@ -27,7 +13,21 @@ __pycache__ *.sublime-* *.tar.gz *.zip -/**/.idea_modules/ +.DS_Store +.classpath +.gradle +.history +.kobalt +.mtj.tmp/ +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.nb-gradle +.project +.scannerwork +.settings +.vscode/* +/**/.idea/$CACHE_FILE$ +/**/.idea/$PRODUCT_WORKSPACE_FILE$ /**/.idea/**/caches/build_file_checksums.ser /**/.idea/**/contentModel.xml /**/.idea/**/dataSources.ids @@ -48,8 +48,10 @@ __pycache__ /**/.idea/**/uiDesigner.xml /**/.idea/**/usage.statistics.xml /**/.idea/**/workspace.xml -/**/.idea/$CACHE_FILE$ -/**/.idea/$PRODUCT_WORKSPACE_FILE$ +/**/.idea/sonarlint* +/**/.idea_modules/ +Thumbs.db +__pycache__ atlassian-ide-plugin.xml bin/ build/ @@ -80,5 +82,4 @@ project.properties release.properties target/ test-output -Thumbs.db venv diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index 69bc70d..1419e40 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,7 +1,3 @@ - - - - - + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml index dc2dcae..dd4c951 100644 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -1,6 +1,6 @@ - diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt index ee0c2ec..95f6892 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016-2021, Erik C. Thauvin (erik@thauvin.net) +Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/appveyor.yml b/appveyor.yml index dd9bd2a..d902a4e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ image: - - Visual Studio 2019 + - Visual Studio 2019 version: "{branch} {build}" skip_tags: true @@ -23,8 +23,8 @@ cache: environment: matrix: - - JAVA_HOME: C:\Program Files\Java\jdk15 - - JAVA_HOME: C:\Program Files\Java\jdk11 + - JAVA_HOME: C:\Program Files\Java\jdk15 + - JAVA_HOME: C:\Program Files\Java\jdk11 matrix: fast_finish: true diff --git a/build.gradle b/build.gradle index b6d9447..9c1471e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,9 +4,9 @@ plugins { id 'maven-publish' id 'pmd' id 'signing' - id 'com.github.ben-manes.versions' version '0.39.0' + id 'com.github.ben-manes.versions' version '0.40.0' id 'net.thauvin.erik.gradle.semver' version '1.0.4' - id 'com.github.spotbugs' version '4.7.1' + id 'com.github.spotbugs' version '5.0.3' id 'org.sonarqube' version '3.3' } @@ -25,9 +25,15 @@ final def mavenLicenseUrl = 'http://opensource.org/licenses/BSD-3-Clause' final def mavenScmCon = 'https://github.com/ethauvin/semver.git' final def mavenScmDevCon = 'git@github.com:ethauvin/semver.git' +def isNonStable = { String version -> + def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } + def regex = /^[0-9,.v-]+(-r)?$/ + return !stableKeyword && !(version ==~ regex) +} + ext.versions = [ - pmd: '6.35.0', - spotbugs: '4.2.3' + pmd: '6.41.0', + spotbugs: '4.5.2' ] repositories { @@ -59,6 +65,12 @@ java { withJavadocJar() } +tasks.named("dependencyUpdates").configure { + rejectVersionIf { + isNonStable(it.candidate.version) + } +} + pmd { toolVersion = versions.pmd ignoreFailures = true @@ -184,7 +196,7 @@ task pandoc(type: Exec) { } jacocoTestReport { - dependsOn(test) + dependsOn test reports { html.required = true xml.required = true diff --git a/examples/java/build.gradle b/examples/java/build.gradle index 80e59f5..d10460e 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.39.0' + id 'com.github.ben-manes.versions' version '0.40.0' } // ./gradlew run diff --git a/examples/java/gradle/wrapper/gradle-wrapper.properties b/examples/java/gradle/wrapper/gradle-wrapper.properties index 69a9715..2e6e589 100644 --- a/examples/java/gradle/wrapper/gradle-wrapper.properties +++ b/examples/java/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/java/gradlew b/examples/java/gradlew index 744e882..1b6c787 100755 --- a/examples/java/gradlew +++ b/examples/java/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# 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 +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +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"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MSYS* | MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# 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 +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts index 442d77f..47a02a2 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.39.0" - kotlin("jvm") version "1.5.10" - kotlin("kapt") version "1.5.10" + id("com.github.ben-manes.versions") version "0.40.0" + kotlin("jvm") version "1.6.10" + kotlin("kapt") version "1.6.10" } // ./gradlew diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties index 69a9715..2e6e589 100644 --- a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/kotlin/gradlew b/examples/kotlin/gradlew index 744e882..1b6c787 100755 --- a/examples/kotlin/gradlew +++ b/examples/kotlin/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# 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 +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +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"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MSYS* | MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# 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 +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/test/gradle/wrapper/gradle-wrapper.properties b/examples/test/gradle/wrapper/gradle-wrapper.properties index e5338d3..2e6e589 100644 --- a/examples/test/gradle/wrapper/gradle-wrapper.properties +++ b/examples/test/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/test/gradlew b/examples/test/gradlew index 4f906e0..1b6c787 100755 --- a/examples/test/gradlew +++ b/examples/test/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# 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 +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +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"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# 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 +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 69a9715..2e6e589 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 744e882..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# 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 +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +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"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MSYS* | MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# 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 +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/preflightcheck.sh b/preflightcheck.sh index 1c8272a..3642481 100755 --- a/preflightcheck.sh +++ b/preflightcheck.sh @@ -8,8 +8,8 @@ ext=".java" java8=true # e.g: declare -a examples=( - "examples/java run runExample" - "examples/kotlin run runJava runExample runJavaExample") + "examples/java run runExample" + "examples/kotlin run runJava runExample runJavaExample") # e.g: empty or javadoc, etc. gradle_doc="javadoc pandoc" # e.g. empty or sonarqube @@ -23,10 +23,9 @@ maven_args="compile exec:java" # Version: 1.1.5 # -if [ "$java8" = true ] -then - export JAVA_HOME="$JAVA8_HOME" - export PATH="$(cygpath "$JAVA_HOME")/bin:$PATH" +if [ "$java8" = true ]; then + export JAVA_HOME="$JAVA8_HOME" + export PATH="$(cygpath "$JAVA_HOME")/bin:$PATH" fi pwd=$PWD @@ -40,174 +39,163 @@ pause() { } checkCopyright() { - if [ "$(grep -c "$date" "$1")" == "0" ] - then - echo -e " Invalid: ${red}$f${std}" - else - echo -e " Checked: $1" - fi + if [ "$(grep -c "$date" "$1")" == "0" ]; then + echo -e " Invalid: ${red}$f${std}" + else + echo -e " Checked: $1" + fi } runGradle() { - cd "$1" || exit 1 - clear - reset - echo -e "> Project: ${cyan}${1}${std} [Gradle]" - shift - ./gradlew $@ || exit 1 - pause - cd "$pwd" + cd "$1" || exit 1 + clear + reset + echo -e "> Project: ${cyan}${1}${std} [Gradle]" + shift + ./gradlew $@ || exit 1 + pause + cd "$pwd" } runKobalt() { - cd "$1" || exit 1 - if [ -f kobalt/src/Build.kt ] - then - clear - reset - echo -e "> Project: ${cyan}${1}${std} [Kobalt]" - shift - ./kobaltw $@ || exit 1 - pause - fi - cd "$pwd" + cd "$1" || exit 1 + if [ -f kobalt/src/Build.kt ]; then + clear + reset + echo -e "> Project: ${cyan}${1}${std} [Kobalt]" + shift + ./kobaltw $@ || exit 1 + pause + fi + cd "$pwd" } runMaven() { - cd "$1" || exit 1 - if [ -f pom.xml ] - then - clear - reset - echo -e "> Project: ${cyan}${1}${std} [Maven]" - shift - mvn $@ || exit 1 - pause - fi - cd "$pwd" + cd "$1" || exit 1 + if [ -f pom.xml ]; then + clear + reset + echo -e "> Project: ${cyan}${1}${std} [Maven]" + shift + mvn $@ || exit 1 + pause + fi + cd "$pwd" } updateWrappers() { - clear - ./updatewrappers.sh - pause + clear + ./updatewrappers.sh + pause } checkDeps() { - clear - echo -e "${cyan}Checking depencencies...${std}" - gradle --console=plain dU || exit 1 - read -p "Check Examples depencencies? [y/n] " cont - clear - case $cont in - [Nn] ) return ;; - * ) for ex in "${!examples[@]}" - do - runGradle $(echo "${examples[ex]}" | cut -d " " -f 1) dU - # runKobalt $(echo "${examples[ex]}" | cut -d " " -f 1) checkVersions - runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) versions:display-dependency-updates - if [ "$ex" -eq "${#examples}" ] - then - read -p "Continue? [y/n]: " cont - clear - case $cont in - * ) continue ;; - [Nn] ) return ;; - esac - fi - done ;; - esac + clear + echo -e "${cyan}Checking depencencies...${std}" + gradle --console=plain dU || exit 1 + read -p "Check Examples depencencies? [y/n] " cont + clear + case $cont in + [Nn]) return ;; + *) for ex in "${!examples[@]}"; do + runGradle $(echo "${examples[ex]}" | cut -d " " -f 1) dU + # runKobalt $(echo "${examples[ex]}" | cut -d " " -f 1) checkVersions + runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) versions:display-dependency-updates + if [ "$ex" -eq "${#examples}" ]; then + read -p "Continue? [y/n]: " cont + clear + case $cont in + *) continue ;; + [Nn]) return ;; + esac + fi + done ;; + esac } gradleCheck() { - clear - echo -e "${cyan}Checking Gradle build....${std}" - gradle $gradle_opts clean check $gradle_doc $gradle_sonar || exit 1 - pause + clear + echo -e "${cyan}Checking Gradle build....${std}" + gradle $gradle_opts clean check $gradle_doc $gradle_sonar || exit 1 + pause } runExamples() { - for ex in "${!examples[@]}" - do - runGradle ${examples[ex]} clean $gradle_opts - # runKobalt ${examples[ex]} clean - runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) clean $maven_args - done + for ex in "${!examples[@]}"; do + runGradle ${examples[ex]} clean $gradle_opts + # runKobalt ${examples[ex]} clean + runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) clean $maven_args + done } examplesMenu() { - clear - echo -e "${cyan}Examples${std}" - for ex in "${!examples[@]}" - do - printf ' %d. %s\n' $(($ex + 1)) $(echo "${examples[ex]}" | cut -d " " -f 1) - done - echo " $((${#examples[@]} + 1)). Run All Examples" - read -p "Enter choice [1-${#examples[@]}]: " choice - clear - case $choice in - [0-9] ) if [ "$choice" -gt "${#examples[@]}" ] - then - runExamples - examplesMenu - else - runGradle ${examples[$(($choice - 1))]} - # runKobalt ${examples[$(($choice - 1))]} - runMaven $(echo "${examples[$(($choice - 1))]}" | cut -d " " -f 1) $maven_args - examplesMenu - fi ;; - * ) return ;; - esac + clear + echo -e "${cyan}Examples${std}" + for ex in "${!examples[@]}"; do + printf ' %d. %s\n' $(($ex + 1)) $(echo "${examples[ex]}" | cut -d " " -f 1) + done + echo " $((${#examples[@]} + 1)). Run All Examples" + read -p "Enter choice [1-${#examples[@]}]: " choice + clear + case $choice in + [0-9]) if [ "$choice" -gt "${#examples[@]}" ]; then + runExamples + examplesMenu + else + runGradle ${examples[$(($choice - 1))]} + # runKobalt ${examples[$(($choice - 1))]} + runMaven $(echo "${examples[$(($choice - 1))]}" | cut -d " " -f 1) $maven_args + examplesMenu + fi ;; + *) return ;; + esac } validateCopyrights() { - clear - echo -e "${cyan}Validating copyrights...${std}" - for f in "LICENSE.txt" ${src}/*${ext} ${test}/*${ext} - do - if [ -f "$f" ] - then - checkCopyright "$f" - fi - done - pause + clear + echo -e "${cyan}Validating copyrights...${std}" + for f in "LICENSE.txt" ${src}/*${ext} ${test}/*${ext}; do + if [ -f "$f" ]; then + checkCopyright "$f" + fi + done + pause } everything() { - updateWrappers - checkDeps - gradleCheck - runExamples - validateCopyrights + updateWrappers + checkDeps + gradleCheck + runExamples + validateCopyrights } showMenu() { - clear - echo "${cyan}Preflight Check${std}" - echo " 1. Update Wrappers" - echo " 2. Check Dependencies" - echo " 3. Check Gradle Build" - echo " 4. Run Examples" - echo " 5. Validate Copyrights" - echo " 6. Check Everything" + clear + echo "${cyan}Preflight Check${std}" + echo " 1. Update Wrappers" + echo " 2. Check Dependencies" + echo " 3. Check Gradle Build" + echo " 4. Run Examples" + echo " 5. Validate Copyrights" + echo " 6. Check Everything" } readOptions() { - local choice - read -p "Enter choice [1-6]: " choice - case $choice in - 1) updateWrappers ;; - 2) checkDeps ;; - 3) gradleCheck ;; - 4) examplesMenu ;; - 5) validateCopyrights ;; - 6) everything ;; - *) exit 0 ;; - esac + local choice + read -p "Enter choice [1-6]: " choice + case $choice in + 1) updateWrappers ;; + 2) checkDeps ;; + 3) gradleCheck ;; + 4) examplesMenu ;; + 5) validateCopyrights ;; + 6) everything ;; + *) exit 0 ;; + esac } -while true -do - showMenu - readOptions +while true; do + showMenu + readOptions done diff --git a/src/main/java/net/thauvin/erik/semver/Constants.java b/src/main/java/net/thauvin/erik/semver/Constants.java index 51248e7..70a0ca7 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, 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 fa0f500..e6ec6c1 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, 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 270f5e7..95b12b1 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, 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 49cba2c..bfc2b89 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ public class VersionProcessor extends AbstractProcessor { log(Diagnostic.Kind.ERROR, t != null ? t.toString() : s); } - @SuppressFBWarnings({"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"}) + @SuppressFBWarnings({"PATH_TRAVERSAL_IN"}) private VersionInfo findValues(final Version version) throws IOException { final VersionInfo versionInfo = new VersionInfo(version); diff --git a/src/main/java/net/thauvin/erik/semver/package.html b/src/main/java/net/thauvin/erik/semver/package.html index 1b1b126..e37a084 100644 --- a/src/main/java/net/thauvin/erik/semver/package.html +++ b/src/main/java/net/thauvin/erik/semver/package.html @@ -1,3 +1,35 @@ + + diff --git a/src/test/java/net/thauvin/erik/semver/ConstantsTest.java b/src/test/java/net/thauvin/erik/semver/ConstantsTest.java index c5a9a34..eb7fabf 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, 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 30572e2..5de7828 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, 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/VersionProcessorTest.java b/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java index 3f8ebe0..8e2315d 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,6 +53,7 @@ public class VersionProcessorTest { private final Version version = new VersionTest(); @SuppressFBWarnings("RFI_SET_ACCESSIBLE") + @SuppressWarnings("PMD.AvoidAccessibilityAlteration") @Test public void testFindValues() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { final Method method = processor.getClass().getDeclaredMethod("findValues", Version.class); @@ -64,6 +65,7 @@ public class VersionProcessorTest { } @SuppressFBWarnings("RFI_SET_ACCESSIBLE") + @SuppressWarnings("PMD.AvoidAccessibilityAlteration") @Test public void testParseIntProperty() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { final Properties p = new Properties(); diff --git a/src/test/java/net/thauvin/erik/semver/VersionTest.java b/src/test/java/net/thauvin/erik/semver/VersionTest.java index ed47982..ea311ac 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-2021, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2016-2022, 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"}) +@SuppressWarnings({"ClassExplicitlyAnnotation", "SameReturnValue", "java:S2187"}) class VersionTest implements Version { @Override public Class annotationType() { diff --git a/updatewrappers.sh b/updatewrappers.sh index 000f0b6..b841e09 100755 --- a/updatewrappers.sh +++ b/updatewrappers.sh @@ -6,9 +6,9 @@ # set the examples directories declare -a dirs=( - "${PWD##*/}" - "examples/java" - "examples/kotlin") + "${PWD##*/}" + "examples/java" + "examples/kotlin") java8=true ### @@ -27,34 +27,34 @@ std=$(tput sgr0) #kVer=$(kobaltw --version | awk '{print substr($2, 1, length($2)-1)}') updateWrappers() { - curVer="$(gradle --version | awk '/Gradle/ {print $2}')" - if [ -d gradle ]; then - if [ "$curVer" != "$(./gradlew --version | awk '/Gradle/ {print $2}')" ]; then - gradle -q --console=plain wrapper - echo -e " $(./gradlew --version | awk '/Gradle/') ${green}UPDATED${std}" - else - echo -e " Gradle $curVer UP-TO-DATE" - fi + curVer="$(gradle --version | awk '/Gradle/ {print $2}')" + if [ -d gradle ]; then + if [ "$curVer" != "$(./gradlew --version | awk '/Gradle/ {print $2}')" ]; then + gradle -q --console=plain wrapper + echo -e " $(./gradlew --version | awk '/Gradle/') ${green}UPDATED${std}" + else + echo -e " Gradle $curVer UP-TO-DATE" fi -# if [ -d kobalt ]; then -# kw=$(cut -d "=" -f 2 kobalt/wrapper/kobalt-wrapper.properties) -# if [ "$kw" = "$kVer" ] -# then -# echo -e " Kobalt $kw UP-TO-DATE" -# else -# echo -e "kobalt.version=$kVer" > kobalt/wrapper/kobalt-wrapper.properties -# echo -e " Kobalt $kVer ${green}UPDATED${std}" -# fi -# fi + fi + # if [ -d kobalt ]; then + # kw=$(cut -d "=" -f 2 kobalt/wrapper/kobalt-wrapper.properties) + # if [ "$kw" = "$kVer" ] + # then + # echo -e " Kobalt $kw UP-TO-DATE" + # else + # echo -e "kobalt.version=$kVer" > kobalt/wrapper/kobalt-wrapper.properties + # echo -e " Kobalt $kVer ${green}UPDATED${std}" + # fi + # fi } echo -e "Updating wrappers..." for d in "${!dirs[@]}"; do - if [ "$d" -ne 0 ]; then - cd "${dirs[d]}" || exit 1 - fi - echo -e " ${cyan}${dirs[d]}${std}" - updateWrappers - cd "$pwd" + if [ "$d" -ne 0 ]; then + cd "${dirs[d]}" || exit 1 + fi + echo -e " ${cyan}${dirs[d]}${std}" + updateWrappers + cd "$pwd" done