diff --git a/.circleci/config.yml b/.circleci/config.yml
index fcc81ca..6c0190e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,54 +1,45 @@
version: 2
defaults: &defaults
working_directory: ~/repo
+ docker:
+ - image: circleci/openjdk:8-jdk
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
CI: true
-defaults_gradle: &defaults_gradle
- steps:
- - checkout
- - restore_cache:
- keys:
+jobs:
+ build_gradle:
+ <<: *defaults
+
+ 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 --stacktrace
- - store_artifacts:
- path: build/reports/
- destination: reports
- - store_test_results:
- path: build/reports/
-jobs:
- build_gradle_jdk17:
- <<: *defaults
+ - run:
+ name: Gradle Dependencies
+ command: ./gradlew dependencies
- docker:
- - image: cimg/openjdk:17.0
+ - save_cache:
+ paths: ~/.gradle
+ key: gradle-dependencies-{{ checksum "build.gradle.kts" }}
- <<: *defaults_gradle
+ - run:
+ name: Run All Checks
+ command: ./gradlew check --scan
- build_gradle_jdk21:
- <<: *defaults
-
- docker:
- - image: cimg/openjdk:21.0
-
- <<: *defaults_gradle
+ - store_artifacts:
+ path: build/reports/
+ destination: reports
+ - store_test_results:
+ path: build/reports/
workflows:
version: 2
- gradle:
+ build_gradle:
jobs:
- - build_gradle_jdk21
- - build_gradle_jdk17
+ - build_gradle
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 71d4858..f1ac387 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -1,46 +1,19 @@
-name: gradle-ci
+name: Java CI with Gradle
on: [push, pull_request, workflow_dispatch]
jobs:
build:
+
runs-on: ubuntu-latest
- env:
- GRADLE_OPTS: "-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m"
-
- strategy:
- matrix:
- java-version: [17, 21, 24]
-
steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Set up JDK ${{ matrix.java-version }}
- uses: actions/setup-java@v4
- with:
- distribution: "zulu"
- java-version: ${{ matrix.java-version }}
-
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
-
- - name: Cache Gradle packages
- uses: actions/cache@v4
- 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
-
- - name: Cleanup Gradle Cache
- run: |
- rm -f ~/.gradle/caches/modules-2/modules-2.lock
- rm -f ~/.gradle/caches/modules-2/gc.properties
+ - uses: actions/checkout@v2
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v1
+ with:
+ java-version: 1.8
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+ - name: Test with Gradle
+ run: ./gradlew check
diff --git a/.gitignore b/.gitignore
index 0742f86..f007981 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,12 @@
+.vscode/*
!.vscode/extensions.json
!.vscode/launch.json
!.vscode/settings.json
!.vscode/tasks.json
-*.class
-*.code-workspace
-*.ctxt
-*.iws
-*.log
-*.nar
-*.rar
-*.sublime-*
-*.tar.gz
-*.zip
-.DS_Store
+
+__pycache__
.classpath
+.DS_Store
.gradle
.history
.kobalt
@@ -24,9 +17,17 @@
.project
.scannerwork
.settings
-.vscode/*
-/**/.idea/$CACHE_FILE$
-/**/.idea/$PRODUCT_WORKSPACE_FILE$
+*.class
+*.code-workspace
+*.ctxt
+*.iws
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.zip
+/**/.idea_modules/
/**/.idea/**/caches/build_file_checksums.ser
/**/.idea/**/contentModel.xml
/**/.idea/**/dataSources.ids
@@ -47,10 +48,8 @@
/**/.idea/**/uiDesigner.xml
/**/.idea/**/usage.statistics.xml
/**/.idea/**/workspace.xml
-/**/.idea/sonarlint*
-/**/.idea_modules/
-Thumbs.db
-__pycache__
+/**/.idea/$CACHE_FILE$
+/**/.idea/$PRODUCT_WORKSPACE_FILE$
atlassian-ide-plugin.xml
bin/
build/
@@ -64,6 +63,7 @@ dist/
ehthumbs.db
fabric.properties
gen/
+gradle.properties
hs_err_pid*
kobaltBuild
kobaltw*-test
@@ -71,7 +71,6 @@ lib/kotlin*
libs/
local.properties
out/
-pom.xml.asc
pom.xml.next
pom.xml.releaseBackup
pom.xml.tag
@@ -81,4 +80,5 @@ project.properties
release.properties
target/
test-output
+Thumbs.db
venv
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e73cce4..26820aa 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: gradle:8-jdk17
+image: gradle:alpine
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
@@ -12,7 +12,7 @@ stages:
build:
stage: build
- script: gradle --build-cache assemble
+ script: ./gradlew --build-cache assemble
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
@@ -22,7 +22,7 @@ build:
test:
stage: test
- script: gradle check --stacktrace
+ script: ./gradlew check
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index eb0e453..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-semver-gradle
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 3ad4dc5..0000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 79ee123..d91f848 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index b589d56..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 56b596e..98b5537 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -26,20 +26,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
deleted file mode 100644
index c224ad5..0000000
--- a/.idea/kotlinc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml
deleted file mode 100644
index 9fa3156..0000000
--- a/.idea/libraries-with-intellij-classes.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 270f8ab..692822a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -2,7 +2,10 @@
-
+
+
+
+
@@ -10,10 +13,7 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..4c5218b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/semver-gradle.iml b/.idea/semver-gradle.iml
deleted file mode 100644
index d6ebd48..0000000
--- a/.idea/semver-gradle.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4a40469
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,30 @@
+language: java
+dist: trusty
+
+jdk:
+ - oraclejdk8
+
+addons:
+ sonarcloud:
+ organization: "ethauvin-github"
+
+before_cache:
+ - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
+ - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
+
+before_install:
+ - chmod +x gradlew
+
+script:
+ - ./gradlew check --scan
+
+cache:
+ directories:
+ - $HOME/.gradle/caches/
+ - $HOME/.gradle/wrapper/
+
+after_success:
+ - |
+ if [ "${TRAVIS_TEST_RESULT}" == 0 ]; then
+ ./gradlew sonarqube
+ fi
diff --git a/LICENSE.txt b/LICENSE.TXT
similarity index 96%
rename from LICENSE.txt
rename to LICENSE.TXT
index b242f58..7345551 100644
--- a/LICENSE.txt
+++ b/LICENSE.TXT
@@ -1,4 +1,4 @@
-Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2018-2020, 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 e5d5256..681d9b4 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/semver-gradle/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/semver-gradle/tree/master) [](https://plugins.gradle.org/plugin/net.thauvin.erik.gradle.semver)
+[](http://opensource.org/licenses/BSD-3-Clause) [](https://sonarcloud.io/dashboard?id=ethauvin_semver-gradle) [](https://travis-ci.com/ethauvin/semver-gradle) [](https://circleci.com/gh/ethauvin/semver-gradle/tree/master) [](https://plugins.gradle.org/plugin/net.thauvin.erik.gradle.semver)
# Semantic Version Plugin for Gradle
@@ -49,7 +49,7 @@ or in your `gradle.build` file:
```gradle
someTask {
- dependsOn incrementPatch
+ dependsOn(incrementPatch)
...
}
```
@@ -178,7 +178,7 @@ But, for example, if you wanted to save the version properties in a different fi
```gradle
semver {
- properties = 'my.version' // read and save properties in "my.version"
+ properties = "my.version" // read and save properties in "my.version"
}
```
@@ -186,13 +186,13 @@ or using different property keys for the version data:
```gradle
semver {
- keysPrefix = '' // no prefix
- semverKey = 'version'
- majorKey = 'maj'
- minorKey = 'min'
- patchKey = 'build'
- preReleaseKey = 'rel'
- buildMetaKey = 'meta'
+ keysPrefix = "" // no prefix
+ semverKey = "version"
+ majorKey = "maj"
+ minorKey = "min"
+ patchKey = "build"
+ preReleaseKey = "rel"
+ buildMetaKey = "meta"
}
```
which would match the data in `my.version`:
@@ -227,8 +227,8 @@ In order to quickly support multiple projects. The `keysPrefix` property is avai
```gradle
semver {
- properties = 'test.properties'
- keysPrefix = 'test.'
+ properties = "test.properties"
+ keysPrefix = "test."
}
```
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
index 265759f..7d98402 100644
--- a/bitbucket-pipelines.yml
+++ b/bitbucket-pipelines.yml
@@ -1,4 +1,4 @@
-image: maven:3-openjdk-21
+image: openjdk:8
pipelines:
default:
@@ -6,4 +6,4 @@ pipelines:
caches:
- gradle
script:
- - bash ./gradlew check --stacktrace
+ - bash ./gradlew check
diff --git a/build.gradle.kts b/build.gradle.kts
index b519e59..5d51035 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,86 +1,102 @@
-import io.gitlab.arturbosch.detekt.Detekt
-import org.gradle.api.tasks.testing.logging.TestExceptionFormat
-import org.gradle.api.tasks.testing.logging.TestLogEvent
-import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
- id("com.github.ben-manes.versions") version "0.52.0"
- id("com.gradle.plugin-publish") version "1.3.1"
- id("io.gitlab.arturbosch.detekt") version "1.23.8"
- id("java-gradle-plugin")
- id("java")
- id("maven-publish")
- id("org.gradle.kotlin.kotlin-dsl") version "5.2.0"
- kotlin("jvm") version "2.0.21"
+ `java-gradle-plugin`
+ `maven-publish`
+ jacoco
+ kotlin("jvm") version "1.3.72"
+ id("com.github.ben-manes.versions") version "0.36.0"
+ id("com.gradle.plugin-publish") version "0.12.0"
+ id("io.gitlab.arturbosch.detekt") version "1.14.2"
+ id("org.gradle.kotlin.kotlin-dsl") version "1.3.6"
+ id("org.sonarqube") version "3.0"
}
-version = "1.0.5-SNAPSHOT"
+version = "1.0.5-beta"
group = "net.thauvin.erik.gradle"
+object VersionInfo {
+ const val spek = "2.0.13"
+}
+val versions: VersionInfo by extra { VersionInfo }
+
val github = "https://github.com/ethauvin/semver-gradle"
val packageName = "net.thauvin.erik.gradle.semver"
repositories {
- mavenCentral()
- maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
+ jcenter()
}
dependencies {
implementation(gradleApi())
- implementation(platform(kotlin("bom")))
+ implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation(kotlin("stdlib"))
-
- // testImplementation(gradleTestKit())
-
+ testImplementation(kotlin("reflect"))
testImplementation(kotlin("test"))
- testImplementation(kotlin("test-junit"))
-}
-java {
- sourceCompatibility = JavaVersion.VERSION_17
- targetCompatibility = JavaVersion.VERSION_17
-}
+ testImplementation(gradleTestKit())
-kotlin {
- compilerOptions {
- jvmTarget.set(JvmTarget.JVM_17)
- languageVersion.set(KotlinVersion.KOTLIN_2_2)
- }
+ testImplementation("org.spekframework.spek2:spek-dsl-jvm:${versions.spek}")
+ testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:${versions.spek}")
}
tasks {
+ withType {
+ kotlinOptions.jvmTarget = "1.8"
+ // Gradle 4.6
+ kotlinOptions.apiVersion = "1.2"
+ }
+
withType {
- testLogging {
- exceptionFormat = TestExceptionFormat.FULL
- events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
+ useJUnitPlatform {
+ includeEngines("spek2")
}
}
+
+ withType {
+ reports {
+ html.isEnabled = true
+ xml.isEnabled = true
+ }
+ }
+
+ "sonarqube" {
+ dependsOn("jacocoTestReport")
+ }
}
detekt {
- toolVersion = "main-SNAPSHOT"
+ // input = files("src/main/kotlin", "src/test/kotlin")
+ // filters = ".*/resources/.*,.*/build/.*"
baseline = project.rootDir.resolve("detekt-baseline.xml")
}
-tasks.withType().configureEach {
- if (JavaVersion.current() >= JavaVersion.VERSION_24) {
- jvmTarget = "23"
+sonarqube {
+ properties {
+ property("sonar.projectName", "semver-gradle")
+ property("sonar.projectKey", "ethauvin_semver-gradle")
+ property("sonar.sourceEncoding", "UTF-8")
}
}
gradlePlugin {
- website.set(github)
- vcsUrl.set(github)
-
plugins {
create(project.name) {
id = packageName
displayName = "SemVer Plugin"
description = "Semantic Version Plugin for Gradle"
- tags.set(listOf("semver", "semantic", "version", "versioning", "auto-increment", "kotlin", "java"))
implementationClass = "$packageName.SemverPlugin"
}
}
}
+
+pluginBundle {
+ website = github
+ vcsUrl = github
+ tags = listOf("semver", "semantic", "version", "versioning", "auto-increment", "kotlin", "java")
+ mavenCoordinates {
+ groupId = project.group.toString()
+ artifactId = project.name
+ }
+}
diff --git a/detekt-baseline.xml b/detekt-baseline.xml
index 4de5a80..52cc674 100644
--- a/detekt-baseline.xml
+++ b/detekt-baseline.xml
@@ -1,12 +1,12 @@
-
+
- MagicNumber:utils.kt:3
- MagicNumber:utils.kt:4
- MagicNumber:utils.kt:5
- NestedBlockDepth:utils.kt:fun File.loadProperties(): Properties
- NestedBlockDepth:utils.kt:fun parseSemVer(input: String?, version: Version): Boolean
- NestedBlockDepth:utils.kt:fun saveProperties(projectDir: File, config: SemverConfig, version: Version)
+ MagicNumber:Utils.kt$Utils$3
+ MagicNumber:Utils.kt$Utils$4
+ MagicNumber:Utils.kt$Utils$5
+ NestedBlockDepth:Utils.kt$Utils$fun loadProperties(file: File): Properties
+ NestedBlockDepth:Utils.kt$Utils$fun parseSemVer(input: String?, version: Version): Boolean
+ NestedBlockDepth:Utils.kt$Utils$fun saveProperties(projectDir: File, config: SemverConfig, version: Version)
diff --git a/examples/annotation-processor/java/build.gradle b/examples/annotation-processor/java/build.gradle
index 9e30dc2..b343869 100644
--- a/examples/annotation-processor/java/build.gradle
+++ b/examples/annotation-processor/java/build.gradle
@@ -2,7 +2,7 @@ plugins {
id 'java'
id 'application'
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
- id 'com.github.ben-manes.versions' version '0.52.0'
+ id 'com.github.ben-manes.versions' version '0.28.0'
}
// ./gradlew
@@ -10,9 +10,11 @@ plugins {
// ./gradlew clean incrementMinor run
// ./gradlew clean incrementMajor run
+mainClassName = 'com.example.Example'
+
defaultTasks 'run'
-def semverProcessor = 'net.thauvin.erik:semver:1.2.1'
+def semverProcessor = "net.thauvin.erik:semver:1.2.0"
dependencies {
annotationProcessor semverProcessor
@@ -20,17 +22,13 @@ dependencies {
}
tasks.withType(JavaCompile) {
- options.generatedSourceOutputDirectory = file("${projectDir}/src/generated/java")
+ options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
}
repositories {
mavenLocal()
- mavenCentral()
-}
-
-application {
- mainClass = 'com.example.Example'
+ jcenter()
}
run {
@@ -43,8 +41,8 @@ run {
}
semver {
-// properties = 'example.properties'
-// keysPrefix = 'example.'
-// preReleaseKey = 'release'
-// buildMetaKey = 'meta'
+// properties = "example.properties"
+// keysPrefix = "example."
+// preReleaseKey = "release"
+// buildMetaKey = "meta"
}
diff --git a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..f3d88b1 100644
Binary files a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar and b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties
index ca025c8..a2bf131 100644
--- a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/annotation-processor/java/gradlew b/examples/annotation-processor/java/gradlew
index 23d15a9..2fe81a7 100755
--- a/examples/annotation-processor/java/gradlew
+++ b/examples/annotation-processor/java/gradlew
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,115 +15,80 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
-#
-# 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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
+##
+## Gradle start up script for UN*X
+##
##############################################################################
# Attempt to set APP_HOME
-
# Resolve links: $0 may be a link
-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
+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
done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-CLASSPATH="\\\"\\\""
-
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
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
@@ -132,120 +97,87 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD=java
- 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.
+ 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
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=SC2039,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=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
+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
-# 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.
+# 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" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
- 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
+ # 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" ;;
+ esac
fi
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
-# 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 optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# 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.
-#
-# 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' ' '
- )" '"$@"'
+# 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"
exec "$JAVACMD" "$@"
diff --git a/examples/annotation-processor/java/gradlew.bat b/examples/annotation-processor/java/gradlew.bat
index db3a6ac..62bd9b9 100644
--- a/examples/annotation-processor/java/gradlew.bat
+++ b/examples/annotation-processor/java/gradlew.bat
@@ -13,10 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -57,36 +54,48 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto execute
+if exist "%JAVA_EXE%" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
:execute
@rem Setup the command line
-set CLASSPATH=
-
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java b/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java
index 6ed2e78..5010897 100644
--- a/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java
+++ b/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java
@@ -1,34 +1,34 @@
/*
-* This file is automatically generated.
-* Do not modify! -- ALL CHANGES WILL BE ERASED!
-*/
-
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
package com.example;
import java.util.Date;
/**
-* Provides semantic version information.
-*
-* @author Semantic Version Annotation Processor
-*/
+ * Provides semantic version information.
+ *
+ * @author Semantic Version Annotation Processor
+ */
public final class GeneratedVersion {
-public static final String PROJECT = "Java Example";
-public static final Date BUILDDATE = new Date(1745642618838L);
-public static final int MAJOR = 2;
-public static final int MINOR = 13;
-public static final int PATCH = 0;
-public static final String PRERELEASE = "";
-public static final String PRERELEASE_PREFIX = "-";
-public static final String BUILDMETA = "";
-public static final String BUILDMETA_PREFIX = "+";
-public static final String SEPARATOR = ".";
-public static final String VERSION = "2.13.0";
+ public static final String PROJECT = "Java Example";
+ public static final Date BUILDDATE = new Date(1564027571537L);
+ public static final int MAJOR = 2;
+ public static final int MINOR = 10;
+ public static final int PATCH = 0;
+ public static final String PRERELEASE = "";
+ public static final String PRERELEASE_PREFIX = "-";
+ public static final String BUILDMETA = "";
+ public static final String BUILDMETA_PREFIX = "+";
+ public static final String SEPARATOR = ".";
+ public static final String VERSION = "2.10.0";
-/**
-* Disables the default constructor.
-*/
-private GeneratedVersion() {
-throw new UnsupportedOperationException("Illegal constructor call.");
-}
+ /**
+ * Disables the default constructor.
+ */
+ private GeneratedVersion() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
}
diff --git a/examples/annotation-processor/java/version.properties b/examples/annotation-processor/java/version.properties
index df2238d..fc54733 100644
--- a/examples/annotation-processor/java/version.properties
+++ b/examples/annotation-processor/java/version.properties
@@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Sun Feb 11 19:56:02 PST 2024
+#Wed Jul 24 21:06:09 PDT 2019
version.buildmeta=
version.major=2
-version.minor=13
+version.minor=10
version.patch=0
version.prerelease=
version.project=Java Example
-version.semver=2.13.0
+version.semver=2.10.0
diff --git a/examples/annotation-processor/kotlin/build.gradle.kts b/examples/annotation-processor/kotlin/build.gradle.kts
index e947b8a..78cd80b 100644
--- a/examples/annotation-processor/kotlin/build.gradle.kts
+++ b/examples/annotation-processor/kotlin/build.gradle.kts
@@ -1,9 +1,9 @@
plugins {
- id("application")
- id("com.github.ben-manes.versions") version "0.52.0"
- id("net.thauvin.erik.gradle.semver") version "1.0.4"
- kotlin("jvm") version "2.1.20"
- kotlin("kapt") version "1.9.25"
+ kotlin("jvm").version("1.3.61")
+ application
+ id("org.jetbrains.kotlin.kapt").version("1.3.61")
+ id("net.thauvin.erik.gradle.semver").version("1.0.4")
+ id("com.github.ben-manes.versions").version("0.28.0")
}
// ./gradlew
@@ -13,7 +13,7 @@ plugins {
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
-var semverProcessor = "net.thauvin.erik:semver:1.2.1"
+var semverProcessor = "net.thauvin.erik:semver:1.2.0"
dependencies {
kapt(semverProcessor)
@@ -24,22 +24,16 @@ dependencies {
repositories {
mavenLocal()
- mavenCentral()
-}
-
-java {
- toolchain {
- languageVersion.set(JavaLanguageVersion.of(17))
- }
+ jcenter()
}
application {
- mainClass.set("com.example.Main")
+ mainClassName = "com.example.Main"
}
kapt {
arguments {
- arg("semver.project.dir", projectDir.absolutePath)
+ arg("semver.project.dir", projectDir)
}
}
diff --git a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..f3d88b1 100644
Binary files a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar and b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties
index ca025c8..a2bf131 100644
--- a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/annotation-processor/kotlin/gradlew b/examples/annotation-processor/kotlin/gradlew
index 23d15a9..2fe81a7 100755
--- a/examples/annotation-processor/kotlin/gradlew
+++ b/examples/annotation-processor/kotlin/gradlew
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,115 +15,80 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
-#
-# 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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
+##
+## Gradle start up script for UN*X
+##
##############################################################################
# Attempt to set APP_HOME
-
# Resolve links: $0 may be a link
-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
+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
done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-CLASSPATH="\\\"\\\""
-
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
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
@@ -132,120 +97,87 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD=java
- 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.
+ 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
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=SC2039,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=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
+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
-# 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.
+# 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" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
- 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
+ # 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" ;;
+ esac
fi
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
-# 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 optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# 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.
-#
-# 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' ' '
- )" '"$@"'
+# 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"
exec "$JAVACMD" "$@"
diff --git a/examples/annotation-processor/kotlin/gradlew.bat b/examples/annotation-processor/kotlin/gradlew.bat
index db3a6ac..62bd9b9 100644
--- a/examples/annotation-processor/kotlin/gradlew.bat
+++ b/examples/annotation-processor/kotlin/gradlew.bat
@@ -13,10 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -57,36 +54,48 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto execute
+if exist "%JAVA_EXE%" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
:execute
@rem Setup the command line
-set CLASSPATH=
-
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/examples/annotation-processor/kotlin/version.properties b/examples/annotation-processor/kotlin/version.properties
index 9380cb2..8da5e3a 100644
--- a/examples/annotation-processor/kotlin/version.properties
+++ b/examples/annotation-processor/kotlin/version.properties
@@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Sun Feb 11 19:56:22 PST 2024
+#Wed Jul 24 21:06:46 PDT 2019
version.buildmeta=
version.major=14
-version.minor=6
+version.minor=3
version.patch=0
version.prerelease=
version.project=Kotlin Example
-version.semver=14.6.0
+version.semver=14.3.0
diff --git a/examples/java/build.gradle b/examples/java/build.gradle
index a95e911..e841b08 100644
--- a/examples/java/build.gradle
+++ b/examples/java/build.gradle
@@ -2,7 +2,7 @@ plugins {
id 'java'
id 'application'
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
- id 'com.github.ben-manes.versions' version '0.52.0'
+ id 'com.github.ben-manes.versions' version '0.36.0'
}
// ./gradlew
@@ -12,34 +12,34 @@ plugins {
// ./gradlew incrementBuildMeta run
// ./gradlew echoVersion
+
defaultTasks 'run'
-
dependencies {
-
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
repositories {
- mavenCentral()
+ jcenter()
}
-testing {
- suites {
- test {
- useJUnitJupiter('5.12.2')
- }
- }
+test {
+ useJUnitPlatform()
}
application {
- mainClass = 'App'
-}
+ mainClassName = 'App'
+// project.afterEvaluate {
+// println "Version: $version"
+// }
+}
semver {
-// properties = 'example.properties'
-// keysPrefix = 'example.'
-// preReleaseKey = 'release'
-// buildMetaKey = 'meta'
+// properties = "example.properties"
+// keysPrefix = "example."
+// preReleaseKey = "release"
+// buildMetaKey = "meta"
}
incrementBuildMeta {
@@ -50,10 +50,8 @@ incrementBuildMeta {
}
run {
-// project.afterEvaluate {
-// println "Version: $version"
-// }
doFirst {
+// println "Version: ${-> version}"
println "Version: $version"
}
@@ -62,5 +60,5 @@ run {
}
task echoVersion(type:Exec) {
- commandLine('echo', "${-> project.version}")
+ commandLine 'echo', "${-> project.version}"
}
diff --git a/examples/java/gradle/wrapper/gradle-wrapper.jar b/examples/java/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..e708b1c 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 ca025c8..be52383 100644
--- a/examples/java/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/java/gradlew b/examples/java/gradlew
index 23d15a9..4f906e0 100755
--- a/examples/java/gradlew
+++ b/examples/java/gradlew
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,115 +15,81 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
-#
-# 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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
+##
+## Gradle start up script for UN*X
+##
##############################################################################
# Attempt to set APP_HOME
-
# Resolve links: $0 may be a link
-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
+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
done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-CLASSPATH="\\\"\\\""
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
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
@@ -132,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD=java
- 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.
+ 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
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=SC2039,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=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
+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
-# 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.
+# 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" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=$( cygpath --unix "$JAVACMD" )
+ 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
+ # 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" ;;
+ esac
fi
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
-# 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 optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# 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.
-#
-# 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' ' '
- )" '"$@"'
+# 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"
exec "$JAVACMD" "$@"
diff --git a/examples/java/gradlew.bat b/examples/java/gradlew.bat
index db3a6ac..107acd3 100644
--- a/examples/java/gradlew.bat
+++ b/examples/java/gradlew.bat
@@ -13,10 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -59,34 +56,32 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
-set CLASSPATH=
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/examples/java/version.properties b/examples/java/version.properties
index 5485951..f5bf6aa 100644
--- a/examples/java/version.properties
+++ b/examples/java/version.properties
@@ -1,8 +1,8 @@
#Generated by the Semver Plugin for Gradle
-#Sun Feb 11 19:55:34 PST 2024
-version.buildmeta=20240211195534
+#Fri Sep 25 17:38:33 PDT 2020
+version.buildmeta=20200925173833
version.major=1
version.minor=0
version.patch=0
version.prerelease=
-version.semver=1.0.0+20240211195534
+version.semver=1.0.0+20200925173833
diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts
index 514316b..d54e882 100644
--- a/examples/kotlin/build.gradle.kts
+++ b/examples/kotlin/build.gradle.kts
@@ -4,10 +4,10 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
plugins {
- id("application")
- id("com.github.ben-manes.versions") version "0.52.0"
- id("net.thauvin.erik.gradle.semver") version "1.0.4"
- kotlin("jvm") version "2.1.20"
+ kotlin("jvm").version("1.4.10")
+ application
+ id("net.thauvin.erik.gradle.semver").version("1.0.4")
+ id("com.github.ben-manes.versions").version("0.36.0")
}
// ./gradlew
@@ -20,21 +20,15 @@ defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
dependencies {
implementation(kotlin("stdlib"))
- testImplementation("org.testng:testng:7.11.0")
+ testImplementation("org.testng:testng:7.3.0")
}
repositories {
- mavenCentral()
-}
-
-java {
- toolchain {
- languageVersion.set(JavaLanguageVersion.of(17))
- }
+ jcenter()
}
application {
- mainClass.set("com.example.MainKt")
+ mainClassName = "com.example.MainKt"
// project.afterEvaluate {
// println("Version: $version")
// }
diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/kotlin/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..e708b1c 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 ca025c8..be52383 100644
--- a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/kotlin/gradlew b/examples/kotlin/gradlew
index 23d15a9..4f906e0 100755
--- a/examples/kotlin/gradlew
+++ b/examples/kotlin/gradlew
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,115 +15,81 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
-#
-# 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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
+##
+## Gradle start up script for UN*X
+##
##############################################################################
# Attempt to set APP_HOME
-
# Resolve links: $0 may be a link
-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
+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
done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-CLASSPATH="\\\"\\\""
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
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
@@ -132,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD=java
- 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.
+ 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
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=SC2039,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=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
+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
-# 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.
+# 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" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=$( cygpath --unix "$JAVACMD" )
+ 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
+ # 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" ;;
+ esac
fi
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
-# 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 optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# 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.
-#
-# 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' ' '
- )" '"$@"'
+# 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"
exec "$JAVACMD" "$@"
diff --git a/examples/kotlin/gradlew.bat b/examples/kotlin/gradlew.bat
index db3a6ac..107acd3 100644
--- a/examples/kotlin/gradlew.bat
+++ b/examples/kotlin/gradlew.bat
@@ -13,10 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -59,34 +56,32 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
-set CLASSPATH=
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/examples/kotlin/version.properties b/examples/kotlin/version.properties
index 4f963f9..98e937a 100644
--- a/examples/kotlin/version.properties
+++ b/examples/kotlin/version.properties
@@ -1,8 +1,8 @@
#Generated by the Semver Plugin for Gradle
-#Sun Feb 11 19:55:46 PST 2024
-version.buildmeta=20240211195546
+#Mon Nov 09 21:24:16 PST 2020
+version.buildmeta=20201109212416
version.major=1
version.minor=2
version.patch=4
version.prerelease=beta
-version.semver=1.2.4-beta+20240211195546
+version.semver=1.2.4-beta+20201109212416
diff --git a/examples/test/build.gradle b/examples/test/build.gradle
index de69c3f..9813e76 100644
--- a/examples/test/build.gradle
+++ b/examples/test/build.gradle
@@ -1,40 +1,39 @@
-plugins {
- id 'java'
- id 'application'
- id("net.thauvin.erik.gradle.semver")
+buildscript {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+ dependencies {
+ classpath "net.thauvin.erik.gradle:semver:1.0.5-beta"
+ }
}
-defaultTasks 'run'
+apply plugin: 'java'
+apply plugin: 'application'
+apply plugin: 'net.thauvin.erik.gradle.semver'
+mainClassName = 'App'
-application {
- mainClass = 'App'
-}
-
-// version = 1.0
+//version = 1.0
def f = new File("version.properties")
-def semverProcessor = 'net.thauvin.erik:semver:1.2.2-SNAPSHOT'
-
-repositories {
- mavenLocal()
- mavenCentral()
- maven {
- name = "SonatypeSnapshots"
- url = uri("https://oss.sonatype.org/content/repositories/snapshots")
- }
-}
+def semverProcessor = 'net.thauvin.erik:semver:1.2.0'
dependencies {
annotationProcessor semverProcessor
compileOnly semverProcessor
}
+repositories {
+ mavenLocal()
+ jcenter()
+}
+
application {
- println project.version
+ println(project.version)
project.afterEvaluate {
- println "afterEvaluate: $project.version"
+ println(project.version)
}
}
@@ -48,13 +47,13 @@ incrementBuildMeta {
run {
doFirst {
- println "$semver"
+ println("Version: $semver.major$semver.separator$semver.minor$semver.separator$semver.patch$semver.preReleasePrefix$semver.preRelease$semver.buildMetaPrefix$semver.buildMeta")
args = [f.name]
}
}
-tasks.register('echoVersion', Exec) {
- commandLine('echo', "${-> version}")
+task echoVersion(type:Exec) {
+ commandLine "echo", "${-> version}"
}
semver {
diff --git a/examples/test/gradle/wrapper/gradle-wrapper.jar b/examples/test/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..5c2d1cf 100644
Binary files a/examples/test/gradle/wrapper/gradle-wrapper.jar and b/examples/test/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/test/gradle/wrapper/gradle-wrapper.properties b/examples/test/gradle/wrapper/gradle-wrapper.properties
index ca025c8..4b7e1f3 100644
--- a/examples/test/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/test/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/test/gradlew b/examples/test/gradlew
index 23d15a9..8e25e6c 100755
--- a/examples/test/gradlew
+++ b/examples/test/gradlew
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,115 +15,80 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
-#
-# 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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
+##
+## Gradle start up script for UN*X
+##
##############################################################################
# Attempt to set APP_HOME
-
# Resolve links: $0 may be a link
-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
+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
done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-CLASSPATH="\\\"\\\""
-
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
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
@@ -132,120 +97,92 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD=java
- 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.
+ 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
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=SC2039,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=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
-fi
-
-# 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.
-
-# 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" )
+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
- # 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
+ 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, switch paths to Windows format before running java
+if $cygwin ; 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=$((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" ;;
+ esac
fi
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
-# 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, 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"
-# Collect all arguments for the java command:
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# Stop when "xargs" is not available.
-if ! command -v xargs >/dev/null 2>&1
-then
- die "xargs is not available"
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
fi
-# 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/gradlew.bat b/examples/test/gradlew.bat
index db3a6ac..9618d8d 100644
--- a/examples/test/gradlew.bat
+++ b/examples/test/gradlew.bat
@@ -13,10 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,14 +25,10 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -43,13 +37,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -57,36 +51,48 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto execute
+if exist "%JAVA_EXE%" goto init
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
:execute
@rem Setup the command line
-set CLASSPATH=
-
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 1b33c55..e708b1c 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 ca025c8..be52383 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 23d15a9..4f906e0 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,115 +15,81 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-License-Identifier: Apache-2.0
-#
##############################################################################
-#
-# 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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
+##
+## Gradle start up script for UN*X
+##
##############################################################################
# Attempt to set APP_HOME
-
# Resolve links: $0 may be a link
-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
+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
done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$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
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-CLASSPATH="\\\"\\\""
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
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
@@ -132,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD=java
- 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.
+ 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
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=SC2039,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=SC2039,SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
+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
-# 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.
+# 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" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=$( cygpath --unix "$JAVACMD" )
+ 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
+ # 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" ;;
+ esac
fi
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
-# 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 optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
- "$@"
-
-# 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.
-#
-# 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' ' '
- )" '"$@"'
+# 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"
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index db3a6ac..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,10 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
-@rem SPDX-License-Identifier: Apache-2.0
-@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -43,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
@@ -59,34 +56,32 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo. 1>&2
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
-echo. 1>&2
-echo Please set the JAVA_HOME variable in your environment to match the 1>&2
-echo location of your Java installation. 1>&2
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
-set CLASSPATH=
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="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!
-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%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/preflightcheck.sh b/preflightcheck.sh
old mode 100755
new mode 100644
index 1770f06..f95e229
--- a/preflightcheck.sh
+++ b/preflightcheck.sh
@@ -2,7 +2,7 @@
# set source and test locations
src="src/main/kotlin/net/thauvin/erik/gradle/semver/"
-test="src/test/kotlin/net/thauvin/erik/gradle/semver/"
+test="src/main/kotlin/net/thauvin/erik/gradle/semver/"
# e.g: .java, .kt, etc.
ext=".kt"
java8=true
@@ -15,14 +15,14 @@ declare -a examples=(
# e.g: empty or javadoc, etc.
gradle_doc=""
# e.g. empty or sonarqube
-gradle_sonar=""
+gradle_sonar="sonarqube"
# gradle options for examples
gradle_opts="--console=plain --no-build-cache --no-daemon"
# maven arguments for examples
maven_args="compile exec:java"
#
-# Version: 1.1.5
+# Version: 1.1.3
#
if [ "$java8" = true ]
@@ -42,7 +42,7 @@ pause() {
}
checkCopyright() {
- if [ "$(grep -c "$date" "$1")" == "0" ]
+ if [ "$(grep -c "$date" "$1")" -eq 0 ]
then
echo -e " Invalid: ${red}$f${std}"
else
@@ -106,7 +106,7 @@ checkDeps() {
* ) for ex in "${!examples[@]}"
do
runGradle $(echo "${examples[ex]}" | cut -d " " -f 1) dU
- # runKobalt $(echo "${examples[ex]}" | cut -d " " -f 1) checkVersions
+ 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
@@ -132,7 +132,7 @@ runExamples() {
for ex in "${!examples[@]}"
do
runGradle ${examples[ex]} clean $gradle_opts
- # runKobalt ${examples[ex]} clean
+ runKobalt ${examples[ex]} clean
runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) clean $maven_args
done
}
@@ -154,7 +154,7 @@ examplesMenu() {
examplesMenu
else
runGradle ${examples[$(($choice - 1))]}
- # runKobalt ${examples[$(($choice - 1))]}
+ runKobalt ${examples[$(($choice - 1))]}
runMaven $(echo "${examples[$(($choice - 1))]}" | cut -d " " -f 1) $maven_args
examplesMenu
fi ;;
@@ -165,12 +165,9 @@ examplesMenu() {
validateCopyrights() {
clear
echo -e "${cyan}Validating copyrights...${std}"
- for f in "LICENSE.txt" ${src}/*${ext} ${test}/*${ext}
+ for f in LICENSE.TXT ${src}/*${ext} ${test}/*${ext}
do
- if [ -f "$f" ]
- then
- checkCopyright "$f"
- fi
+ checkCopyright "$f"
done
pause
}
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 6b31d28..e9b895f 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,17 +1,16 @@
plugins {
- id("com.gradle.develocity") version "4.0.1"
+ id("com.gradle.enterprise").version("3.3.4")
}
-develocity {
+gradleEnterprise {
buildScan {
- link("GitHub", "https://github.com/ethauvin/semver/tree/master")
- if (!System.getenv("CI").isNullOrEmpty()) {
- uploadInBackground.set(false)
- publishing.onlyIf { true }
+ link("GitHub", "https://github.com/ethauvin/semver-gradle/tree/master")
+ if ("true" == System.getenv("CI")) {
+ publishOnFailure()
tag("CI")
}
- termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
- termsOfUseAgree.set("yes")
+ termsOfServiceUrl = "https://gradle.com/terms-of-service"
+ termsOfServiceAgree = "yes"
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt
index 6eb5bdc..06a8f7b 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt
@@ -1,7 +1,7 @@
/*
* SemverConfig.kt
*
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -97,14 +97,27 @@ open class SemverConfig @Inject constructor(
get() = semVersion.separator
override fun toString(): String {
- return "SemverConfig(semVersion=$semVersion, properties='$properties', semverKey='$semverKey'," +
- " majorKey='$majorKey', minorKey='$minorKey', patchKey='$patchKey', preReleaseKey='$preReleaseKey'," +
- " preReleasePrefixKey='$preReleasePrefixKey', buildMetaKey='$buildMetaKey'," +
- " buildMetaPrefixKey='$buildMetaPrefixKey', separatorKey='$separatorKey', keysPrefix='$keysPrefix'," +
- " semver='$semver', version='$version', major=$major, minor=$minor, patch=$patch," +
- " preRelease='$preRelease', buildMeta='$buildMeta', preReleasePrefix='$preReleasePrefix'," +
- " buildMetaPrefix='$buildMetaPrefix', separator='$separator')"
+ return "SemverConfig(" +
+ "properties='$properties', " +
+ "semverKey='$semverKey', " +
+ "majorKey='$majorKey', " +
+ "minorKey='$minorKey', " +
+ "patchKey='$patchKey', " +
+ "preReleaseKey='$preReleaseKey', " +
+ "preReleasePrefixKey='$preReleasePrefixKey', " +
+ "buildMetaKey='$buildMetaKey', " +
+ "buildMetaPrefixKey='$buildMetaPrefixKey', " +
+ "separator='$separatorKey', " +
+ "keysPrefix='$keysPrefix', " +
+ "semver='$semver', " +
+ "major='$major', " +
+ "minor='$minor', " +
+ "patch='$patch', " +
+ "preRelease='$preRelease', " +
+ "buildMeta='$buildMeta', " +
+ "preReleasePrefix='$preReleasePrefix', " +
+ "buildMetaPrefix='$buildMetaPrefix', " +
+ "separator='$separator'" +
+ ')'
}
-
-
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt
index 3dedd18..7463ba0 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt
@@ -1,7 +1,7 @@
/*
* SemverIncrementBuildMetaTask.kt
*
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -48,16 +48,18 @@ open class SemverIncrementBuildMetaTask @Inject constructor(
description = "Increments Build version metadata."
}
+ @Suppress("MemberVisibilityCanBePrivate")
@Input
var buildMeta: String = ""
+ @Suppress("unused")
@TaskAction
fun increment() {
if (version.buildMeta != buildMeta) {
version.buildMeta = buildMeta
project.version = version.semver
- if (logger.isLifecycleEnabled) logger.lifecycle("Version: ${project.version}")
- saveProperties(project.projectDir, config, version)
+ logger.lifecycle("Version: ${project.version}")
+ Utils.saveProperties(project.projectDir, config, version)
}
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt
index 35fc3b2..9e5af44 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt
@@ -1,7 +1,7 @@
/*
* SemverIncrementTask.kt
*
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,6 @@ package net.thauvin.erik.gradle.semver
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.TaskAction
-import java.util.Locale
import javax.inject.Inject
@CacheableTask
@@ -46,15 +45,10 @@ open class SemverIncrementTask @Inject constructor(
) : DefaultTask() {
init {
group = "version"
- description =
- "Increments ${
- type.replaceFirstChar {
- if (it.isLowerCase()) it.titlecase(Locale.getDefault())
- else it.toString()
- }
- } version number."
+ description = "Increments ${type.capitalize()} version number."
}
+ @Suppress("unused")
@TaskAction
fun increment() {
version.increment(
@@ -63,7 +57,7 @@ open class SemverIncrementTask @Inject constructor(
isPatch = type == SemverConfig.DEFAULT_PATCH_KEY
)
project.version = version.semver
- if (logger.isLifecycleEnabled) logger.lifecycle("Version: ${project.version}")
- saveProperties(project.projectDir, config, version)
+ logger.lifecycle("Version: ${project.version}")
+ Utils.saveProperties(project.projectDir, config, version)
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt
index 8a4445e..1e137e7 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt
@@ -1,7 +1,7 @@
/*
* SemverPlugin.kt
*
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,6 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.util.GradleVersion
-@Suppress("unused")
class SemverPlugin : Plugin {
private val simpleName = SemverPlugin::class.simpleName
private var version = Version()
@@ -51,17 +50,17 @@ class SemverPlugin : Plugin {
project.afterEvaluate(this::afterEvaluate)
project.tasks.apply {
- register("incrementMajor", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_MAJOR_KEY)
- register("incrementMinor", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_MINOR_KEY)
- register("incrementPatch", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_PATCH_KEY)
- register("incrementBuildMeta", SemverIncrementBuildMetaTask::class.java, config, version)
+ create("incrementMajor", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_MAJOR_KEY)
+ create("incrementMinor", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_MINOR_KEY)
+ create("incrementPatch", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_PATCH_KEY)
+ create("incrementBuildMeta", SemverIncrementBuildMetaTask::class.java, config, version)
}
}
private fun afterEvaluate(project: Project) {
- val propsFile = getPropertiesFile(project.projectDir, config.properties)
+ val propsFile = Utils.getPropertiesFile(project.projectDir, config.properties)
- if (project.version != "unspecified" && project.logger.isWarnEnabled) {
+ if (project.version != "unspecified") {
project.logger.warn(
"Please specify the version in ${propsFile.name} and remove it from ${project.buildFile.name}"
)
@@ -70,37 +69,31 @@ class SemverPlugin : Plugin {
propsFile.apply {
val isNew = !exists()
- if (project.logger.isInfoEnabled) {
- project.logger.info(
- "[$simpleName] Attempting to read properties from: `$absoluteFile`. " +
- "[exists: $isNew, isFile: $isFile, canRead: ${canRead()}]"
- )
- }
+ project.logger.info(
+ "[$simpleName] Attempting to read properties from: `$absoluteFile`. " +
+ "[exists: $isNew, isFile: $isFile, canRead: ${canRead()}]"
+ )
- val props = this.loadProperties()
+ val props = Utils.loadProperties(this)
val requiredProps = setOf(
config.semverKey, config.majorKey, config.minorKey, config.patchKey,
config.preReleaseKey, config.buildMetaKey
)
val hasReqProps = !isNew && props.stringPropertyNames().containsAll(requiredProps) &&
- requiredProps.isNotSystemProperty()
+ Utils.isNotSystemProperty(requiredProps)
- loadVersion(config, version, props)
+ Utils.loadVersion(config, version, props)
project.tasks.withType(SemverIncrementBuildMetaTask::class.java) {
buildMeta = version.buildMeta
}
project.version = version.semver
- if (project.logger.isInfoEnabled) {
- project.logger.info("[$simpleName] Project version set to: ${project.version}")
- }
+ project.logger.info("[$simpleName] Project version set to: ${project.version}")
if (!hasReqProps || !isFile) {
- if (project.logger.isInfoEnabled) {
- project.logger.info("[$simpleName] Saving version properties to `$absoluteFile`.")
- }
- saveProperties(project.projectDir, config, version)
+ project.logger.info("[$simpleName] Saving version properties to `$absoluteFile`.")
+ Utils.saveProperties(project.projectDir, config, version)
}
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt
index 9bd7990..1a99d15 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt
@@ -1,7 +1,7 @@
/*
* SortedProperties.kt
*
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,11 +38,11 @@ import java.util.Properties
internal class SortedProperties : Properties() {
override val entries: MutableSet>
- get() = super.entries.sortedWith { a, b -> a.toString().compareTo(b.toString()) }.toMutableSet()
+ get() = super.entries.sortedWith(Comparator { a, b -> a.toString().compareTo(b.toString()) }).toMutableSet()
override fun keys(): Enumeration {
val keys = Collections.list(super.keys())
- keys.sortWith { a, b -> a.toString().compareTo(b.toString()) }
+ keys.sortWith(Comparator { a, b -> a.toString().compareTo(b.toString()) })
return Collections.enumeration(keys)
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/Utils.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/Utils.kt
new file mode 100644
index 0000000..e7cd681
--- /dev/null
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/Utils.kt
@@ -0,0 +1,223 @@
+/*
+ * Utils.kt
+ *
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.thauvin.erik.gradle.semver
+
+import org.gradle.api.GradleException
+import java.io.File
+import java.io.FileInputStream
+import java.io.FileOutputStream
+import java.io.IOException
+import java.util.Properties
+
+/**
+ * The Utils
class.
+ *
+ * @author Erik C. Thauvin
+ * @created 2019-04-10
+ * @since 1.0
+ */
+object Utils {
+ fun File.canReadFile(): Boolean {
+ return canRead() && isFile
+ }
+
+ private fun Properties.put(key: String, value: String, isValidCondition: Boolean) {
+ if (isValidCondition) put(key, value)
+ }
+
+ fun isNotSystemProperty(keys: Set): Boolean {
+ keys.forEach {
+ if (System.getProperties().containsKey(it)) return false
+ }
+ return true
+ }
+
+ fun getPropertiesFile(projectDir: File, propsFile: String): File {
+ return if (File(propsFile).isAbsolute) {
+ File(propsFile)
+ } else {
+ File(projectDir, propsFile)
+ }
+ }
+
+ fun loadProperties(file: File): Properties {
+ var isNew = false
+ val props = Properties()
+ file.apply {
+ try {
+ if (!exists() && createNewFile()) {
+ isNew = true
+ }
+ } catch (e: IOException) {
+ throw GradleException("Unable to create: `$absoluteFile`", e)
+ }
+ if (canReadFile()) {
+ FileInputStream(this).reader().use { reader ->
+ props.apply {
+ if (!isNew) {
+ load(reader)
+ }
+ }
+ }
+ } else {
+ throw GradleException("Unable to read version from: `$absoluteFile`")
+ }
+ }
+ return props
+ }
+
+ fun loadIntProperty(props: Properties, key: String, default: Int): Int {
+ try {
+ return loadProperty(props, key, default.toString()).toInt()
+ } catch (e: java.lang.NumberFormatException) {
+ throw GradleException("Unable to parse $key property. (${e.message})", e)
+ }
+ }
+
+ fun loadProperty(props: Properties, key: String, default: String): String {
+ return System.getProperty(key, if (props.isNotEmpty()) props.getProperty(key, default) else default)
+ }
+
+ fun loadVersion(config: SemverConfig, version: Version, props: Properties) {
+ props.apply {
+ if (!parseSemVer(System.getProperty(config.semverKey), version)) {
+ version.major = loadIntProperty(this, config.majorKey, Version.DEFAULT_MAJOR)
+ version.minor = loadIntProperty(this, config.minorKey, Version.DEFAULT_MINOR)
+ version.patch = loadIntProperty(this, config.patchKey, Version.DEFAULT_PATCH)
+ version.preRelease = loadProperty(this, config.preReleaseKey, Version.DEFAULT_EMPTY)
+ version.buildMeta = loadProperty(this, config.buildMetaKey, Version.DEFAULT_EMPTY)
+ }
+
+ if (!isEmpty) {
+ version.preReleasePrefix =
+ getProperty(config.preReleasePrefixKey, Version.DEFAULT_PRERELEASE_PREFIX)
+ version.buildMetaPrefix =
+ getProperty(config.buildMetaPrefixKey, Version.DEFAULT_BUILDMETA_PREFIX)
+ version.separator = getProperty(config.separatorKey, Version.DEFAULT_SEPARATOR)
+ }
+ }
+ }
+
+ fun parseSemVer(input: String?, version: Version): Boolean {
+ if (input.isNullOrBlank()) return false
+
+ try {
+ val max = 5
+ val min = 3
+
+ val parts = input.split(
+ Regex("[\\Q${version.separator}${version.preReleasePrefix}${version.buildMetaPrefix}\\E]"),
+ max
+ )
+
+ if (parts.size >= min) {
+ version.major = parts[0].toInt()
+ version.minor = parts[1].toInt()
+ version.patch = parts[2].toInt()
+ version.preRelease = ""
+ version.buildMeta = ""
+
+ if (parts.size > min) {
+ when {
+ parts.size == max -> {
+ version.preRelease = parts[3]
+ version.buildMeta = parts[4]
+ }
+ parts.size == 4 -> {
+ if (input.endsWith(version.buildMetaPrefix + parts[3])) {
+ version.buildMeta = parts[3]
+ } else {
+ version.preRelease = parts[3]
+ }
+ }
+ }
+ }
+ } else {
+ throw NumberFormatException("Not enough parts.")
+ }
+ } catch (e: NumberFormatException) {
+ throw GradleException("Unable to parse version: \"$input\" (${e.message})", e)
+ }
+
+ return true
+ }
+
+ fun saveProperties(projectDir: File, config: SemverConfig, version: Version) {
+ val propsFile = getPropertiesFile(projectDir, config.properties)
+ SortedProperties().apply {
+ try {
+ propsFile.apply {
+ if (canReadFile()) {
+ FileInputStream(this).reader().use { load(it) }
+ } else {
+ createNewFile()
+ }
+
+ put(config.semverKey, version.semver)
+ put(config.majorKey, version.major.toString())
+ put(config.minorKey, version.minor.toString())
+ put(config.patchKey, version.patch.toString())
+ put(config.preReleaseKey, version.preRelease)
+ put(config.buildMetaKey, version.buildMeta)
+ put(config.semverKey, version.semver)
+
+ put(
+ config.buildMetaPrefixKey, version.buildMetaPrefix,
+ version.buildMetaPrefix != Version.DEFAULT_BUILDMETA_PREFIX ||
+ containsKey(config.buildMetaPrefixKey)
+ )
+ put(
+ config.preReleasePrefixKey, version.preReleasePrefix,
+ version.preReleasePrefix != Version.DEFAULT_PRERELEASE_PREFIX ||
+ containsKey(config.preReleasePrefixKey)
+ )
+ put(
+ config.separatorKey, version.separator,
+ version.separator != Version.DEFAULT_SEPARATOR ||
+ containsKey(config.separatorKey)
+ )
+
+ if (canWrite()) {
+ FileOutputStream(this).writer().use {
+ store(it, "Generated by the Semver Plugin for Gradle")
+ }
+ } else {
+ throw IOException("Can't write.")
+ }
+ }
+ } catch (e: IOException) {
+ throw GradleException("Unable to write version to: `${propsFile.absoluteFile}`", e)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt
index 5752b85..eedbf38 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt
@@ -1,7 +1,7 @@
/*
* Version.kt
*
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -54,8 +54,8 @@ class Version {
val semver: String
get() = "$major$separator$minor$separator$patch" +
- (if (preRelease.isNotEmpty()) "$preReleasePrefix$preRelease" else "") +
- (if (buildMeta.isNotEmpty()) "$buildMetaPrefix$buildMeta" else "")
+ (if (preRelease.isNotEmpty()) "$preReleasePrefix$preRelease" else "") +
+ (if (buildMeta.isNotEmpty()) "$buildMetaPrefix$buildMeta" else "")
fun increment(isMajor: Boolean = false, isMinor: Boolean = false, isPatch: Boolean = false) {
if (isMajor) {
@@ -70,5 +70,16 @@ class Version {
if (isPatch) patch++
}
- override fun toString() = semver
+ override fun toString(): String {
+ return "Version(" +
+ "major='$major', " +
+ "minor='$minor', " +
+ "patch='$patch', " +
+ "preRelease='$preRelease', " +
+ "preReleasePrefix='$preReleasePrefix', " +
+ "buildMeta='$buildMeta', " +
+ "buildMetaPrefix='$buildMetaPrefix', " +
+ "separator='$separator', " +
+ ')'
+ }
}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/utils.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/utils.kt
deleted file mode 100644
index c2c3725..0000000
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/utils.kt
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * utils.kt
- *
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.gradle.semver
-
-import org.gradle.api.GradleException
-import java.io.File
-import java.io.FileInputStream
-import java.io.FileOutputStream
-import java.io.IOException
-import java.util.Properties
-
-private fun Properties.put(key: String, value: String, isValidCondition: Boolean) {
- if (isValidCondition) put(key, value)
-}
-
-fun File.canReadFile(): Boolean {
- return canRead() && isFile
-}
-
-fun getPropertiesFile(projectDir: File, propsFile: String): File {
- return if (File(propsFile).isAbsolute) {
- File(propsFile)
- } else {
- File(projectDir, propsFile)
- }
-}
-
-fun Set.isNotSystemProperty(): Boolean {
- this.forEach {
- if (System.getProperties().containsKey(it)) return false
- }
- return true
-}
-
-fun File.loadProperties(): Properties {
- var isNew = false
- val props = Properties()
- this.apply {
- try {
- if (!exists() && createNewFile()) {
- isNew = true
- }
- } catch (e: IOException) {
- throw GradleException("Unable to create: `$absoluteFile`", e)
- }
- if (canReadFile()) {
- FileInputStream(this).reader().use { reader ->
- props.apply {
- if (!isNew) {
- load(reader)
- }
- }
- }
- } else {
- throw GradleException("Unable to read version from: `$absoluteFile`")
- }
- }
- return props
-}
-
-fun loadIntProperty(props: Properties, key: String, default: Int): Int {
- try {
- return loadProperty(props, key, default.toString()).toInt()
- } catch (e: java.lang.NumberFormatException) {
- throw GradleException("Unable to parse $key property. (${e.message})", e)
- }
-}
-
-fun loadProperty(props: Properties, key: String, default: String): String {
- return System.getProperty(key, if (props.isNotEmpty()) props.getProperty(key, default) else default)
-}
-
-fun loadVersion(config: SemverConfig, version: Version, props: Properties) {
- props.apply {
- if (!parseSemVer(System.getProperty(config.semverKey), version)) {
- version.major = loadIntProperty(this, config.majorKey, Version.DEFAULT_MAJOR)
- version.minor = loadIntProperty(this, config.minorKey, Version.DEFAULT_MINOR)
- version.patch = loadIntProperty(this, config.patchKey, Version.DEFAULT_PATCH)
- version.preRelease = loadProperty(this, config.preReleaseKey, Version.DEFAULT_EMPTY)
- version.buildMeta = loadProperty(this, config.buildMetaKey, Version.DEFAULT_EMPTY)
- }
-
- if (!isEmpty) {
- version.preReleasePrefix =
- getProperty(config.preReleasePrefixKey, Version.DEFAULT_PRERELEASE_PREFIX)
- version.buildMetaPrefix =
- getProperty(config.buildMetaPrefixKey, Version.DEFAULT_BUILDMETA_PREFIX)
- version.separator = getProperty(config.separatorKey, Version.DEFAULT_SEPARATOR)
- }
- }
-}
-
-fun parseSemVer(input: String?, version: Version): Boolean {
- if (input.isNullOrBlank()) return false
-
- try {
- val max = 5
- val min = 3
-
- val parts = input.split(
- Regex("[\\Q${version.separator}${version.preReleasePrefix}${version.buildMetaPrefix}\\E]"),
- max
- )
-
- if (parts.size >= min) {
- version.major = parts[0].toInt()
- version.minor = parts[1].toInt()
- version.patch = parts[2].toInt()
- version.preRelease = ""
- version.buildMeta = ""
-
- if (parts.size > min) {
- when (parts.size) {
- max -> {
- version.preRelease = parts[3]
- version.buildMeta = parts[4]
- }
- 4 -> {
- if (input.endsWith(version.buildMetaPrefix + parts[3])) {
- version.buildMeta = parts[3]
- } else {
- version.preRelease = parts[3]
- }
- }
- }
- }
- } else {
- throw NumberFormatException("Not enough parts.")
- }
- } catch (e: NumberFormatException) {
- throw GradleException("Unable to parse version: \"$input\" (${e.message})", e)
- }
-
- return true
-}
-
-fun saveProperties(projectDir: File, config: SemverConfig, version: Version) {
- val propsFile = getPropertiesFile(projectDir, config.properties)
- SortedProperties().apply {
- try {
- propsFile.apply {
- if (canReadFile()) {
- FileInputStream(this).reader().use { load(it) }
- } else {
- createNewFile()
- }
-
- put(config.semverKey, version.semver)
- put(config.majorKey, version.major.toString())
- put(config.minorKey, version.minor.toString())
- put(config.patchKey, version.patch.toString())
- put(config.preReleaseKey, version.preRelease)
- put(config.buildMetaKey, version.buildMeta)
- put(config.semverKey, version.semver)
-
- put(
- config.buildMetaPrefixKey, version.buildMetaPrefix,
- version.buildMetaPrefix != Version.DEFAULT_BUILDMETA_PREFIX ||
- containsKey(config.buildMetaPrefixKey)
- )
- put(
- config.preReleasePrefixKey, version.preReleasePrefix,
- version.preReleasePrefix != Version.DEFAULT_PRERELEASE_PREFIX ||
- containsKey(config.preReleasePrefixKey)
- )
- put(
- config.separatorKey, version.separator,
- version.separator != Version.DEFAULT_SEPARATOR ||
- containsKey(config.separatorKey)
- )
-
- if (canWrite()) {
- FileOutputStream(this).writer().use {
- store(it, "Generated by the Semver Plugin for Gradle")
- }
- } else {
- throw IOException("Can't write.")
- }
- }
- } catch (e: IOException) {
- throw GradleException("Unable to write version to: `${propsFile.absoluteFile}`", e)
- }
- }
-}
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt
new file mode 100644
index 0000000..45105a0
--- /dev/null
+++ b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt
@@ -0,0 +1,124 @@
+/*
+ * SemverConfigSpec.kt
+ *
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.thauvin.erik.gradle.semver
+
+import org.spekframework.spek2.Spek
+import org.spekframework.spek2.style.gherkin.Feature
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+@Suppress("unused")
+object SemverConfigSpec : Spek({
+ Feature("SemverConfig") {
+ val config = SemverConfig(Version())
+ Scenario("Testing configs") {
+ val vars = listOf(
+ config.semverKey,
+ config.majorKey,
+ config.minorKey,
+ config.patchKey,
+ config.preReleaseKey,
+ config.preReleasePrefixKey,
+ config.buildMetaKey,
+ config.buildMetaPrefixKey,
+ config.separatorKey
+ )
+ val defaults = listOf(
+ SemverConfig.DEFAULT_SEMVER_KEY,
+ SemverConfig.DEFAULT_MAJOR_KEY,
+ SemverConfig.DEFAULT_MINOR_KEY,
+ SemverConfig.DEFAULT_PATCH_KEY,
+ SemverConfig.DEFAULT_PRERELEASE_KEY,
+ SemverConfig.DEFAULT_PRERELEASE_PREFIX_KEY,
+ SemverConfig.DEFAULT_BUILDMETA_KEY,
+ SemverConfig.DEFAULT_BUILDMETA_PREFIX_KEY,
+ SemverConfig.DEFAULT_SEPARATOR
+ )
+
+ When("checking defaults") {}
+
+ defaults.forEachIndexed { i, d ->
+ Then(" ${vars[i]} should be the same: ${config.keysPrefix}$d") {
+ assertEquals(vars[i], "${config.keysPrefix}$d")
+ }
+ }
+
+ Then("config.properties should be version.properties") {
+ assertEquals(config.properties, "version.properties")
+ }
+
+ lateinit var newKeys: List
+
+ When("setting keyPrefix to test.") {
+ config.keysPrefix = "test."
+ newKeys = listOf(
+ config.semverKey,
+ config.majorKey,
+ config.minorKey,
+ config.patchKey,
+ config.preReleaseKey,
+ config.preReleasePrefixKey,
+ config.buildMetaKey,
+ config.buildMetaPrefixKey,
+ config.separatorKey
+ )
+ }
+
+ Then("all config keys should start with test.xxxx") {
+ newKeys.forEach { k ->
+ assertTrue(k.startsWith("test."), k)
+ }
+ }
+
+ When("checking extension properties") {}
+
+ Then("semver should be defaults") {
+ val defaultSemver =
+ "${Version.DEFAULT_MAJOR}${Version.DEFAULT_SEPARATOR}${Version.DEFAULT_MINOR}${Version.DEFAULT_SEPARATOR}${Version.DEFAULT_PATCH}"
+ assertEquals(config.semver, defaultSemver)
+ assertEquals(
+ "${config.major}${config.separator}${config.minor}${config.separator}${config.patch}",
+ defaultSemver
+ )
+ assertEquals(config.preRelease, Version.DEFAULT_EMPTY)
+ assertEquals(config.buildMeta, Version.DEFAULT_EMPTY)
+ assertEquals(config.preReleasePrefix, Version.DEFAULT_PRERELEASE_PREFIX)
+ assertEquals(config.buildMetaPrefix, Version.DEFAULT_BUILDMETA_PREFIX)
+ }
+
+ Then("semver = version") {
+ assertEquals(config.semver, config.version)
+ }
+ }
+ }
+})
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigTest.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigTest.kt
deleted file mode 100644
index 23088bb..0000000
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigTest.kt
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * SemverConfigTest.kt
- *
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.gradle.semver
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-class SemverConfigTest {
- private val config = SemverConfig(Version())
-
- @Test
- fun testConfigs() {
- val vars = listOf(
- config.semverKey,
- config.majorKey,
- config.minorKey,
- config.patchKey,
- config.preReleaseKey,
- config.preReleasePrefixKey,
- config.buildMetaKey,
- config.buildMetaPrefixKey,
- config.separatorKey
- )
- val defaults = listOf(
- SemverConfig.DEFAULT_SEMVER_KEY,
- SemverConfig.DEFAULT_MAJOR_KEY,
- SemverConfig.DEFAULT_MINOR_KEY,
- SemverConfig.DEFAULT_PATCH_KEY,
- SemverConfig.DEFAULT_PRERELEASE_KEY,
- SemverConfig.DEFAULT_PRERELEASE_PREFIX_KEY,
- SemverConfig.DEFAULT_BUILDMETA_KEY,
- SemverConfig.DEFAULT_BUILDMETA_PREFIX_KEY,
- SemverConfig.DEFAULT_SEPARATOR
- )
-
- defaults.forEachIndexed { i, d ->
- assertEquals(vars[i], "${config.keysPrefix}$d", " ${vars[i]} should be the same: ${config.keysPrefix}$d")
- }
-
- assertEquals(config.properties, "version.properties", "config.properties should be version.properties")
-
- assertTrue(
- config.toString().contains("properties='${SemverConfig.DEFAULT_PROPERTIES}'"),
- "toString contains default properties"
- )
- }
-
- @Test
- fun testExtensionProperties() {
- config.keysPrefix = "test."
-
- val newKeys = listOf(
- config.semverKey,
- config.majorKey,
- config.minorKey,
- config.patchKey,
- config.preReleaseKey,
- config.preReleasePrefixKey,
- config.buildMetaKey,
- config.buildMetaPrefixKey,
- config.separatorKey
- )
-
- newKeys.forEach { k ->
- assertTrue(k.startsWith("test."), "$k: all config keys should start with test.xxxx")
- }
-
- val defaultSemver =
- "${Version.DEFAULT_MAJOR}${Version.DEFAULT_SEPARATOR}${Version.DEFAULT_MINOR}" +
- "${Version.DEFAULT_SEPARATOR}${Version.DEFAULT_PATCH}"
- assertEquals(config.semver, defaultSemver, "semver should be defaults")
- assertEquals(
- "${config.major}${config.separator}${config.minor}${config.separator}${config.patch}",
- defaultSemver,
- "major-minor-patch should be defaults."
- )
- assertEquals(config.preRelease, Version.DEFAULT_EMPTY, "preRelease empty default")
- assertEquals(config.buildMeta, Version.DEFAULT_EMPTY, "buildMeta empty default")
- assertEquals(config.preReleasePrefix, Version.DEFAULT_PRERELEASE_PREFIX, "preReleasePrefix default")
- assertEquals(config.buildMetaPrefix, Version.DEFAULT_BUILDMETA_PREFIX, "buildMetaPrefix default")
-
- assertEquals(config.semver, config.version, "semver = version")
- }
-}
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverPluginTest.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverPluginTest.kt
deleted file mode 100644
index d56adbd..0000000
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverPluginTest.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SemverPluginTest.kt
- *
- * Copyright (c) 2018-2025, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.gradle.semver
-
-import org.gradle.testkit.runner.GradleRunner
-import org.gradle.testkit.runner.TaskOutcome.FAILED
-import org.gradle.testkit.runner.TaskOutcome.SUCCESS
-import org.junit.Test
-import java.io.File
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-
-class SemverPluginTest {
- @Test
- fun testSemverPlugin() {
- val result = GradleRunner.create()
- .withProjectDir(File("examples/test/"))
- .withPluginClasspath()
- .withArguments("incrementBuildMeta", "run")
- .forwardOutput()
- .build()
-
- assertTrue(result.output.contains("version.meta="))
- assertEquals(SUCCESS, result.task(":incrementBuildMeta")?.outcome ?: FAILED)
- assertEquals(SUCCESS, result.task(":run")?.outcome ?: FAILED)
- }
-}
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt
new file mode 100644
index 0000000..3dc5f1e
--- /dev/null
+++ b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt
@@ -0,0 +1,203 @@
+/*
+ * SemverVersionSpec.kt
+ *
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.thauvin.erik.gradle.semver
+
+import org.spekframework.spek2.Spek
+import org.spekframework.spek2.style.gherkin.Feature
+import kotlin.test.assertEquals
+
+@Suppress("unused")
+object SemverVersionSpec : Spek({
+ Feature("SemverVersion") {
+ val version = Version()
+ Scenario("Testing Versions") {
+ When("validating default version") {}
+
+ Then("major should be 1") {
+ assertEquals(1, version.major)
+ }
+
+ Then("minor should be 1") {
+ assertEquals(0, version.minor)
+ }
+
+ Then("patch should be 0") {
+ assertEquals(0, version.patch)
+ }
+
+ Then("prerelease should be empty") {
+ assertEquals("", version.preRelease)
+ }
+
+ Then("meta should be empty") {
+ assertEquals("", version.buildMeta)
+ }
+
+ Then("preRelease prefix should be -") {
+ assertEquals("-", version.preReleasePrefix)
+ }
+
+ Then("meta prefix should be +") {
+ assertEquals("+", version.buildMetaPrefix)
+ }
+
+ Then("separator should be .") {
+ assertEquals(".", version.separator)
+ }
+
+ Then("version should be 1.0.0") {
+ assertEquals("1.0.0", version.semver)
+ }
+
+ When("incrementing major") {
+ version.increment(isMajor = true)
+ }
+
+ Then("should return 2.0.0") {
+ assertEquals("2.0.0", version.semver)
+ }
+
+ When("incrementing minor") {
+ version.increment(isMinor = true)
+ }
+
+ Then("should return 2.1.0") {
+ assertEquals("2.1.0", version.semver)
+ }
+
+ When("incrementing patch") {
+ version.increment(isPatch = true)
+ }
+
+ Then("should return 2.1.1") {
+ assertEquals("2.1.1", version.semver)
+ }
+
+ When("incrementing minor again") {
+ version.increment(isMinor = true)
+ }
+
+ Then("should return 2.2.0") {
+ assertEquals("2.2.0", version.semver)
+ }
+
+ When("incrementing major again") {
+ version.increment(isMajor = true)
+ }
+
+ Then("should return 3.0.0") {
+ assertEquals("3.0.0", version.semver)
+ }
+
+ When("incrementing all") {
+ version.increment(isMajor = true, isMinor = true, isPatch = true)
+ }
+
+ Then("should return 4.1.1") {
+ assertEquals("4.1.1", version.semver)
+ }
+
+ When("incrementing major and minor") {
+ version.increment(isMajor = true, isMinor = true)
+ }
+
+ Then("should return 5.1.0") {
+ assertEquals("5.1.0", version.semver)
+ }
+
+ When("incrementing minor and patch") {
+ version.increment(isMinor = true, isPatch = true)
+ }
+ Then("should return 5.2.1") {
+ assertEquals("5.2.1", version.semver)
+ }
+
+ When("incrementing nothing") {
+ version.increment()
+ }
+ Then("should still return 5.2.1") {
+ assertEquals("5.2.1", version.semver)
+ }
+
+ When("resetting version") {
+ version.major = 1
+ version.minor = 0
+ version.patch = 0
+ }
+
+ Then("should return 1.0.0") {
+ assertEquals("1.0.0", version.semver)
+ }
+
+ When("adding prerelease") {
+ version.preRelease = "beta"
+ }
+
+ Then("should return 1.0.0-beta") {
+ assertEquals("1.0.0-beta", version.semver)
+ }
+
+ When("adding metadata") {
+ version.buildMeta = "007"
+ }
+
+ Then("should return 1.0.0-beta+007") {
+ assertEquals("1.0.0-beta+007", version.semver)
+ }
+
+ When("changing prerelease prefix") {
+ version.preReleasePrefix = "--"
+ }
+
+ Then("should return 1.0.0--beta+007") {
+ assertEquals("1.0.0--beta+007", version.semver)
+ }
+
+ When("changing meta prefix") {
+ version.buildMetaPrefix = "++"
+ }
+
+ Then("should return 1.0.0--beta++007") {
+ assertEquals("1.0.0--beta++007", version.semver)
+ }
+
+ When("changing separator") {
+ version.separator = "-"
+ }
+
+ Then("should return 1-0-0--beta++007") {
+ assertEquals("1-0-0--beta++007", version.semver)
+ }
+ }
+ }
+})
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SortedPropertiesTest.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SortedPropertiesTest.kt
deleted file mode 100644
index 562299a..0000000
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/SortedPropertiesTest.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SortedPropertiesTest.kt
- *
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.gradle.semver
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class SortedPropertiesTest {
- @Test
- fun testSortedProperties() {
- val props = SortedProperties()
- val fruits = setOf("Avocado", "Tomato", "apple", "banana", "cucumber", "zucchini")
-
- fruits.reversed().forEach {
- props[it] = "test"
- }
-
- val keys = props.keys().iterator()
- fruits.forEach {
- assertEquals(it, keys.next(), "$it key")
- }
-
- val entries = props.entries.iterator()
- fruits.forEach {
- assertEquals(it, entries.next().key, "$it entry")
- }
- }
-}
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsSpec.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsSpec.kt
new file mode 100644
index 0000000..3ad050f
--- /dev/null
+++ b/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsSpec.kt
@@ -0,0 +1,269 @@
+/*
+ * UtilsSpec.kt
+ *
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package net.thauvin.erik.gradle.semver
+
+import net.thauvin.erik.gradle.semver.Utils.canReadFile
+import org.gradle.api.GradleException
+import org.spekframework.spek2.Spek
+import org.spekframework.spek2.style.gherkin.Feature
+import java.io.File
+import java.util.*
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
+import kotlin.test.assertNull
+import kotlin.test.assertTrue
+
+@Suppress("unused")
+object UtilsSpec : Spek(
+ {
+ Feature("Utils") {
+ val version = Version()
+ val config = SemverConfig(version)
+ val propsFile = File("test.properties")
+ val projectDir = File("./")
+ lateinit var props: Properties
+
+ Scenario("Save/Load Properties") {
+ When("saving the property") {
+ config.properties = propsFile.name
+ Utils.saveProperties(projectDir, config, version)
+ }
+
+ Then("properties file should exists and be readable") {
+ assertEquals(propsFile.canReadFile(), propsFile.canRead() && propsFile.isFile)
+ }
+
+ When("loading the properties file") {
+ props = Utils.loadProperties(propsFile)
+ propsFile.delete()
+ }
+
+ Then("version and properties should be the same.") {
+ assertEquals(props.getProperty(config.majorKey), version.major.toString(), "Major")
+ assertEquals(props.getProperty(config.minorKey), version.minor.toString(), "Minor")
+ assertEquals(props.getProperty(config.patchKey), version.patch.toString(), "Patch")
+ assertEquals(props.getProperty(config.preReleaseKey), version.preRelease, "PreRelease")
+ assertNull(props.getProperty(config.preReleasePrefixKey), "PreRelease Prefix")
+ assertEquals(props.getProperty(config.buildMetaKey), version.buildMeta, "Build Meta")
+ assertNull(props.getProperty(config.buildMetaPrefixKey), "Build Meta Prefix")
+ assertNull(props.getProperty(config.separatorKey), "Separator")
+ assertEquals(props.getProperty(config.semverKey), version.semver, "semver")
+ }
+ }
+
+ Scenario("System Properties") {
+ lateinit var sysProps: Array>
+
+ Given("new system properties") {
+ sysProps = arrayOf(
+ Pair(config.majorKey, "2"),
+ Pair(config.minorKey, "1"),
+ Pair(config.patchKey, "1"),
+ Pair(config.preReleaseKey, "beta"),
+ Pair(config.buildMetaKey, "007")
+ )
+ }
+
+ Then("none should already exists") {
+ assertTrue(
+ Utils.isNotSystemProperty(
+ setOf(
+ config.majorKey,
+ config.minorKey,
+ config.patchKey,
+ config.preReleaseKey,
+ config.buildMetaKey
+ )
+ )
+ )
+ }
+
+ Then("version should match system properties") {
+ sysProps.forEach {
+ System.getProperties().setProperty(it.first, it.second)
+ if (it.first == config.majorKey || it.first == config.minorKey || it.first == config.patchKey) {
+ assertEquals(Utils.loadIntProperty(props, it.first, -1), it.second.toInt())
+ } else {
+ assertEquals(Utils.loadProperty(props, it.first, ""), it.second)
+ }
+ }
+ }
+
+ When("loading version") {
+ Utils.loadVersion(config, version, props)
+ }
+
+ Then("version should be identical") {
+ assertEquals(version.semver, "2.1.1-beta+007")
+ }
+
+ When("saving properties") {
+ Utils.saveProperties(projectDir, config, version)
+ }
+
+ lateinit var newProps: Properties
+
+ And("loading properties file") {
+ newProps = Utils.loadProperties(propsFile)
+ }
+
+ Then("new properties should validate") {
+ sysProps.forEach {
+ assertEquals(newProps.getProperty(it.first), it.second, it.second)
+ }
+ propsFile.delete()
+ }
+
+ When("setting the version as system property") {
+ System.getProperties().setProperty(config.semverKey, "3.2.2")
+ }
+
+ And("loading the properties") {
+ Utils.loadVersion(config, version, props)
+ }
+
+ Then("versions should match") {
+ assertEquals(version.semver, System.getProperty(config.semverKey))
+ }
+ }
+
+ Scenario("Version Parsing") {
+ When("validating version parsing") {}
+
+ Then("versions should parse") {
+ listOf(
+ "1.0.0",
+ "2.1.0-beta",
+ "3.2.1-beta+007",
+ "4.3.2+007",
+ "11.11.1",
+ "111.11.11-beta",
+ "1111.111.11-beta+001.12"
+ ).forEach {
+ assertTrue(Utils.parseSemVer(it, version), "parsing semver: $it")
+ assertEquals(it, version.semver, it)
+ }
+ }
+
+ Then("should throw exceptions") {
+ assertFailsWith("2.1.1a") {
+ Utils.parseSemVer("2.1.1a", version)
+ }
+ assertFailsWith("2a.1.1") {
+ Utils.parseSemVer("2a.1.1", version)
+ }
+ assertFailsWith("2.1a.1") {
+ Utils.parseSemVer("2.1a.1", version)
+ }
+ assertFailsWith("2.1") {
+ Utils.parseSemVer("2.1", version)
+ }
+ }
+
+ Given("new prefixes") {
+ version.preReleasePrefix = "."
+ version.buildMetaPrefix = "."
+ }
+
+ Then("prefixes should parse") {
+ listOf("2.1.0.beta.1", "2.1.1.1", "3.2.1.beta.1.007").forEach {
+ assertTrue(Utils.parseSemVer(it, version), "parsing semver: $it")
+ assertEquals(it, version.semver, it)
+ }
+ }
+
+ Then("last pre-release and meta should match") {
+ assertEquals(version.preRelease, "beta")
+ assertEquals(version.buildMeta, "1.007")
+ }
+ }
+
+ Scenario("Load locked properties") {
+ lateinit var locked: File
+
+ Given("the locked location") {
+ locked = File("locked")
+ }
+
+ Then("loading locked properties") {
+ assertFailsWith {
+ Utils.loadProperties(File(locked, propsFile.name))
+ }
+ locked.delete()
+ }
+ }
+
+ Scenario("Save to locked properties") {
+ lateinit var propsLocked: File
+ Given("the locked properties") {
+ propsLocked = File(System.getProperty("user.home") + File.separator + "locked.properties")
+ propsLocked.createNewFile()
+ propsLocked.setReadOnly()
+ config.properties = propsLocked.name
+ }
+
+ Then("saving the locked properties file") {
+ assertFailsWith {
+ Utils.saveProperties(propsLocked.parentFile, config, version)
+ }
+ propsLocked.delete()
+ }
+ }
+
+ Scenario("Save/Load Properties in foo") {
+ lateinit var fooDir: File
+ lateinit var fooProps: File
+ When("saving the foo property") {
+ fooDir = File("foo")
+ fooDir.mkdir()
+ fooProps = File(fooDir, propsFile.name)
+ config.properties = fooProps.absolutePath
+ Utils.saveProperties(projectDir, config, version)
+ }
+
+ Then("foo properties file should exists and be readable") {
+ assertEquals(fooProps.canReadFile(), fooProps.canRead() && fooProps.isFile)
+ }
+
+ When("loading the foo properties file") {
+ props = Utils.loadProperties(fooProps)
+ fooProps.delete()
+ fooDir.delete()
+ }
+
+ Then("version in foo properties should be the same") {
+ assertEquals(props.getProperty(config.semverKey), version.semver)
+ }
+ }
+ }
+ }
+)
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsTest.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsTest.kt
deleted file mode 100644
index 14dc021..0000000
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsTest.kt
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * est.kt
- *
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.gradle.semver
-
-import org.gradle.api.GradleException
-import java.io.File
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertFailsWith
-import kotlin.test.assertNull
-import kotlin.test.assertTrue
-
-/**
- * Tests
- */
-class UtilsTest {
- private val version = Version()
- private val config = SemverConfig(version)
- private val propsFile = File("test.properties")
- private val projectDir = File("./")
-
- @Test
- fun testExceptions() {
- assertFailsWith("2.1.1a") {
- parseSemVer("2.1.1a", version)
- }
- assertFailsWith("2a.1.1") {
- parseSemVer("2a.1.1", version)
- }
- assertFailsWith("2.1a.1") {
- parseSemVer("2.1a.1", version)
- }
- assertFailsWith("2.1") {
- parseSemVer("2.1", version)
- }
- }
-
- @Test
- fun testFooProperties() {
- val fooDir = File("foo")
- fooDir.mkdir()
- val fooFile = File(fooDir, propsFile.name)
- config.properties = fooFile.absolutePath
- saveProperties(projectDir, config, version)
-
- assertEquals(
- fooFile.canReadFile(),
- fooFile.canRead() && fooFile.isFile,
- "foo properties file should exists and be readable"
- )
-
- val fooProps = fooFile.loadProperties()
- fooFile.delete()
- fooDir.delete()
-
- assertEquals(
- fooProps.getProperty(config.semverKey),
- version.semver,
- "version in foo properties should be the same"
- )
- }
-
- @Test
- fun testLoadSaveProperties() {
- config.properties = propsFile.name
- saveProperties(projectDir, config, version)
- assertEquals(
- propsFile.canReadFile(),
- propsFile.canRead() && propsFile.isFile,
- "properties file should exists and be readable"
- )
-
- val props = propsFile.loadProperties()
-
- assertEquals(props.getProperty(config.majorKey), version.major.toString(), "Major")
- assertEquals(props.getProperty(config.minorKey), version.minor.toString(), "Minor")
- assertEquals(props.getProperty(config.patchKey), version.patch.toString(), "Patch")
- assertEquals(props.getProperty(config.preReleaseKey), version.preRelease, "PreRelease")
- assertNull(props.getProperty(config.preReleasePrefixKey), "PreRelease Prefix")
- assertEquals(props.getProperty(config.buildMetaKey), version.buildMeta, "Build Meta")
- assertNull(props.getProperty(config.buildMetaPrefixKey), "Build Meta Prefix")
- assertNull(props.getProperty(config.separatorKey), "Separator")
- assertEquals(props.getProperty(config.semverKey), version.semver, "semver")
-
- propsFile.delete()
- }
-
- @Test
- fun testLockedProperties() {
- var locked = File("locked")
-
- assertFailsWith {
- File(locked, propsFile.name).loadProperties()
- }
- locked.delete()
-
- locked = File(System.getProperty("user.home") + File.separator + "locked.properties")
- locked.createNewFile()
- locked.setReadOnly()
- config.properties = locked.name
-
- if (!locked.canWrite()) {
- assertFailsWith {
- saveProperties(locked.parentFile, config, version)
- }
- }
- locked.delete()
- }
-
- @Test
- fun testLoadIntProperty() {
- val props = SortedProperties()
- props["foo"] = "bar"
-
- assertFailsWith { loadIntProperty(props, "foo", 1) }
-
- assertEquals(loadIntProperty(props, "none", 1), 1, "default int value")
- }
-
- @Test
- fun testPrefix() {
- version.preReleasePrefix = "."
- version.buildMetaPrefix = "."
-
- listOf("2.1.0.beta.1", "2.1.1.1", "3.2.1.beta.1.007").forEach {
- assertTrue(parseSemVer(it, version), "parsing semver: $it")
- assertEquals(it, version.semver, it)
- }
-
- assertEquals(version.preRelease, "beta", "last pre-release should match")
- assertEquals(version.buildMeta, "1.007", "last meta should match")
- }
-
- @Test
- fun testSystemProperties() {
- val sysProps = arrayOf(
- Pair(config.majorKey, "2"),
- Pair(config.minorKey, "1"),
- Pair(config.patchKey, "1"),
- Pair(config.preReleaseKey, "beta"),
- Pair(config.buildMetaKey, "007")
- )
-
- assertTrue(
- setOf(
- config.majorKey,
- config.minorKey,
- config.patchKey,
- config.preReleaseKey,
- config.buildMetaKey
- ).isNotSystemProperty(), "none should already exists"
- )
-
- val props = propsFile.loadProperties()
-
- sysProps.forEach {
- val msg = "${it.first} should match system properties"
- System.getProperties().setProperty(it.first, it.second)
- if (it.first == config.majorKey || it.first == config.minorKey || it.first == config.patchKey) {
- assertEquals(loadIntProperty(props, it.first, -1), it.second.toInt(), msg)
- } else {
- assertEquals(loadProperty(props, it.first, ""), it.second, msg)
- }
- }
-
- loadVersion(config, version, props)
- assertEquals(version.semver, "2.1.1-beta+007", "version should be identical")
-
- saveProperties(projectDir, config, version)
-
- val newPropsFile = File(config.properties)
- val newProps = newPropsFile.loadProperties()
-
- sysProps.forEach {
- assertEquals(newProps.getProperty(it.first), it.second, "new properties should validate")
- }
-
- newPropsFile.delete()
-
- System.getProperties().setProperty(config.semverKey, "3.2.2")
- props["foo"] = "bar"
- loadVersion(config, version, props)
- assertEquals(version.semver, System.getProperty(config.semverKey), "versions should match")
- }
-
- @Test
- fun testVersionParsing() {
- listOf(
- "1.0.0",
- "2.1.0-beta",
- "3.2.1-beta+007",
- "4.3.2+007",
- "11.11.1",
- "111.11.11-beta",
- "1111.111.11-beta+001.12"
- ).forEach {
- assertTrue(parseSemVer(it, version), "parsing semver: $it")
- assertEquals(it, version.semver, it)
- }
- }
-}
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/VersionTest.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/VersionTest.kt
deleted file mode 100644
index 2299c71..0000000
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/VersionTest.kt
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * VersionTest.kt
- *
- * Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of this project nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package net.thauvin.erik.gradle.semver
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class VersionTest {
- private val version = Version()
-
- @Test
- fun testDefaultVersion() {
- assertEquals(1, version.major, "major should be 1")
- assertEquals(0, version.minor, "minor should be 1")
- assertEquals(0, version.patch, "patch should be 0")
- assertEquals("", version.preRelease, "prerelease should be empty")
- assertEquals("", version.buildMeta, "meta should be empty")
- assertEquals("-", version.preReleasePrefix, "preRelease prefix should be -")
- assertEquals("+", version.buildMetaPrefix, "meta prefix should be +")
- assertEquals(".", version.separator, "separator should be .")
- assertEquals("1.0.0", version.semver, "version should be 1.0.0")
- assertEquals(version.toString(), version.semver, "toString should be semver")
- }
-
- @Test
- fun testIncrement() {
- version.increment(isMajor = true)
- assertEquals("2.0.0", version.semver, "should return 2.0.0")
-
- version.increment(isMinor = true)
- assertEquals("2.1.0", version.semver, "should return 2.1.0")
-
- version.increment(isPatch = true)
- assertEquals("2.1.1", version.semver, "should return 2.1.1")
-
- version.increment(isMinor = true)
- assertEquals("2.2.0", version.semver, "should return 2.2.0")
-
- version.increment(isMajor = true)
- assertEquals("3.0.0", version.semver, "should return 3.0.0")
-
- version.increment(isMajor = true, isMinor = true, isPatch = true)
- assertEquals("4.1.1", version.semver, "should return 4.1.1")
-
- version.increment(isMajor = true, isMinor = true)
- assertEquals("5.1.0", version.semver, "should return 5.1.0")
-
- version.increment(isMinor = true, isPatch = true)
- assertEquals("5.2.1", version.semver, "should return 5.2.1")
-
- version.increment()
- assertEquals("5.2.1", version.semver, "should still return 5.2.1")
- }
-
- @Test
- fun testVersion() {
- version.major = 1
- version.minor = 0
- version.patch = 0
- assertEquals("1.0.0", version.semver, "should return 1.0.0")
-
- version.preRelease = "beta"
- assertEquals("1.0.0-beta", version.semver, "should return 1.0.0-beta")
-
- version.buildMeta = "007"
- assertEquals("1.0.0-beta+007", version.semver, "should return 1.0.0-beta+007")
-
- version.preReleasePrefix = "--"
- assertEquals("1.0.0--beta+007", version.semver, "should return 1.0.0--beta+007")
-
- version.buildMetaPrefix = "++"
- assertEquals("1.0.0--beta++007", version.semver, "should return 1.0.0--beta++007")
-
- version.separator = "-"
- assertEquals("1-0-0--beta++007", version.semver, "should return 1-0-0--beta++007")
-
- assertEquals(version.toString(), version.semver, "toString() should return semver")
- }
-}
diff --git a/updatewrappers.sh b/updatewrappers.sh
old mode 100755
new mode 100644
index 10c69e1..e98cca5
--- a/updatewrappers.sh
+++ b/updatewrappers.sh
@@ -1,16 +1,18 @@
#!/bin/bash
+
#
-# Version: 1.0.3
+# Version: 1.0.2
#
# set the examples directories
declare -a dirs=(
- "${PWD##*/}"
- "examples/java"
- "examples/kotlin"
- "examples/annotation-processor/java"
- "examples/annotation-processor/kotlin")
+ "${PWD##*/}"
+ "examples/java"
+ "examples/kotlin"
+ "examples/annotation-processor/java"
+ "examples/annotation-processor/kotlin")
+java8=true
###
@@ -20,25 +22,42 @@ green=$(tput setaf 2)
red=$(tput setaf 1)
std=$(tput sgr0)
+if [ "$java8" = true ]
+then
+ export JAVA_HOME="$JAVA8_HOME"
+ export PATH="$(cygpath "$JAVA_HOME")/bin:$PATH"
+fi
+
+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
- 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
+ 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