Compare commits
23 commits
Author | SHA1 | Date | |
---|---|---|---|
990d4e4c27 | |||
bebb56e71a | |||
bd315b4f0a | |||
86cc8b1519 | |||
aef7d1fa6a | |||
dafbaaff0f | |||
352bdaeb0d | |||
e8e7f65b2c | |||
bc2813cd31 | |||
808ca2a6f2 | |||
f7ef436a72 | |||
5e6a29fbe0 | |||
d19857bdd7 | |||
80c5374583 | |||
dac85d16f0 | |||
47ecdb372d | |||
13f0cd5b78 | |||
993d6f6f83 | |||
f4b1caa986 | |||
bcf95bc6f0 | |||
3553573bc7 | |||
09c3fef1ed | |||
b308a52d71 |
68 changed files with 2374 additions and 2040 deletions
|
@ -1,17 +1,12 @@
|
|||
version: 2
|
||||
defaults: &defaults
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
- image: circleci/openjdk:8-jdk
|
||||
environment:
|
||||
JVM_OPTS: -Xmx3200m
|
||||
TERM: dumb
|
||||
CI: true
|
||||
|
||||
jobs:
|
||||
build_gradle:
|
||||
<<: *defaults
|
||||
|
||||
defaults_gradle: &defaults_gradle
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -19,27 +14,41 @@ jobs:
|
|||
- 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: ~/.gradle
|
||||
paths: ~/.m2
|
||||
key: gradle-dependencies-{{ checksum "build.gradle.kts" }}
|
||||
|
||||
- run:
|
||||
name: Run All Checks
|
||||
command: ./gradlew check --scan
|
||||
|
||||
command: ./gradlew check
|
||||
- store_artifacts:
|
||||
path: build/reports/
|
||||
destination: reports
|
||||
- store_test_results:
|
||||
path: build/reports/
|
||||
|
||||
jobs:
|
||||
build_gradle_jdk17:
|
||||
<<: *defaults
|
||||
|
||||
docker:
|
||||
- image: cimg/openjdk:17.0
|
||||
|
||||
<<: *defaults_gradle
|
||||
|
||||
build_gradle_jdk8:
|
||||
<<: *defaults
|
||||
|
||||
docker:
|
||||
- image: cimg/openjdk:8.0
|
||||
|
||||
<<: *defaults_gradle
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_gradle:
|
||||
gradle:
|
||||
jobs:
|
||||
- build_gradle
|
||||
- build_gradle_jdk8
|
||||
- build_gradle_jdk17
|
||||
|
|
36
.github/workflows/gradle.yml
vendored
36
.github/workflows/gradle.yml
vendored
|
@ -1,19 +1,45 @@
|
|||
name: Java CI with Gradle
|
||||
name: gradle-ci
|
||||
|
||||
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: [ 1.8, 11, 17 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK ${{ matrix.java-version }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ matrix.java-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-${{ matrix.java-version }}-
|
||||
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew check
|
||||
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
|
||||
|
|
40
.gitignore
vendored
40
.gitignore
vendored
|
@ -1,22 +1,7 @@
|
|||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
|
||||
__pycache__
|
||||
.classpath
|
||||
.DS_Store
|
||||
.gradle
|
||||
.history
|
||||
.kobalt
|
||||
.mtj.tmp/
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.nb-gradle
|
||||
.project
|
||||
.scannerwork
|
||||
.settings
|
||||
*.class
|
||||
*.code-workspace
|
||||
*.ctxt
|
||||
|
@ -27,7 +12,21 @@ __pycache__
|
|||
*.sublime-*
|
||||
*.tar.gz
|
||||
*.zip
|
||||
/**/.idea_modules/
|
||||
.DS_Store
|
||||
.classpath
|
||||
.gradle
|
||||
.history
|
||||
.kobalt
|
||||
.mtj.tmp/
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.nb-gradle
|
||||
.project
|
||||
.scannerwork
|
||||
.settings
|
||||
.vscode/*
|
||||
/**/.idea/$CACHE_FILE$
|
||||
/**/.idea/$PRODUCT_WORKSPACE_FILE$
|
||||
/**/.idea/**/caches/build_file_checksums.ser
|
||||
/**/.idea/**/contentModel.xml
|
||||
/**/.idea/**/dataSources.ids
|
||||
|
@ -48,8 +47,10 @@ __pycache__
|
|||
/**/.idea/**/uiDesigner.xml
|
||||
/**/.idea/**/usage.statistics.xml
|
||||
/**/.idea/**/workspace.xml
|
||||
/**/.idea/$CACHE_FILE$
|
||||
/**/.idea/$PRODUCT_WORKSPACE_FILE$
|
||||
/**/.idea/sonarlint*
|
||||
/**/.idea_modules/
|
||||
Thumbs.db
|
||||
__pycache__
|
||||
atlassian-ide-plugin.xml
|
||||
bin/
|
||||
build/
|
||||
|
@ -63,7 +64,6 @@ dist/
|
|||
ehthumbs.db
|
||||
fabric.properties
|
||||
gen/
|
||||
gradle.properties
|
||||
hs_err_pid*
|
||||
kobaltBuild
|
||||
kobaltw*-test
|
||||
|
@ -71,6 +71,7 @@ lib/kotlin*
|
|||
libs/
|
||||
local.properties
|
||||
out/
|
||||
pom.xml.asc
|
||||
pom.xml.next
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.tag
|
||||
|
@ -80,5 +81,4 @@ project.properties
|
|||
release.properties
|
||||
target/
|
||||
test-output
|
||||
Thumbs.db
|
||||
venv
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
image: gradle:alpine
|
||||
image: gradle:8-jdk11
|
||||
|
||||
variables:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
|
@ -12,7 +12,7 @@ stages:
|
|||
|
||||
build:
|
||||
stage: build
|
||||
script: ./gradlew --build-cache assemble
|
||||
script: gradle --build-cache assemble
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: push
|
||||
|
@ -22,7 +22,7 @@ build:
|
|||
|
||||
test:
|
||||
stage: test
|
||||
script: ./gradlew check
|
||||
script: gradle check
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: pull
|
||||
|
|
15
.idea/codeStyles/Project.xml
generated
Normal file
15
.idea/codeStyles/Project.xml
generated
Normal file
|
@ -0,0 +1,15 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value />
|
||||
</option>
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
|
||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
2
.idea/codeStyles/codeStyleConfig.xml
generated
2
.idea/codeStyles/codeStyleConfig.xml
generated
|
@ -1,5 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Erik's Code Style" />
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
15
.idea/jarRepositories.xml
generated
15
.idea/jarRepositories.xml
generated
|
@ -26,5 +26,20 @@
|
|||
<option name="name" value="MavenLocal" />
|
||||
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://packages.jetbrains.team/maven/p/ij/intellij-dependencies" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
6
.idea/kotlinc.xml
generated
Normal file
6
.idea/kotlinc.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.9.10" />
|
||||
</component>
|
||||
</project>
|
65
.idea/libraries-with-intellij-classes.xml
generated
Normal file
65
.idea/libraries-with-intellij-classes.xml
generated
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="libraries-with-intellij-classes">
|
||||
<option name="intellijApiContainingLibraries">
|
||||
<list>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="ideaIU" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="ideaIU" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="ideaIC" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="ideaIC" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="pycharmPY" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="pycharmPY" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="pycharmPC" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="pycharmPC" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="clion" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.clion" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="clion" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="riderRD" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.rider" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="riderRD" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="goland" />
|
||||
<option name="groupId" value="com.jetbrains.intellij.goland" />
|
||||
</LibraryCoordinatesState>
|
||||
<LibraryCoordinatesState>
|
||||
<option name="artifactId" value="goland" />
|
||||
<option name="groupId" value="com.jetbrains" />
|
||||
</LibraryCoordinatesState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
|
@ -13,7 +13,10 @@
|
|||
<component name="NodePackageJsonFileManager">
|
||||
<packageJsonPaths />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="PDMPlugin">
|
||||
<option name="skipTestSources" value="false" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="15" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
30
.travis.yml
30
.travis.yml
|
@ -1,30 +0,0 @@
|
|||
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
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
24
README.md
24
README.md
|
@ -1,4 +1,4 @@
|
|||
[](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)
|
||||
[](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)
|
||||
|
||||
# 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.'
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
image: openjdk:8
|
||||
image: maven:3-openjdk-18
|
||||
|
||||
pipelines:
|
||||
default:
|
||||
|
|
|
@ -1,102 +1,79 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
|
||||
plugins {
|
||||
`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"
|
||||
id("com.github.ben-manes.versions") version "0.51.0"
|
||||
id("com.gradle.plugin-publish") version "1.2.1"
|
||||
id("io.gitlab.arturbosch.detekt") version "1.23.5"
|
||||
id("java-gradle-plugin")
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
id("org.gradle.kotlin.kotlin-dsl") version "4.2.1"
|
||||
kotlin("jvm") version "1.9.20"
|
||||
}
|
||||
|
||||
version = "1.0.5-beta"
|
||||
version = "1.0.5"
|
||||
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 {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(gradleApi())
|
||||
|
||||
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
|
||||
implementation(platform(kotlin("bom")))
|
||||
implementation(kotlin("stdlib"))
|
||||
testImplementation(kotlin("reflect"))
|
||||
|
||||
// testImplementation(gradleTestKit())
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
|
||||
testImplementation(gradleTestKit())
|
||||
|
||||
testImplementation("org.spekframework.spek2:spek-dsl-jvm:${versions.spek}")
|
||||
testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:${versions.spek}")
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
tasks {
|
||||
withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
// Gradle 4.6
|
||||
kotlinOptions.apiVersion = "1.2"
|
||||
kotlinOptions {
|
||||
jvmTarget = java.targetCompatibility.toString()
|
||||
apiVersion = "1.6"
|
||||
}
|
||||
}
|
||||
|
||||
withType<Test> {
|
||||
useJUnitPlatform {
|
||||
includeEngines("spek2")
|
||||
testLogging {
|
||||
exceptionFormat = TestExceptionFormat.FULL
|
||||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
}
|
||||
|
||||
withType<JacocoReport> {
|
||||
reports {
|
||||
html.isEnabled = true
|
||||
xml.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
"sonarqube" {
|
||||
dependsOn("jacocoTestReport")
|
||||
}
|
||||
}
|
||||
|
||||
detekt {
|
||||
// input = files("src/main/kotlin", "src/test/kotlin")
|
||||
// filters = ".*/resources/.*,.*/build/.*"
|
||||
// toolVersion = "main-SNAPSHOT"
|
||||
baseline = project.rootDir.resolve("detekt-baseline.xml")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<SmellBaseline>
|
||||
<ManuallySuppressedIssues></ManuallySuppressedIssues>
|
||||
<CurrentIssues>
|
||||
<ID>MagicNumber:Utils.kt$Utils$3</ID>
|
||||
<ID>MagicNumber:Utils.kt$Utils$4</ID>
|
||||
<ID>MagicNumber:Utils.kt$Utils$5</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$fun loadProperties(file: File): Properties</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$fun parseSemVer(input: String?, version: Version): Boolean</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$fun saveProperties(projectDir: File, config: SemverConfig, version: Version)</ID>
|
||||
<ID>MagicNumber:utils.kt$3</ID>
|
||||
<ID>MagicNumber:utils.kt$4</ID>
|
||||
<ID>MagicNumber:utils.kt$5</ID>
|
||||
<ID>NestedBlockDepth:utils.kt$fun File.loadProperties(): Properties</ID>
|
||||
<ID>NestedBlockDepth:utils.kt$fun parseSemVer(input: String?, version: Version): Boolean</ID>
|
||||
<ID>NestedBlockDepth:utils.kt$fun saveProperties(projectDir: File, config: SemverConfig, version: Version)</ID>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
||||
|
|
|
@ -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.28.0'
|
||||
id 'com.github.ben-manes.versions' version '0.51.0'
|
||||
}
|
||||
|
||||
// ./gradlew
|
||||
|
@ -14,7 +14,7 @@ mainClassName = 'com.example.Example'
|
|||
|
||||
defaultTasks 'run'
|
||||
|
||||
def semverProcessor = "net.thauvin.erik:semver:1.2.0"
|
||||
def semverProcessor = 'net.thauvin.erik:semver:1.2.1'
|
||||
|
||||
dependencies {
|
||||
annotationProcessor semverProcessor
|
||||
|
@ -28,7 +28,7 @@ tasks.withType(JavaCompile) {
|
|||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
run {
|
||||
|
@ -41,8 +41,8 @@ run {
|
|||
}
|
||||
|
||||
semver {
|
||||
// properties = "example.properties"
|
||||
// keysPrefix = "example."
|
||||
// preReleaseKey = "release"
|
||||
// buildMetaKey = "meta"
|
||||
// properties = 'example.properties'
|
||||
// keysPrefix = 'example.'
|
||||
// preReleaseKey = 'release'
|
||||
// buildMetaKey = 'meta'
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
294
examples/annotation-processor/java/gradlew
vendored
294
examples/annotation-processor/java/gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,78 +17,111 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_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"'
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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
|
||||
|
@ -97,87 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
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.
|
||||
|
||||
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# 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
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
|
|
51
examples/annotation-processor/java/gradlew.bat
vendored
51
examples/annotation-processor/java/gradlew.bat
vendored
|
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -54,48 +55,36 @@ goto fail
|
|||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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=%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%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%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%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -14,16 +14,16 @@ import java.util.Date;
|
|||
*/
|
||||
public final class GeneratedVersion {
|
||||
public static final String PROJECT = "Java Example";
|
||||
public static final Date BUILDDATE = new Date(1564027571537L);
|
||||
public static final Date BUILDDATE = new Date(1707709694421L);
|
||||
public static final int MAJOR = 2;
|
||||
public static final int MINOR = 10;
|
||||
public static final int MINOR = 12;
|
||||
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";
|
||||
public static final String VERSION = "2.12.0";
|
||||
|
||||
/**
|
||||
* Disables the default constructor.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Wed Jul 24 21:06:09 PDT 2019
|
||||
#Sun Feb 11 19:56:02 PST 2024
|
||||
version.buildmeta=
|
||||
version.major=2
|
||||
version.minor=10
|
||||
version.minor=13
|
||||
version.patch=0
|
||||
version.prerelease=
|
||||
version.project=Java Example
|
||||
version.semver=2.10.0
|
||||
version.semver=2.13.0
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
plugins {
|
||||
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")
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.51.0"
|
||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||
kotlin("jvm") version "1.7.22"
|
||||
kotlin("kapt") version "1.7.22"
|
||||
}
|
||||
|
||||
// ./gradlew
|
||||
|
@ -13,7 +13,7 @@ plugins {
|
|||
|
||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||
|
||||
var semverProcessor = "net.thauvin.erik:semver:1.2.0"
|
||||
var semverProcessor = "net.thauvin.erik:semver:1.2.1"
|
||||
|
||||
dependencies {
|
||||
kapt(semverProcessor)
|
||||
|
@ -24,11 +24,11 @@ dependencies {
|
|||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "com.example.Main"
|
||||
mainClass.set("com.example.Main")
|
||||
}
|
||||
|
||||
kapt {
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
294
examples/annotation-processor/kotlin/gradlew
vendored
294
examples/annotation-processor/kotlin/gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,78 +17,111 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_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"'
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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
|
||||
|
@ -97,87 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
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.
|
||||
|
||||
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# 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
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
|
|
51
examples/annotation-processor/kotlin/gradlew.bat
vendored
51
examples/annotation-processor/kotlin/gradlew.bat
vendored
|
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -54,48 +55,36 @@ goto fail
|
|||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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=%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%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%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%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Wed Jul 24 21:06:46 PDT 2019
|
||||
#Sun Feb 11 19:56:22 PST 2024
|
||||
version.buildmeta=
|
||||
version.major=14
|
||||
version.minor=3
|
||||
version.minor=6
|
||||
version.patch=0
|
||||
version.prerelease=
|
||||
version.project=Kotlin Example
|
||||
version.semver=14.3.0
|
||||
version.semver=14.6.0
|
||||
|
|
|
@ -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.36.0'
|
||||
id 'com.github.ben-manes.versions' version '0.51.0'
|
||||
}
|
||||
|
||||
// ./gradlew
|
||||
|
@ -12,34 +12,28 @@ plugins {
|
|||
// ./gradlew incrementBuildMeta run
|
||||
// ./gradlew echoVersion
|
||||
|
||||
|
||||
defaultTasks 'run'
|
||||
|
||||
mainClassName = 'App'
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
||||
testImplementation platform('org.junit:junit-bom:5.10.2')
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
application {
|
||||
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,8 +44,10 @@ incrementBuildMeta {
|
|||
}
|
||||
|
||||
run {
|
||||
// project.afterEvaluate {
|
||||
// println "Version: $version"
|
||||
// }
|
||||
doFirst {
|
||||
// println "Version: ${-> version}"
|
||||
println "Version: $version"
|
||||
}
|
||||
|
||||
|
@ -60,5 +56,5 @@ run {
|
|||
}
|
||||
|
||||
task echoVersion(type:Exec) {
|
||||
commandLine 'echo', "${-> project.version}"
|
||||
commandLine('echo', "${-> project.version}")
|
||||
}
|
||||
|
|
BIN
examples/java/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/java/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
294
examples/java/gradlew
vendored
294
examples/java/gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,67 +17,99 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_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"'
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
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.
|
||||
|
||||
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# 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
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
|
|
31
examples/java/gradlew.bat
vendored
31
examples/java/gradlew.bat
vendored
|
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Fri Sep 25 17:38:33 PDT 2020
|
||||
version.buildmeta=20200925173833
|
||||
#Sun Feb 11 19:55:34 PST 2024
|
||||
version.buildmeta=20240211195534
|
||||
version.major=1
|
||||
version.minor=0
|
||||
version.patch=0
|
||||
version.prerelease=
|
||||
version.semver=1.0.0+20200925173833
|
||||
version.semver=1.0.0+20240211195534
|
||||
|
|
|
@ -4,10 +4,10 @@ import java.time.LocalDateTime
|
|||
import java.time.format.DateTimeFormatter
|
||||
|
||||
plugins {
|
||||
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")
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.51.0"
|
||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||
kotlin("jvm") version "1.7.22"
|
||||
}
|
||||
|
||||
// ./gradlew
|
||||
|
@ -20,15 +20,15 @@ defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
|||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
testImplementation("org.testng:testng:7.3.0")
|
||||
testImplementation("org.testng:testng:7.9.0")
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "com.example.MainKt"
|
||||
mainClass.set("com.example.MainKt")
|
||||
// project.afterEvaluate {
|
||||
// println("Version: $version")
|
||||
// }
|
||||
|
|
BIN
examples/kotlin/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/kotlin/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
294
examples/kotlin/gradlew
vendored
294
examples/kotlin/gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,67 +17,99 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_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"'
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
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.
|
||||
|
||||
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# 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
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
|
|
31
examples/kotlin/gradlew.bat
vendored
31
examples/kotlin/gradlew.bat
vendored
|
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Mon Nov 09 21:24:16 PST 2020
|
||||
version.buildmeta=20201109212416
|
||||
#Sun Feb 11 19:55:46 PST 2024
|
||||
version.buildmeta=20240211195546
|
||||
version.major=1
|
||||
version.minor=2
|
||||
version.patch=4
|
||||
version.prerelease=beta
|
||||
version.semver=1.2.4-beta+20201109212416
|
||||
version.semver=1.2.4-beta+20240211195546
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "net.thauvin.erik.gradle:semver:1.0.5-beta"
|
||||
}
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'application'
|
||||
id("net.thauvin.erik.gradle.semver") version "1.0.4"
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'application'
|
||||
apply plugin: 'net.thauvin.erik.gradle.semver'
|
||||
defaultTasks 'run'
|
||||
|
||||
mainClassName = 'App'
|
||||
|
||||
|
@ -27,13 +21,12 @@ dependencies {
|
|||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
application {
|
||||
println(project.version)
|
||||
println project.version
|
||||
project.afterEvaluate {
|
||||
println(project.version)
|
||||
println "afterEvaluate: $project.version"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,13 +40,13 @@ incrementBuildMeta {
|
|||
|
||||
run {
|
||||
doFirst {
|
||||
println("Version: $semver.major$semver.separator$semver.minor$semver.separator$semver.patch$semver.preReleasePrefix$semver.preRelease$semver.buildMetaPrefix$semver.buildMeta")
|
||||
println "$semver"
|
||||
args = [f.name]
|
||||
}
|
||||
}
|
||||
|
||||
task echoVersion(type:Exec) {
|
||||
commandLine "echo", "${-> version}"
|
||||
commandLine('echo', "${-> version}")
|
||||
}
|
||||
|
||||
semver {
|
||||
|
|
BIN
examples/test/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/test/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
295
examples/test/gradlew
vendored
295
examples/test/gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,78 +17,111 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_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"'
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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
|
||||
|
@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
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.
|
||||
|
||||
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, 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" ;;
|
||||
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
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
# 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")"
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
|
|
54
examples/test/gradlew.bat
vendored
54
examples/test/gradlew.bat
vendored
|
@ -26,9 +26,13 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
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"
|
||||
|
||||
|
@ -37,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -51,48 +55,36 @@ goto fail
|
|||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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=%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%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%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%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
294
gradlew
vendored
294
gradlew
vendored
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -17,67 +17,99 @@
|
|||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_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"'
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
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.
|
||||
|
||||
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# 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
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# 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" "$@"
|
||||
|
|
31
gradlew.bat
vendored
31
gradlew.bat
vendored
|
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
19
preflightcheck.sh
Normal file → Executable file
19
preflightcheck.sh
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
|||
|
||||
# set source and test locations
|
||||
src="src/main/kotlin/net/thauvin/erik/gradle/semver/"
|
||||
test="src/main/kotlin/net/thauvin/erik/gradle/semver/"
|
||||
test="src/test/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="sonarqube"
|
||||
gradle_sonar=""
|
||||
# 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.3
|
||||
# Version: 1.1.5
|
||||
#
|
||||
|
||||
if [ "$java8" = true ]
|
||||
|
@ -42,7 +42,7 @@ pause() {
|
|||
}
|
||||
|
||||
checkCopyright() {
|
||||
if [ "$(grep -c "$date" "$1")" -eq 0 ]
|
||||
if [ "$(grep -c "$date" "$1")" == "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,9 +165,12 @@ 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
|
||||
done
|
||||
pause
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
plugins {
|
||||
id("com.gradle.enterprise").version("3.3.4")
|
||||
id("com.gradle.enterprise").version("3.6.3")
|
||||
}
|
||||
|
||||
gradleEnterprise {
|
||||
buildScan {
|
||||
link("GitHub", "https://github.com/ethauvin/semver-gradle/tree/master")
|
||||
if ("true" == System.getenv("CI")) {
|
||||
link("GitHub", "https://github.com/ethauvin/semver/tree/master")
|
||||
if (!System.getenv("CI").isNullOrEmpty()) {
|
||||
isUploadInBackground = false
|
||||
publishOnFailure()
|
||||
tag("CI")
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* SemverConfig.kt
|
||||
*
|
||||
* Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -97,27 +97,14 @@ open class SemverConfig @Inject constructor(
|
|||
get() = semVersion.separator
|
||||
|
||||
override fun toString(): String {
|
||||
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'" +
|
||||
')'
|
||||
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')"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* SemverIncrementBuildMetaTask.kt
|
||||
*
|
||||
* Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -58,8 +58,8 @@ open class SemverIncrementBuildMetaTask @Inject constructor(
|
|||
if (version.buildMeta != buildMeta) {
|
||||
version.buildMeta = buildMeta
|
||||
project.version = version.semver
|
||||
logger.lifecycle("Version: ${project.version}")
|
||||
Utils.saveProperties(project.projectDir, config, version)
|
||||
if (logger.isLifecycleEnabled) logger.lifecycle("Version: ${project.version}")
|
||||
saveProperties(project.projectDir, config, version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* SemverIncrementTask.kt
|
||||
*
|
||||
* Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -35,6 +35,7 @@ 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
|
||||
|
@ -45,7 +46,13 @@ open class SemverIncrementTask @Inject constructor(
|
|||
) : DefaultTask() {
|
||||
init {
|
||||
group = "version"
|
||||
description = "Increments ${type.capitalize()} version number."
|
||||
description =
|
||||
"Increments ${
|
||||
type.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(Locale.getDefault())
|
||||
else it.toString()
|
||||
}
|
||||
} version number."
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
|
@ -57,7 +64,7 @@ open class SemverIncrementTask @Inject constructor(
|
|||
isPatch = type == SemverConfig.DEFAULT_PATCH_KEY
|
||||
)
|
||||
project.version = version.semver
|
||||
logger.lifecycle("Version: ${project.version}")
|
||||
Utils.saveProperties(project.projectDir, config, version)
|
||||
if (logger.isLifecycleEnabled) logger.lifecycle("Version: ${project.version}")
|
||||
saveProperties(project.projectDir, config, version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* SemverPlugin.kt
|
||||
*
|
||||
* Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -37,6 +37,7 @@ import org.gradle.api.Plugin
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.util.GradleVersion
|
||||
|
||||
@Suppress("unused")
|
||||
class SemverPlugin : Plugin<Project> {
|
||||
private val simpleName = SemverPlugin::class.simpleName
|
||||
private var version = Version()
|
||||
|
@ -58,9 +59,9 @@ class SemverPlugin : Plugin<Project> {
|
|||
}
|
||||
|
||||
private fun afterEvaluate(project: Project) {
|
||||
val propsFile = Utils.getPropertiesFile(project.projectDir, config.properties)
|
||||
val propsFile = getPropertiesFile(project.projectDir, config.properties)
|
||||
|
||||
if (project.version != "unspecified") {
|
||||
if (project.version != "unspecified" && project.logger.isWarnEnabled) {
|
||||
project.logger.warn(
|
||||
"Please specify the version in ${propsFile.name} and remove it from ${project.buildFile.name}"
|
||||
)
|
||||
|
@ -69,31 +70,37 @@ class SemverPlugin : Plugin<Project> {
|
|||
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()}]"
|
||||
)
|
||||
}
|
||||
|
||||
val props = Utils.loadProperties(this)
|
||||
val props = this.loadProperties()
|
||||
val requiredProps = setOf(
|
||||
config.semverKey, config.majorKey, config.minorKey, config.patchKey,
|
||||
config.preReleaseKey, config.buildMetaKey
|
||||
)
|
||||
val hasReqProps = !isNew && props.stringPropertyNames().containsAll(requiredProps) &&
|
||||
Utils.isNotSystemProperty(requiredProps)
|
||||
requiredProps.isNotSystemProperty()
|
||||
|
||||
Utils.loadVersion(config, version, props)
|
||||
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}")
|
||||
}
|
||||
|
||||
if (!hasReqProps || !isFile) {
|
||||
if (project.logger.isInfoEnabled) {
|
||||
project.logger.info("[$simpleName] Saving version properties to `$absoluteFile`.")
|
||||
Utils.saveProperties(project.projectDir, config, version)
|
||||
}
|
||||
saveProperties(project.projectDir, config, version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* SortedProperties.kt
|
||||
*
|
||||
* Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2018-2022, 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<MutableMap.MutableEntry<Any, Any>>
|
||||
get() = super.entries.sortedWith(Comparator { a, b -> a.toString().compareTo(b.toString()) }).toMutableSet()
|
||||
get() = super.entries.sortedWith { a, b -> a.toString().compareTo(b.toString()) }.toMutableSet()
|
||||
|
||||
override fun keys(): Enumeration<Any> {
|
||||
val keys = Collections.list(super.keys())
|
||||
keys.sortWith(Comparator { a, b -> a.toString().compareTo(b.toString()) })
|
||||
keys.sortWith { a, b -> a.toString().compareTo(b.toString()) }
|
||||
return Collections.enumeration(keys)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,223 +0,0 @@
|
|||
/*
|
||||
* 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 <code>Utils</code> class.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a>
|
||||
* @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<String>): 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Version.kt
|
||||
*
|
||||
* Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2018-2022, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -70,16 +70,5 @@ class Version {
|
|||
if (isPatch) patch++
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Version(" +
|
||||
"major='$major', " +
|
||||
"minor='$minor', " +
|
||||
"patch='$patch', " +
|
||||
"preRelease='$preRelease', " +
|
||||
"preReleasePrefix='$preReleasePrefix', " +
|
||||
"buildMeta='$buildMeta', " +
|
||||
"buildMetaPrefix='$buildMetaPrefix', " +
|
||||
"separator='$separator', " +
|
||||
')'
|
||||
}
|
||||
override fun toString() = semver
|
||||
}
|
||||
|
|
214
src/main/kotlin/net/thauvin/erik/gradle/semver/utils.kt
Normal file
214
src/main/kotlin/net/thauvin/erik/gradle/semver/utils.kt
Normal file
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* 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<String>.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)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* 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<String>
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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")
|
||||
}
|
||||
}
|
|
@ -1,203 +0,0 @@
|
|||
/*
|
||||
* 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* 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<Pair<String, String>>
|
||||
|
||||
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<GradleException>("2.1.1a") {
|
||||
Utils.parseSemVer("2.1.1a", version)
|
||||
}
|
||||
assertFailsWith<GradleException>("2a.1.1") {
|
||||
Utils.parseSemVer("2a.1.1", version)
|
||||
}
|
||||
assertFailsWith<GradleException>("2.1a.1") {
|
||||
Utils.parseSemVer("2.1a.1", version)
|
||||
}
|
||||
assertFailsWith<GradleException>("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<GradleException> {
|
||||
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<GradleException> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
231
src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsTest.kt
Normal file
231
src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsTest.kt
Normal file
|
@ -0,0 +1,231 @@
|
|||
/*
|
||||
* 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<GradleException>("2.1.1a") {
|
||||
parseSemVer("2.1.1a", version)
|
||||
}
|
||||
assertFailsWith<GradleException>("2a.1.1") {
|
||||
parseSemVer("2a.1.1", version)
|
||||
}
|
||||
assertFailsWith<GradleException>("2.1a.1") {
|
||||
parseSemVer("2.1a.1", version)
|
||||
}
|
||||
assertFailsWith<GradleException>("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<GradleException> {
|
||||
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<GradleException> {
|
||||
saveProperties(locked.parentFile, config, version)
|
||||
}
|
||||
}
|
||||
locked.delete()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLoadIntProperty() {
|
||||
val props = SortedProperties()
|
||||
props["foo"] = "bar"
|
||||
|
||||
assertFailsWith<GradleException> { 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)
|
||||
}
|
||||
}
|
||||
}
|
109
src/test/kotlin/net/thauvin/erik/gradle/semver/VersionTest.kt
Normal file
109
src/test/kotlin/net/thauvin/erik/gradle/semver/VersionTest.kt
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* 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")
|
||||
}
|
||||
}
|
21
updatewrappers.sh
Normal file → Executable file
21
updatewrappers.sh
Normal file → Executable file
|
@ -1,8 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
#
|
||||
# Version: 1.0.2
|
||||
# Version: 1.0.3
|
||||
#
|
||||
|
||||
# set the examples directories
|
||||
|
@ -12,7 +11,6 @@ declare -a dirs=(
|
|||
"examples/kotlin"
|
||||
"examples/annotation-processor/java"
|
||||
"examples/annotation-processor/kotlin")
|
||||
java8=true
|
||||
|
||||
###
|
||||
|
||||
|
@ -22,13 +20,6 @@ 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
|
||||
|
@ -39,16 +30,6 @@ updateWrappers() {
|
|||
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..."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue