diff --git a/.circleci/config.yml b/.circleci/config.yml
index 8586151..6c0190e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,3 +1,4 @@
+version: 2
defaults: &defaults
working_directory: ~/repo
docker:
@@ -5,8 +6,7 @@ defaults: &defaults
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
-
-version: 2.0
+ CI: true
jobs:
build_gradle:
@@ -16,7 +16,7 @@ jobs:
- checkout
- restore_cache:
keys:
- - gradle-dependencies-{{ checksum "build.gradle" }}
+ - gradle-dependencies-{{ checksum "build.gradle.kts" }}
# fallback to using the latest cache if no exact match is found
- gradle-dependencies-
@@ -25,12 +25,12 @@ jobs:
command: ./gradlew dependencies
- save_cache:
- paths: ~/.m2
- key: gradle-dependencies-{{ checksum "build.gradle" }}
+ paths: ~/.gradle
+ key: gradle-dependencies-{{ checksum "build.gradle.kts" }}
- run:
name: Run All Checks
- command: ./gradlew check
+ command: ./gradlew check --scan
- store_artifacts:
path: build/reports/
@@ -40,6 +40,6 @@ jobs:
workflows:
version: 2
- build_gradle_and_kobalt:
+ build_gradle:
jobs:
- - build_gradle
\ No newline at end of file
+ - build_gradle
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
new file mode 100644
index 0000000..f1ac387
--- /dev/null
+++ b/.github/workflows/gradle.yml
@@ -0,0 +1,19 @@
+name: Java CI with Gradle
+
+on: [push, pull_request, workflow_dispatch]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v1
+ with:
+ java-version: 1.8
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+ - name: Test with Gradle
+ run: ./gradlew check
diff --git a/.gitignore b/.gitignore
index a440b05..f007981 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,30 +1,84 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.code-workspace
-*.iws
-*.sublime-*
+.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
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
+*.class
+*.code-workspace
+*.ctxt
+*.iws
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.zip
+/**/.idea_modules/
+/**/.idea/**/caches/build_file_checksums.ser
+/**/.idea/**/contentModel.xml
+/**/.idea/**/dataSources.ids
+/**/.idea/**/dataSources.local.xml
+/**/.idea/**/dataSources/
+/**/.idea/**/dbnavigator.xml
+/**/.idea/**/dictionaries
+/**/.idea/**/dynamic.xml
+/**/.idea/**/gradle.xml
+/**/.idea/**/httpRequests
+/**/.idea/**/libraries
+/**/.idea/**/mongoSettings.xml
+/**/.idea/**/replstate.xml
+/**/.idea/**/shelf
+/**/.idea/**/shelf/
+/**/.idea/**/sqlDataSources.xml
+/**/.idea/**/tasks.xml
+/**/.idea/**/uiDesigner.xml
+/**/.idea/**/usage.statistics.xml
+/**/.idea/**/workspace.xml
+/**/.idea/$CACHE_FILE$
+/**/.idea/$PRODUCT_WORKSPACE_FILE$
+atlassian-ide-plugin.xml
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
ehthumbs.db
+fabric.properties
+gen/
+gradle.properties
+hs_err_pid*
kobaltBuild
-Thumbs.db
\ No newline at end of file
+kobaltw*-test
+lib/kotlin*
+libs/
+local.properties
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
+venv
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..26820aa
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,31 @@
+image: gradle:alpine
+
+variables:
+ GRADLE_OPTS: "-Dorg.gradle.daemon=false"
+
+before_script:
+ - export GRADLE_USER_HOME=`pwd`/.gradle
+
+stages:
+ - build
+ - test
+
+build:
+ stage: build
+ script: ./gradlew --build-cache assemble
+ cache:
+ key: "$CI_COMMIT_REF_NAME"
+ policy: push
+ paths:
+ - build
+ - .gradle
+
+test:
+ stage: test
+ script: ./gradlew check
+ cache:
+ key: "$CI_COMMIT_REF_NAME"
+ policy: pull
+ paths:
+ - build
+ - .gradle
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000..95c433c
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 283fcb4..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/Erik_s_Copyright_Notice.xml b/.idea/copyright/Erik_s_Copyright_Notice.xml
index 08660a1..914713f 100644
--- a/.idea/copyright/Erik_s_Copyright_Notice.xml
+++ b/.idea/copyright/Erik_s_Copyright_Notice.xml
@@ -1,6 +1,7 @@
-
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
index 3423376..1607f69 100644
--- a/.idea/copyright/profiles_settings.xml
+++ b/.idea/copyright/profiles_settings.xml
@@ -1,8 +1,7 @@
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..98b5537
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
deleted file mode 100644
index 5806fb3..0000000
--- a/.idea/kotlinc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index de03161..692822a 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,19 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index dac269c..4c5218b 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,29 +2,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor-java.iml b/.idea/modules/annotation-processor-java.iml
deleted file mode 100644
index 008cdb4..0000000
--- a/.idea/modules/annotation-processor-java.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/annotation-processor.iml b/.idea/modules/annotation-processor/annotation-processor.iml
deleted file mode 100644
index 465fff5..0000000
--- a/.idea/modules/annotation-processor/annotation-processor.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/java/annotation-processor-java.iml b/.idea/modules/annotation-processor/java/annotation-processor-java.iml
deleted file mode 100644
index a0a747b..0000000
--- a/.idea/modules/annotation-processor/java/annotation-processor-java.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/java/annotation-processor-java_main.iml b/.idea/modules/annotation-processor/java/annotation-processor-java_main.iml
deleted file mode 100644
index 63956e7..0000000
--- a/.idea/modules/annotation-processor/java/annotation-processor-java_main.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/java/annotation-processor-java_test.iml b/.idea/modules/annotation-processor/java/annotation-processor-java_test.iml
deleted file mode 100644
index 38c2600..0000000
--- a/.idea/modules/annotation-processor/java/annotation-processor-java_test.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin.iml b/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin.iml
deleted file mode 100644
index af6355a..0000000
--- a/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin_main.iml b/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin_main.iml
deleted file mode 100644
index c9f697a..0000000
--- a/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin_main.iml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin_test.iml b/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin_test.iml
deleted file mode 100644
index 4a71ebf..0000000
--- a/.idea/modules/annotation-processor/kotlin/annotation-processor-kotlin_test.iml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/ap-examples-java.iml b/.idea/modules/ap-examples-java.iml
deleted file mode 100644
index d890132..0000000
--- a/.idea/modules/ap-examples-java.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/ap-examples-java_main.iml b/.idea/modules/ap-examples-java_main.iml
deleted file mode 100644
index f0872d0..0000000
--- a/.idea/modules/ap-examples-java_main.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/ap-examples-java_test.iml b/.idea/modules/ap-examples-java_test.iml
deleted file mode 100644
index 1168954..0000000
--- a/.idea/modules/ap-examples-java_test.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/ap-examples-kotlin.iml b/.idea/modules/ap-examples-kotlin.iml
deleted file mode 100644
index 4a799f3..0000000
--- a/.idea/modules/ap-examples-kotlin.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/ap-examples-kotlin_main.iml b/.idea/modules/ap-examples-kotlin_main.iml
deleted file mode 100644
index 9b5da31..0000000
--- a/.idea/modules/ap-examples-kotlin_main.iml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/ap-examples-kotlin_test.iml b/.idea/modules/ap-examples-kotlin_test.iml
deleted file mode 100644
index 93dfa26..0000000
--- a/.idea/modules/ap-examples-kotlin_test.iml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-java.iml b/.idea/modules/examples-java.iml
deleted file mode 100644
index 4a61c8a..0000000
--- a/.idea/modules/examples-java.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-java_main.iml b/.idea/modules/examples-java_main.iml
deleted file mode 100644
index e92db06..0000000
--- a/.idea/modules/examples-java_main.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-java_main~1.iml b/.idea/modules/examples-java_main~1.iml
deleted file mode 100644
index 36c031f..0000000
--- a/.idea/modules/examples-java_main~1.iml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-java_test.iml b/.idea/modules/examples-java_test.iml
deleted file mode 100644
index 569706d..0000000
--- a/.idea/modules/examples-java_test.iml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-java_test~1.iml b/.idea/modules/examples-java_test~1.iml
deleted file mode 100644
index 0f58715..0000000
--- a/.idea/modules/examples-java_test~1.iml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-kotlin.iml b/.idea/modules/examples-kotlin.iml
deleted file mode 100644
index a9f4b89..0000000
--- a/.idea/modules/examples-kotlin.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-kotlin_main.iml b/.idea/modules/examples-kotlin_main.iml
deleted file mode 100644
index 9b8f986..0000000
--- a/.idea/modules/examples-kotlin_main.iml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples-kotlin_test.iml b/.idea/modules/examples-kotlin_test.iml
deleted file mode 100644
index 775c9ac..0000000
--- a/.idea/modules/examples-kotlin_test.iml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/examples.iml b/.idea/modules/examples.iml
deleted file mode 100644
index 455d728..0000000
--- a/.idea/modules/examples.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/semver_main.iml b/.idea/modules/semver_main.iml
deleted file mode 100644
index 41fc643..0000000
--- a/.idea/modules/semver_main.iml
+++ /dev/null
@@ -1,313 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/semver_test.iml b/.idea/modules/semver_test.iml
deleted file mode 100644
index 76d5b1b..0000000
--- a/.idea/modules/semver_test.iml
+++ /dev/null
@@ -1,298 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/scopes/Copyright.xml b/.idea/scopes/Copyright.xml
new file mode 100644
index 0000000..5acbcdb
--- /dev/null
+++ b/.idea/scopes/Copyright.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/Sources.xml b/.idea/scopes/Sources.xml
deleted file mode 100644
index 73614ea..0000000
--- a/.idea/scopes/Sources.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 8306744..94a25f7 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,7 +1,6 @@
-
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4a40469
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,30 @@
+language: java
+dist: trusty
+
+jdk:
+ - oraclejdk8
+
+addons:
+ sonarcloud:
+ organization: "ethauvin-github"
+
+before_cache:
+ - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
+ - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
+
+before_install:
+ - chmod +x gradlew
+
+script:
+ - ./gradlew check --scan
+
+cache:
+ directories:
+ - $HOME/.gradle/caches/
+ - $HOME/.gradle/wrapper/
+
+after_success:
+ - |
+ if [ "${TRAVIS_TEST_RESULT}" == 0 ]; then
+ ./gradlew sonarqube
+ fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..14c8942
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,68 @@
+# Change Log
+
+## [1.0.4](https://github.com/ethauvin/semver-gradle/tree/1.0.4) (2019-07-26)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/1.0.3-beta...1.0.4)
+
+**Implemented enhancements:**
+
+- Access semver version properties in Gradle build file. [\#8](https://github.com/ethauvin/semver-gradle/issues/8)
+
+## [1.0.3-beta](https://github.com/ethauvin/semver-gradle/tree/1.0.3-beta) (2019-07-25)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/1.0.2...1.0.3-beta)
+
+**Closed issues:**
+
+- Thanks! [\#7](https://github.com/ethauvin/semver-gradle/issues/7)
+
+## [1.0.2](https://github.com/ethauvin/semver-gradle/tree/1.0.2) (2019-05-24)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/1.0.1...1.0.2)
+
+**Implemented enhancements:**
+
+- version.properties write issue when using NetBeans on Windows. [\#6](https://github.com/ethauvin/semver-gradle/issues/6)
+
+## [1.0.1](https://github.com/ethauvin/semver-gradle/tree/1.0.1) (2019-05-24)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/1.0.0...1.0.1)
+
+## [1.0.0](https://github.com/ethauvin/semver-gradle/tree/1.0.0) (2019-04-23)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.9-beta...1.0.0)
+
+**Implemented enhancements:**
+
+- Optionally save version properties [\#1](https://github.com/ethauvin/semver-gradle/issues/1)
+- Set prerelease from commandline [\#3](https://github.com/ethauvin/semver-gradle/issues/3)
+
+**Merged pull requests:**
+
+- Extended existing tests to include semver property [\#5](https://github.com/ethauvin/semver-gradle/pull/5) ([rveede](https://github.com/rveede))
+- Include full semver version in version.properties [\#4](https://github.com/ethauvin/semver-gradle/pull/4) ([rveede](https://github.com/rveede))
+
+## [0.9.9-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.9-beta) (2018-12-20)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.8-beta...0.9.9-beta)
+
+**Merged pull requests:**
+
+- Add option for disabling saves every project evaluation [\#2](https://github.com/ethauvin/semver-gradle/pull/2) ([lewismorgan](https://github.com/lewismorgan))
+
+## [0.9.8-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.8-beta) (2018-07-14)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.7-beta...0.9.8-beta)
+
+## [0.9.7-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.7-beta) (2018-07-13)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.6-beta...0.9.7-beta)
+
+## [0.9.6-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.6-beta) (2018-07-10)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.5-beta...0.9.6-beta)
+
+## [0.9.5-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.5-beta) (2018-07-07)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.4-beta...0.9.5-beta)
+
+## [0.9.4-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.4-beta) (2018-07-03)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.3-beta...0.9.4-beta)
+
+## [0.9.3-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.3-beta) (2018-07-02)
+[Full Changelog](https://github.com/ethauvin/semver-gradle/compare/0.9.2-beta...0.9.3-beta)
+
+## [0.9.2-beta](https://github.com/ethauvin/semver-gradle/tree/0.9.2-beta) (2018-07-01)
+
+
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\ No newline at end of file
diff --git a/LICENSE.TXT b/LICENSE.TXT
index b7ddd7f..7345551 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -1,4 +1,4 @@
-Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -24,4 +24,4 @@ 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.
\ No newline at end of file
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
index 13d9a37..681d9b4 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-[](http://opensource.org/licenses/BSD-3-Clause) [](https://circleci.com/gh/ethauvin/semver-gradle/tree/master)
+[](http://opensource.org/licenses/BSD-3-Clause) [](https://sonarcloud.io/dashboard?id=ethauvin_semver-gradle) [](https://travis-ci.com/ethauvin/semver-gradle) [](https://circleci.com/gh/ethauvin/semver-gradle/tree/master) [](https://plugins.gradle.org/plugin/net.thauvin.erik.gradle.semver)
# Semantic Version Plugin for Gradle
-A [Semantic Version](https://semver.org) Plugin for [Gradle](https://gradle.org) that manages a project version via a properties file, and provide tasks to __automatically increment__ major, minor and patch build numbers.
+A [Semantic Version](https://semver.org) Plugin for [Gradle](https://gradle.org) that manages a project version via a properties file, and provide tasks to __automatically increment__ major, minor, patch and build version numbers.
The plugin can be used in conjunction with the [__Semantic Version Annotation Processor__](https://github.com/ethauvin/semver).
@@ -21,9 +21,10 @@ version.minor=0
version.patch=0
version.prerelease=
version.buildmeta=
+version.semver=1.0.0
```
-To change the version of your project, remove the version from your `build.gradle` and simply edit your the version properties file to match your version number.
+To change the version of your project, remove the version from `build.gradle` and simply edit the version properties file to match your version number.
- __Examples__: [Java](https://github.com/ethauvin/semver-gradle/tree/master/examples/java), [Kotlin](https://github.com/ethauvin/semver-gradle/tree/master/examples/kotlin)
@@ -31,6 +32,8 @@ If you need to change the properties file or name of the properties keys to matc
## Increment Version Tasks
+### incrementMajor, incrementMinor and incrementPatch
+
The `incrementMajor`, `incrementMinor` and `incrementPatch` tasks are available to automatically increment their respective and reset lower counterpart version numbers.
- `incrementMajor` will increment the `major` and set the `minor` and `patch` versions to `0`.
@@ -53,6 +56,79 @@ someTask {
- __Examples__: [Java](https://github.com/ethauvin/semver-gradle/tree/master/examples/java), [Kotlin](https://github.com/ethauvin/semver-gradle/tree/master/examples/kotlin)
+### incrementBuildMeta
+
+The `incrementBuildMeta` task is available to set the build metadata version to a custom calculated value.
+
+#### Examples:
+
+To set the build metadata to a custom formatted date:
+
+```gradle
+incrementBuildMeta {
+ doFirst {
+ buildMeta = new Date().format("yyyyMMddHHmmss")
+ }
+}
+```
+
+```bash
+./gradlew incrementBuildMeta
+
+...
+
+> Task :incrementBuildMeta
+Version: 1.0.16-beta+20180713143416
+```
+
+Or to set the build metadata to a custom formatted number with increment:
+
+
+```gradle
+incrementBuildMeta {
+ doFirst {
+ buildMeta = sprintf("%03d", (buildMeta as Integer) + 1)
+ }
+}
+```
+
+```bash
+./gradlew incrementBuildMeta
+
+...
+
+> Task :incrementBuildMeta
+Version: 1.0.16-beta+002
+```
+
+- __Examples__: [Java](https://github.com/ethauvin/semver-gradle/tree/master/examples/java), [Kotlin](https://github.com/ethauvin/semver-gradle/tree/master/examples/kotlin)
+
+## Command Line
+
+The `major`, `minor`, `patch`, `prerelease` and `buildmeta` versions can also be set via the command line:
+
+```bash
+./gradlew -Dversion.prerelease=beta -Dversion.buildmeta= ...
+```
+
+```ini
+#version.properties
+version.major=1
+version.minor=0
+version.patch=0
+version.prerelease=beta
+version.buildmeta=
+version.semver=1.0.0-beta
+```
+
+The full semantic version can also be specified via the `semver` property:
+
+```sh
+./gradlew -Dversion.semver=1.0.0-beta ...
+```
+
+If a version cannot be parsed your build will **fail**.
+
## Configuration
### Version File Properties
@@ -65,15 +141,17 @@ Property | Description | Default
`version.minor` | The minor version. | `0`
`version.patch` | The patch version. | `0`
`version.prerelease` | The pre-release version |
-`version.buildmeta` | The build metatdata version |
`version.prerelease.prefix` | The pre-release prefix | `-`
+`version.buildmeta` | The build metatdata version |
`version.buildmeta.prefix` | The build metadata prefix | `+`
`version.separator` | The version separator. | `.`
The version number is built as follows:
-`version.major` `version.separtor` `version.minor` `version.separator` `[` `version.prerelease.prefix` `version.prerelease` `]` `[` `version.prerelease.prefix` `version.buildmeta` `]`
+`version.major` `version.separator` `version.minor` `version.separator` `version.patch` `[` `version.prerelease.prefix` `version.prerelease` `]` `[` `version.prerelease.prefix` `version.buildmeta` `]`
+
+For reference, it is automatically included in the `version.semver` property.
for example:
@@ -84,6 +162,7 @@ version.minor=0
version.patch=0
version.prerelease=beta
version.buildmeta=exp.sha.5114f85
+version.semver=1.0.0-beta+exp.sha.5114f85
```
`project.version` will be `1.0.0-beta+exp.sha.5114f85` in Gradle.
@@ -108,6 +187,7 @@ or using different property keys for the version data:
```gradle
semver {
keysPrefix = "" // no prefix
+ semverKey = "version"
majorKey = "maj"
minorKey = "min"
patchKey = "build"
@@ -124,21 +204,23 @@ min=0
build=0
rel=beta
meta=
+version=1.0.0-beta
```
The following `semver` properties are available:
Property | Description | Default
-:---------------------|:----------------------------------------|:------------------------
+:---------------------|:----------------------------------------|:---------------------------
`properties` | The properties file. | `version.properties`
-`majorKey` | The major property key. | `major`
-`minorKey` | The minor property key. | `minor`
-`patchKey` | The patch property key. | `patch`
-`preReleaseKey` | The pre-release property key. | `preRelease`
-`preReleasePrefixKey` | The build pre-release prefix key. | `preReleasePrefix`
-`buildMetaKey` | The build metadata property key. | `buildMeta`
-`buildMetaPrefixKey` | The build metadata prefix property key. | `buildMetaPrefix`
-`separatorKey` | The separator property key. | `separator`
+`semverKey` | The semver property key. | `version.semver`
+`majorKey` | The major property key. | `version.major`
+`minorKey` | The minor property key. | `version.minor`
+`patchKey` | The patch property key. | `version.patch`
+`preReleaseKey` | The pre-release property key. | `version.prerelease`
+`preReleasePrefixKey` | The build pre-release prefix key. | `version.prerelease.prefix`
+`buildMetaKey` | The build metadata property key. | `version.buildmeta`
+`buildMetaPrefixKey` | The build metadata prefix property key. | `version.buildmeta.prefix`
+`separatorKey` | The separator property key. | `version.separator`
`keysPrefix` | The prefix for all property keys. | `version.`
In order to quickly support multiple projects. The `keysPrefix` property is available to set all properties keys prefixes at once:
@@ -157,12 +239,64 @@ test.minor=0
test.patch=0
test.prerelease=
test.buildmeta=
+test.semver=1.0.0
```
- __Examples__: [Java](https://github.com/ethauvin/semver-gradle/tree/master/examples/java), [Kotlin](https://github.com/ethauvin/semver-gradle/tree/master/examples/kotlin)
+### Semver Extension Properties
+
+The values stored in the version properties file can individually be accessed using the `semver` extension, for example:
+
+```gradle
+ fooTask {
+ doFirst {
+ println "Build: $semver.buildMeta"
+ }
+ }
+```
+
+The semver extension properties are:
+
+Property | Description
+:-------------------------|:----------------------------
+`semver.semver` | The full semantic version.
+`semver.version` | Same as `semver.semver`.
+`semver.major` | The major version.
+`semver.minor` | The minor version.
+`semver.patch` | The patch version.
+`semver.preRelease` | The pre-release version
+`semver.preReleasePrefix` | The pre-release prefix
+`semver.buildMeta` | The build metatdata version
+`semver.buildMetaPrefix` | The build metadata prefix
+`semver.separator` | The version separator.
+
+## Version is "unspecified"
+
+This is a common problem stemming from the configuration and build phases in Gradle.
+
+It is always preferable to access to version during the execution stage, in a `doFirst` or `doLast` closure within your tasks:
+
+```gradle
+task foo() {
+ doFirst {
+ println project.version
+ }
+}
+```
+
+or if absolutely necessary, at the end of the configuration stage in a `project.afterEvaluate` block:
+
+```gradle
+foo {
+ project.afterEvaluate {
+ println project.version
+ }
+}
+```
+
## Source Code Generation
If you'd like to incorporate the version number data into your source code, please have a look at the [__Semantic Version Annotation Processor__](https://github.com/ethauvin/semver).
-There are also full [examples](https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor) in both [Java](https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/java) and [Kotlin](https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor) showing how to use both the plugin and annotation processor concurrently.
\ No newline at end of file
+There are also full [examples](https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor) in both [Java](https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/java) and [Kotlin](https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/kotlin) showing how to use both the plugin and annotation processor concurrently.
diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml
new file mode 100644
index 0000000..7d98402
--- /dev/null
+++ b/bitbucket-pipelines.yml
@@ -0,0 +1,9 @@
+image: openjdk:8
+
+pipelines:
+ default:
+ - step:
+ caches:
+ - gradle
+ script:
+ - bash ./gradlew check
diff --git a/build.gradle.kts b/build.gradle.kts
index 92c0cd6..5d51035 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,45 +1,44 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
- `kotlin-dsl`
`java-gradle-plugin`
`maven-publish`
- id("com.gradle.plugin-publish") version "0.9.10"
- id("com.github.ben-manes.versions") version "0.20.0"
- id("org.jlleitschuh.gradle.ktlint") version "4.1.0"
+ jacoco
+ kotlin("jvm") version "1.3.72"
+ id("com.github.ben-manes.versions") version "0.36.0"
+ id("com.gradle.plugin-publish") version "0.12.0"
+ id("io.gitlab.arturbosch.detekt") version "1.14.2"
+ id("org.gradle.kotlin.kotlin-dsl") version "1.3.6"
+ id("org.sonarqube") version "3.0"
}
-version = "0.9.4-beta"
+version = "1.0.5-beta"
group = "net.thauvin.erik.gradle"
-var github = "https://github.com/ethauvin/semver-gradle"
-var packageName = "net.thauvin.erik.gradle.semver"
+object VersionInfo {
+ const val spek = "2.0.13"
+}
+val versions: VersionInfo by extra { VersionInfo }
-var spekVersion = "1.1.5"
+val github = "https://github.com/ethauvin/semver-gradle"
+val packageName = "net.thauvin.erik.gradle.semver"
repositories {
jcenter()
}
dependencies {
- compile(gradleApi())
+ implementation(gradleApi())
+ implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
+ implementation(kotlin("stdlib"))
testImplementation(kotlin("reflect"))
testImplementation(kotlin("test"))
+
testImplementation(gradleTestKit())
- testImplementation("org.jetbrains.spek:spek-api:$spekVersion") {
- exclude(group = "org.jetbrains.kotlin")
- }
-
- testRuntimeOnly("org.jetbrains.spek:spek-junit-platform-engine:$spekVersion") {
- exclude(group = "org.jetbrains.kotlin")
- exclude(group = "org.junit.platform")
- }
-
- testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.2.0") {
- because("Needed to run tests IDEs that bundle an older version")
- }
+ testImplementation("org.spekframework.spek2:spek-dsl-jvm:${versions.spek}")
+ testRuntimeOnly("org.spekframework.spek2:spek-runner-junit5:${versions.spek}")
}
tasks {
@@ -51,19 +50,42 @@ tasks {
withType {
useJUnitPlatform {
- includeEngines("spek")
+ includeEngines("spek2")
}
}
- val check by getting {
- dependsOn("ktlintCheck")
+ withType {
+ reports {
+ html.isEnabled = true
+ xml.isEnabled = true
+ }
+ }
+
+ "sonarqube" {
+ dependsOn("jacocoTestReport")
+ }
+}
+
+detekt {
+ // input = files("src/main/kotlin", "src/test/kotlin")
+ // filters = ".*/resources/.*,.*/build/.*"
+ 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 {
- (plugins) {
- project.name {
+ plugins {
+ create(project.name) {
id = packageName
+ displayName = "SemVer Plugin"
+ description = "Semantic Version Plugin for Gradle"
implementationClass = "$packageName.SemverPlugin"
}
}
@@ -72,18 +94,9 @@ gradlePlugin {
pluginBundle {
website = github
vcsUrl = github
- description = "Semantic Version Plugin for Gradle"
tags = listOf("semver", "semantic", "version", "versioning", "auto-increment", "kotlin", "java")
-
- (plugins) {
- project.name {
- id = packageName
- displayName = project.name
- }
- }
-
mavenCoordinates {
groupId = project.group.toString()
artifactId = project.name
}
-}
\ No newline at end of file
+}
diff --git a/detekt-baseline.xml b/detekt-baseline.xml
new file mode 100644
index 0000000..52cc674
--- /dev/null
+++ b/detekt-baseline.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ MagicNumber:Utils.kt$Utils$3
+ MagicNumber:Utils.kt$Utils$4
+ MagicNumber:Utils.kt$Utils$5
+ NestedBlockDepth:Utils.kt$Utils$fun loadProperties(file: File): Properties
+ NestedBlockDepth:Utils.kt$Utils$fun parseSemVer(input: String?, version: Version): Boolean
+ NestedBlockDepth:Utils.kt$Utils$fun saveProperties(projectDir: File, config: SemverConfig, version: Version)
+
+
diff --git a/examples/annotation-processor/java/.editorconfig b/examples/annotation-processor/java/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/examples/annotation-processor/java/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/examples/annotation-processor/java/.gitignore b/examples/annotation-processor/java/.gitignore
index 6322c7f..a78c5c2 100644
--- a/examples/annotation-processor/java/.gitignore
+++ b/examples/annotation-processor/java/.gitignore
@@ -1,29 +1,82 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.sublime-*
-*.iws
+!.vscode/extensions.json
+!.vscode/launch.json
+!.vscode/settings.json
+!.vscode/tasks.json
+!gradle-wrapper.jar
.classpath
.DS_Store
.gradle
+.history
+.idea_modules/
+.idea/**/contentModel.xml
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/dataSources/
+.idea/**/dbnavigator.xml
+.idea/**/dictionaries
+.idea/**/dynamic.xml
+.idea/**/gradle.xml
+.idea/**/libraries
+.idea/**/mongoSettings.xml
+.idea/**/shelf
+.idea/**/sqlDataSources.xml
+.idea/**/tasks.xml
+.idea/**/uiDesigner.xml
+.idea/**/usage.statistics.xml
+.idea/**/workspace.xml
+.idea/caches/build_file_checksums.ser
+.idea/httpRequests
+.idea/replstate.xml
.kobalt
+.mtj.tmp/
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
.nb-gradle
.project
+.scannerwork
.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
+.vscode/*
+*.class
+*.code-workspace
+*.ctxt
+*.ear
+*.iws
+*.jar
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.war
+*.zip
+atlassian-ide-plugin.xml
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
ehthumbs.db
+fabric.properties
+gen/
+gradle.properties
+hs_err_pid*
kobaltBuild
-Thumbs.db
\ No newline at end of file
+kobaltw*-test
+lib/kotlin*
+libs/
+local.properties
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
diff --git a/examples/annotation-processor/java/.idea/compiler.xml b/examples/annotation-processor/java/.idea/compiler.xml
new file mode 100644
index 0000000..cb1142d
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/compiler.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/.idea/encodings.xml b/examples/annotation-processor/java/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/.idea/inspectionProfiles/Project_Default.xml b/examples/annotation-processor/java/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8ff795e
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/.idea/misc.xml b/examples/annotation-processor/java/.idea/misc.xml
new file mode 100644
index 0000000..db06c18
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/.idea/modules.xml b/examples/annotation-processor/java/.idea/modules.xml
new file mode 100644
index 0000000..7cd1f26
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/semver.iml b/examples/annotation-processor/java/.idea/modules/ap-examples-java.iml
similarity index 62%
rename from .idea/modules/semver.iml
rename to examples/annotation-processor/java/.idea/modules/ap-examples-java.iml
index 41ae9a8..57e5b58 100644
--- a/.idea/modules/semver.iml
+++ b/examples/annotation-processor/java/.idea/modules/ap-examples-java.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/examples/annotation-processor/java/.idea/modules/ap-examples-java.main.iml b/examples/annotation-processor/java/.idea/modules/ap-examples-java.main.iml
new file mode 100644
index 0000000..c65ff83
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/modules/ap-examples-java.main.iml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/.idea/modules/ap-examples-java.test.iml b/examples/annotation-processor/java/.idea/modules/ap-examples-java.test.iml
new file mode 100644
index 0000000..e3e8de5
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/modules/ap-examples-java.test.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/.idea/vcs.xml b/examples/annotation-processor/java/.idea/vcs.xml
new file mode 100644
index 0000000..c2365ab
--- /dev/null
+++ b/examples/annotation-processor/java/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/java/build.gradle b/examples/annotation-processor/java/build.gradle
index 1ccb9c8..b343869 100644
--- a/examples/annotation-processor/java/build.gradle
+++ b/examples/annotation-processor/java/build.gradle
@@ -1,7 +1,8 @@
plugins {
id 'java'
id 'application'
- id "net.thauvin.erik.gradle.semver" version "0.9.4-beta"
+ id 'net.thauvin.erik.gradle.semver' version '1.0.4'
+ id 'com.github.ben-manes.versions' version '0.28.0'
}
// ./gradlew
@@ -13,13 +14,16 @@ mainClassName = 'com.example.Example'
defaultTasks 'run'
-compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated")
-
-def semverProcessor = "net.thauvin.erik:semver:1.1.0-beta"
+def semverProcessor = "net.thauvin.erik:semver:1.2.0"
dependencies {
annotationProcessor semverProcessor
- compileOnly semverProcessor
+ implementation semverProcessor
+}
+
+tasks.withType(JavaCompile) {
+ options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
+ options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
}
repositories {
@@ -27,6 +31,15 @@ repositories {
jcenter()
}
+run {
+ doFirst {
+ println "Version: $version"
+ }
+
+// args = ['example.properties']
+ args = ['version.properties']
+}
+
semver {
// properties = "example.properties"
// keysPrefix = "example."
diff --git a/examples/annotation-processor/java/example.properties b/examples/annotation-processor/java/example.properties
index 11e4b78..ef37d26 100644
--- a/examples/annotation-processor/java/example.properties
+++ b/examples/annotation-processor/java/example.properties
@@ -1,7 +1,7 @@
#Generated by the Semver Plugin for Gradle
-#Sun Jul 01 20:13:31 PDT 2018
+#Thu Nov 01 18:52:23 PDT 2018
example.major=1
-example.release=
example.meta=
example.minor=0
example.patch=0
+example.release=
diff --git a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar
index 758de96..f3d88b1 100644
Binary files a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar and b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties
index 2d80b69..a2bf131 100644
--- a/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/annotation-processor/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/annotation-processor/java/gradlew b/examples/annotation-processor/java/gradlew
old mode 100644
new mode 100755
index cccdd3d..2fe81a7
--- a/examples/annotation-processor/java/gradlew
+++ b/examples/annotation-processor/java/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ 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=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -109,8 +125,8 @@ 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
+# 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"`
@@ -138,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# 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"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/examples/annotation-processor/java/gradlew.bat b/examples/annotation-processor/java/gradlew.bat
index f955316..62bd9b9 100644
--- a/examples/annotation-processor/java/gradlew.bat
+++ b/examples/annotation-processor/java/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
diff --git a/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java b/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java
deleted file mode 100644
index cce75d1..0000000
--- a/examples/annotation-processor/java/src/generated/com/example/GeneratedVersion.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * This file is automatically generated.
- * Do not modify! -- ALL CHANGES WILL BE ERASED!
- */
-package com.example;
-
-import java.util.Date;
-
-/**
- * Provides semantic version information.
- *
- * @author Semantic Version Annotation Processor
- */
-public final class GeneratedVersion {
- public final static String PRERELEASE_PREFIX = "-";
- public final static String BUILDMETA_PREFIX = "+";
-
- public final static String PROJECT = "";
- public final static Date BUILDDATE = new Date(1530571116045L);
- public final static int MAJOR = 1;
- public final static int MINOR = 1;
- public final static int PATCH = 0;
- public final static String PRERELEASE = "";
- public final static String BUILDMETA = "";
-
- /**
- * The full version string.
- *
- * Formatted as:
- *
- * MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]
- *
- *
- * For example:
- *
- * 1.0.0
- * 1.0.0-beta
- * 1.0.0+20160124144700
- * 1.0.0-alpha+001
- *
- */
- public final static String VERSION = Integer.toString(MAJOR) + '.'
- + Integer.toString(MINOR) + '.'
- + Integer.toString(PATCH)
- + preReleaseWithPrefix() + buildMetaWithPrefix();
-
- /**
- * Disables the default constructor.
- *
- * @throws UnsupportedOperationException If the constructor is called.
- */
- private GeneratedVersion()
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Illegal constructor call.");
- }
-
- /**
- * Returns the build metadata with {@value #BUILDMETA_PREFIX} prefix.
- *
- * @return The build metadata, if any.
- */
- public static String buildMetaWithPrefix() {
- return buildMetaWithPrefix(BUILDMETA_PREFIX);
- }
-
- /**
- * Returns the build metadata.
- *
- * @param prefix Prefix to prepend.
- * @return The build metadata, if any.
- */
- public static String buildMetaWithPrefix(final String prefix) {
- if (BUILDMETA.length() > 0 && prefix.length() > 0) {
- return prefix + BUILDMETA;
- } else {
- return BUILDMETA;
- }
- }
-
- /**
- * Returns the pre-release version with {@value #PRERELEASE_PREFIX} prefix.
- *
- * @return The pre-release version, if any.
- */
- public static String preReleaseWithPrefix() {
- return preReleaseWithPrefix(PRERELEASE_PREFIX);
- }
-
- /**
- * Returns the pre-release version.
- *
- * @param prefix The prefix to prepend.
- * @return The pre-release version, if any.
- */
- public static String preReleaseWithPrefix(final String prefix) {
- if (PRERELEASE.length() > 0 && prefix.length() > 0) {
- return prefix + PRERELEASE;
- } else {
- return PRERELEASE;
- }
- }
-}
\ No newline at end of file
diff --git a/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java b/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java
new file mode 100644
index 0000000..5010897
--- /dev/null
+++ b/examples/annotation-processor/java/src/generated/java/com/example/GeneratedVersion.java
@@ -0,0 +1,34 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package com.example;
+
+import java.util.Date;
+
+/**
+ * Provides semantic version information.
+ *
+ * @author Semantic Version Annotation Processor
+ */
+public final class GeneratedVersion {
+ public static final String PROJECT = "Java Example";
+ public static final Date BUILDDATE = new Date(1564027571537L);
+ public static final int MAJOR = 2;
+ public static final int MINOR = 10;
+ public static final int PATCH = 0;
+ public static final String PRERELEASE = "";
+ public static final String PRERELEASE_PREFIX = "-";
+ public static final String BUILDMETA = "";
+ public static final String BUILDMETA_PREFIX = "+";
+ public static final String SEPARATOR = ".";
+ public static final String VERSION = "2.10.0";
+
+ /**
+ * Disables the default constructor.
+ */
+ private GeneratedVersion() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
+}
diff --git a/examples/annotation-processor/java/src/main/java/com/example/Example.java b/examples/annotation-processor/java/src/main/java/com/example/Example.java
index 6992ac9..723f398 100644
--- a/examples/annotation-processor/java/src/main/java/com/example/Example.java
+++ b/examples/annotation-processor/java/src/main/java/com/example/Example.java
@@ -2,6 +2,12 @@ package com.example;
import net.thauvin.erik.semver.Version;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
import java.text.SimpleDateFormat;
@Version(properties = "version.properties")
@@ -11,12 +17,12 @@ import java.text.SimpleDateFormat;
// preReleaseKey = "release",
// buildMetaKey = "meta")
public class Example {
- public static void main(final String... args) {
+ public static void main(String... args) throws IOException {
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
System.out.println("-----------------------------------------------------");
- System.out.println(" Version:" + GeneratedVersion.PROJECT + ' ' + GeneratedVersion.VERSION);
+ System.out.println(" Version: " + GeneratedVersion.PROJECT + ' ' + GeneratedVersion.VERSION);
System.out.println(" Built on: " + sdf.format(GeneratedVersion.BUILDDATE));
System.out.println(" Major: " + GeneratedVersion.MAJOR);
@@ -26,5 +32,16 @@ public class Example {
System.out.println(" BuildMetaData: " + GeneratedVersion.BUILDMETA);
System.out.println("-----------------------------------------------------");
+
+ if (args.length == 1) {
+ final Path path = Paths.get(args[0]);
+ if (Files.exists(path)) {
+ final List content = Files.readAllLines(path);
+ System.out.println("> cat " + path.getFileName());
+ for (final String line : content) {
+ System.out.println(line);
+ }
+ }
+ }
}
}
diff --git a/examples/annotation-processor/java/src/test/java/AppTest.java b/examples/annotation-processor/java/src/test/java/AppTest.java
deleted file mode 100644
index 6cf97a2..0000000
--- a/examples/annotation-processor/java/src/test/java/AppTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-class AppTest {
- @Test
- void testAppHasAGreeting() {
- App classUnderTest = new App();
- assertNotNull("app should have a greeting", classUnderTest.getGreeting());
- }
-}
diff --git a/examples/annotation-processor/java/version.properties b/examples/annotation-processor/java/version.properties
index e430d9a..fc54733 100644
--- a/examples/annotation-processor/java/version.properties
+++ b/examples/annotation-processor/java/version.properties
@@ -1,7 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 12:23:13 PDT 2018
-version.prerelease=
-version.minor=0
+#Wed Jul 24 21:06:09 PDT 2019
version.buildmeta=
-version.patch=0
version.major=2
+version.minor=10
+version.patch=0
+version.prerelease=
+version.project=Java Example
+version.semver=2.10.0
diff --git a/examples/annotation-processor/kotlin/.editorconfig b/examples/annotation-processor/kotlin/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/examples/annotation-processor/kotlin/.gitignore b/examples/annotation-processor/kotlin/.gitignore
index 32fe2fe..638960b 100644
--- a/examples/annotation-processor/kotlin/.gitignore
+++ b/examples/annotation-processor/kotlin/.gitignore
@@ -1,32 +1,81 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.iws
-*.sublime-*
+!.vscode/extensions.json
+!.vscode/launch.json
+!.vscode/settings.json
+!.vscode/tasks.json
+!gradle-wrapper.jar
.classpath
.DS_Store
.gradle
+.history
+.idea_modules/
+.idea/**/contentModel.xml
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/dataSources/
+.idea/**/dbnavigator.xml
+.idea/**/dictionaries
+.idea/**/dynamic.xml
+.idea/**/gradle.xml
+.idea/**/libraries
+.idea/**/mongoSettings.xml
+.idea/**/shelf
+.idea/**/sqlDataSources.xml
+.idea/**/tasks.xml
+.idea/**/uiDesigner.xml
+.idea/**/usage.statistics.xml
+.idea/**/workspace.xml
+.idea/caches/build_file_checksums.ser
+.idea/httpRequests
+.idea/replstate.xml
.kobalt
+.mtj.tmp/
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
.nb-gradle
.project
+.scannerwork
.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/lib/kotlin*
-/libs
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
+.vscode/*
+*.class
+*.code-workspace
+*.ctxt
+*.ear
+*.iws
+*.jar
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.war
+*.zip
+atlassian-ide-plugin.xml
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
ehthumbs.db
+fabric.properties
+gen/
+hs_err_pid*
kobaltBuild
kobaltw*-test
-Thumbs.db
\ No newline at end of file
+lib/kotlin*
+libs/
+local.properties
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
diff --git a/examples/annotation-processor/kotlin/.idea/compiler.xml b/examples/annotation-processor/kotlin/.idea/compiler.xml
new file mode 100644
index 0000000..0974d2a
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/compiler.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/encodings.xml b/examples/annotation-processor/kotlin/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/inspectionProfiles/Project_Default.xml b/examples/annotation-processor/kotlin/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8ff795e
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/misc.xml b/examples/annotation-processor/kotlin/.idea/misc.xml
new file mode 100644
index 0000000..db06c18
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/modules.xml b/examples/annotation-processor/kotlin/.idea/modules.xml
new file mode 100644
index 0000000..3b646e0
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.iml b/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.iml
new file mode 100644
index 0000000..d89813c
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.main.iml b/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.main.iml
new file mode 100644
index 0000000..4a6974e
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.main.iml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.test.iml b/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.test.iml
new file mode 100644
index 0000000..0ab49b9
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/modules/ap-examples-kotlin.test.iml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/.idea/vcs.xml b/examples/annotation-processor/kotlin/.idea/vcs.xml
new file mode 100644
index 0000000..c2365ab
--- /dev/null
+++ b/examples/annotation-processor/kotlin/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/annotation-processor/kotlin/build.gradle.kts b/examples/annotation-processor/kotlin/build.gradle.kts
index b17889a..78cd80b 100644
--- a/examples/annotation-processor/kotlin/build.gradle.kts
+++ b/examples/annotation-processor/kotlin/build.gradle.kts
@@ -1,10 +1,9 @@
-import net.thauvin.erik.gradle.semver.SemverConfig
-
plugins {
- kotlin("jvm") version "1.2.50"
+ kotlin("jvm").version("1.3.61")
application
- id("org.jetbrains.kotlin.kapt") version "1.2.50"
- id("net.thauvin.erik.gradle.semver") version "0.9.4-beta"
+ id("org.jetbrains.kotlin.kapt").version("1.3.61")
+ id("net.thauvin.erik.gradle.semver").version("1.0.4")
+ id("com.github.ben-manes.versions").version("0.28.0")
}
// ./gradlew
@@ -14,13 +13,13 @@ plugins {
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
-var semverProcessor = "net.thauvin.erik:semver:1.1.0-beta"
+var semverProcessor = "net.thauvin.erik:semver:1.2.0"
dependencies {
kapt(semverProcessor)
- compileOnly(semverProcessor)
+ implementation(semverProcessor)
- compile(kotlin("stdlib"))
+ implementation(kotlin("stdlib"))
}
repositories {
@@ -32,9 +31,26 @@ application {
mainClassName = "com.example.Main"
}
-configure {
- //properties = "example.properties"
- //keysPrefix = "example."
- //preReleaseKey = "release"
- //buildMetaKey = "meta"
+kapt {
+ arguments {
+ arg("semver.project.dir", projectDir)
+ }
+}
+
+tasks {
+ "run"(JavaExec::class) {
+ doFirst {
+ println("Verion: $version")
+ }
+
+// args = listOf("example.properties")
+ args = listOf("version.properties")
+ }
+}
+
+semver {
+// properties = "example.properties"
+// keysPrefix = "example."
+// preReleaseKey = "release"
+// buildMetaKey = "meta"
}
diff --git a/examples/annotation-processor/kotlin/gradle.properties b/examples/annotation-processor/kotlin/gradle.properties
new file mode 100644
index 0000000..93cd554
--- /dev/null
+++ b/examples/annotation-processor/kotlin/gradle.properties
@@ -0,0 +1 @@
+#kapt.use.worker.api=true
diff --git a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar
index 758de96..f3d88b1 100644
Binary files a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar and b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties
index 2d80b69..a2bf131 100644
--- a/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/annotation-processor/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/annotation-processor/kotlin/gradlew b/examples/annotation-processor/kotlin/gradlew
old mode 100644
new mode 100755
index cccdd3d..2fe81a7
--- a/examples/annotation-processor/kotlin/gradlew
+++ b/examples/annotation-processor/kotlin/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ 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=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -109,8 +125,8 @@ 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
+# 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"`
@@ -138,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# 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"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/examples/annotation-processor/kotlin/gradlew.bat b/examples/annotation-processor/kotlin/gradlew.bat
index f955316..62bd9b9 100644
--- a/examples/annotation-processor/kotlin/gradlew.bat
+++ b/examples/annotation-processor/kotlin/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
diff --git a/examples/annotation-processor/kotlin/src/main/kotlin/com/example/Main.kt b/examples/annotation-processor/kotlin/src/main/kotlin/com/example/Main.kt
index 7ccd226..cc503f1 100644
--- a/examples/annotation-processor/kotlin/src/main/kotlin/com/example/Main.kt
+++ b/examples/annotation-processor/kotlin/src/main/kotlin/com/example/Main.kt
@@ -1,6 +1,7 @@
package com.example
import net.thauvin.erik.semver.Version
+import java.io.File
import java.text.SimpleDateFormat
@Version(properties = "version.properties", type = "kt")
@@ -28,6 +29,17 @@ class Main {
println(" BuildMetaData: ${GeneratedVersion.BUILDMETA}")
println("-----------------------------------------------------")
+
+ if (args.size == 1) {
+ File(args[0]).apply {
+ if (exists()) {
+ println("> cat $name")
+ forEachLine {
+ println(it)
+ }
+ }
+ }
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/examples/annotation-processor/kotlin/version.properties b/examples/annotation-processor/kotlin/version.properties
index 2ba0606..8da5e3a 100644
--- a/examples/annotation-processor/kotlin/version.properties
+++ b/examples/annotation-processor/kotlin/version.properties
@@ -1,7 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 12:30:21 PDT 2018
-version.prerelease=
-version.minor=1
+#Wed Jul 24 21:06:46 PDT 2019
version.buildmeta=
-version.patch=2
-version.major=11
+version.major=14
+version.minor=3
+version.patch=0
+version.prerelease=
+version.project=Kotlin Example
+version.semver=14.3.0
diff --git a/examples/build.gradle b/examples/build.gradle
deleted file mode 100644
index 1e3ca7e..0000000
--- a/examples/build.gradle
+++ /dev/null
@@ -1,36 +0,0 @@
-task clean(type: Delete) {
- doFirst {
- delete fileTree(".") {
- include "*.properties"
- }
- }
-}
-
-task incrementPatch {
- dependsOn(
- "java:clean", "java:incrementPatch",
- "kotlin:clean", "kotlin:incrementPatch",
- "annotation-processor:java:clean", "annotation-processor:java:incrementPatch",
- "annotation-processor:kotlin:clean", "annotation-processor:kotlin:incrementPatch")
-}
-
-task incrementMinor {
- dependsOn(
- "java:clean", "java:incrementMinor",
- "kotlin:clean", "kotlin:incrementMinor",
- "annotation-processor:java:clean", "annotation-processor:java:incrementMinor",
- "annotation-processor:kotlin:clean", "annotation-processor:kotlin:incrementMinor")
-}
-
-task incrementMajor {
- dependsOn(
- "java:clean", "java:incrementMajor",
- "kotlin:clean", "kotlin:incrementMajor",
- "annotation-processor:java:clean", "annotation-processor:java:incrementMajor",
- "annotation-processor:kotlin:clean", "annotation-processor:kotlin:incrementMajor")
-}
-
-task run {
- dependsOn(
- "java:run", "kotlin:run", "annotation-processor:java:run", "annotation-processor:kotlin:run")
-}
\ No newline at end of file
diff --git a/examples/examples.sh b/examples/examples.sh
new file mode 100755
index 0000000..787be4a
--- /dev/null
+++ b/examples/examples.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Version 1.0
+
+if [ $# -eq 0 ]; then
+ echo "Usage: $0 "
+ exit 1
+fi
+
+# set the examples directories
+declare -a examples=(
+ "java"
+ "kotlin"
+ "annotation-processor/java"
+ "annotation-processor/kotlin")
+
+dir=$(dirname "$(readlink -f "$0")")
+cyan=$(tput setaf 6)
+normal=$(tput sgr0)
+
+i=0
+for ex in "${examples[@]}"; do
+ if [ $i -ne 0 ]
+ then
+ read -p "Press [Enter] key to continue..."
+ clear
+ fi
+ cd "$dir/$ex" || exit 1
+ echo "> Project: ${cyan}${ex}${normal}"
+ ./gradlew --console=plain --no-build-cache clean "$@" || exit 1
+ (( i++ ))
+done
diff --git a/examples/java/.editorconfig b/examples/java/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/examples/java/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/examples/java/.gitignore b/examples/java/.gitignore
index 6322c7f..a78c5c2 100644
--- a/examples/java/.gitignore
+++ b/examples/java/.gitignore
@@ -1,29 +1,82 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.sublime-*
-*.iws
+!.vscode/extensions.json
+!.vscode/launch.json
+!.vscode/settings.json
+!.vscode/tasks.json
+!gradle-wrapper.jar
.classpath
.DS_Store
.gradle
+.history
+.idea_modules/
+.idea/**/contentModel.xml
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/dataSources/
+.idea/**/dbnavigator.xml
+.idea/**/dictionaries
+.idea/**/dynamic.xml
+.idea/**/gradle.xml
+.idea/**/libraries
+.idea/**/mongoSettings.xml
+.idea/**/shelf
+.idea/**/sqlDataSources.xml
+.idea/**/tasks.xml
+.idea/**/uiDesigner.xml
+.idea/**/usage.statistics.xml
+.idea/**/workspace.xml
+.idea/caches/build_file_checksums.ser
+.idea/httpRequests
+.idea/replstate.xml
.kobalt
+.mtj.tmp/
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
.nb-gradle
.project
+.scannerwork
.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
+.vscode/*
+*.class
+*.code-workspace
+*.ctxt
+*.ear
+*.iws
+*.jar
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.war
+*.zip
+atlassian-ide-plugin.xml
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
ehthumbs.db
+fabric.properties
+gen/
+gradle.properties
+hs_err_pid*
kobaltBuild
-Thumbs.db
\ No newline at end of file
+kobaltw*-test
+lib/kotlin*
+libs/
+local.properties
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
diff --git a/examples/java/.idea/compiler.xml b/examples/java/.idea/compiler.xml
new file mode 100644
index 0000000..0888ebb
--- /dev/null
+++ b/examples/java/.idea/compiler.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/encodings.xml b/examples/java/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/examples/java/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/inspectionProfiles/Project_Default.xml b/examples/java/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8ff795e
--- /dev/null
+++ b/examples/java/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/misc.xml b/examples/java/.idea/misc.xml
new file mode 100644
index 0000000..db06c18
--- /dev/null
+++ b/examples/java/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/modules.xml b/examples/java/.idea/modules.xml
new file mode 100644
index 0000000..da0a5ad
--- /dev/null
+++ b/examples/java/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/modules/examples-java.iml b/examples/java/.idea/modules/examples-java.iml
new file mode 100644
index 0000000..7c9c673
--- /dev/null
+++ b/examples/java/.idea/modules/examples-java.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/modules/examples-java.main.iml b/examples/java/.idea/modules/examples-java.main.iml
new file mode 100644
index 0000000..b3b97ea
--- /dev/null
+++ b/examples/java/.idea/modules/examples-java.main.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/modules/examples-java.test.iml b/examples/java/.idea/modules/examples-java.test.iml
new file mode 100644
index 0000000..860abdf
--- /dev/null
+++ b/examples/java/.idea/modules/examples-java.test.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/vcs.xml b/examples/java/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/examples/java/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/build.gradle b/examples/java/build.gradle
index d8ae200..e841b08 100644
--- a/examples/java/build.gradle
+++ b/examples/java/build.gradle
@@ -1,27 +1,23 @@
plugins {
id 'java'
id 'application'
- id "net.thauvin.erik.gradle.semver" version "0.9.4-beta"
+ id 'net.thauvin.erik.gradle.semver' version '1.0.4'
+ id 'com.github.ben-manes.versions' version '0.36.0'
}
// ./gradlew
// ./gradlew incrementPatch run
// ./gradlew incrementMinor run
// ./gradlew incrementMajor run
+// ./gradlew incrementBuildMeta run
+// ./gradlew echoVersion
-mainClassName = 'App'
-
-compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated")
defaultTasks 'run'
dependencies {
- testImplementation(
- 'org.junit.jupiter:junit-jupiter-api:5.2.0'
- )
- testRuntimeOnly(
- 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
- )
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
repositories {
@@ -32,15 +28,37 @@ 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 {
+ doFirst {
+// buildMeta = sprintf("%03d", (buildMeta as Integer) + 1)
+ buildMeta = new Date().format("yyyyMMddHHmmss")
+ }
}
run {
doFirst {
+// println "Version: ${-> version}"
println "Version: $version"
}
+
+// args = ['example.properties']
+ args = ['version.properties']
+}
+
+task echoVersion(type:Exec) {
+ commandLine 'echo', "${-> project.version}"
}
diff --git a/examples/java/example.properties b/examples/java/example.properties
index d946882..5438279 100644
--- a/examples/java/example.properties
+++ b/examples/java/example.properties
@@ -1,7 +1,7 @@
#Generated by the Semver Plugin for Gradle
#Sun Jul 01 12:21:40 PDT 2018
example.major=1
-example.release=beta
+example.release=alpha
example.meta=
example.minor=1
example.patch=1
diff --git a/examples/java/gradle/wrapper/gradle-wrapper.jar b/examples/java/gradle/wrapper/gradle-wrapper.jar
index 758de96..e708b1c 100644
Binary files a/examples/java/gradle/wrapper/gradle-wrapper.jar and b/examples/java/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/java/gradle/wrapper/gradle-wrapper.properties b/examples/java/gradle/wrapper/gradle-wrapper.properties
index 2d80b69..be52383 100644
--- a/examples/java/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/java/gradlew b/examples/java/gradlew
old mode 100644
new mode 100755
index cccdd3d..4f906e0
--- a/examples/java/gradlew
+++ b/examples/java/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ 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=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ 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
@@ -109,10 +126,11 @@ 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
+# 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
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# 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"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/examples/java/gradlew.bat b/examples/java/gradlew.bat
index f955316..107acd3 100644
--- a/examples/java/gradlew.bat
+++ b/examples/java/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ 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%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%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
diff --git a/examples/java/java.iml b/examples/java/java.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/examples/java/java.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/src/main/java/App.java b/examples/java/src/main/java/App.java
index c2347df..32b2431 100644
--- a/examples/java/src/main/java/App.java
+++ b/examples/java/src/main/java/App.java
@@ -1,12 +1,20 @@
-/*
- * This Java source file was generated by the Gradle 'init' task.
- */
-public class App {
- public static void main(String[] args) {
- System.out.println(new App().getGreeting());
- }
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
- public String getGreeting() {
- return "Hello world.";
+public class App {
+ public static void main(String... args) throws IOException {
+ if (args.length == 1) {
+ final Path path = Paths.get(args[0]);
+ if (Files.exists(path)) {
+ final List content = Files.readAllLines(path);
+ System.out.println("> cat " + path.getFileName());
+ for (final String line : content) {
+ System.out.println(line);
+ }
+ }
+ }
}
}
diff --git a/examples/java/src/test/java/AppTest.java b/examples/java/src/test/java/AppTest.java
index 6cf97a2..b214b69 100644
--- a/examples/java/src/test/java/AppTest.java
+++ b/examples/java/src/test/java/AppTest.java
@@ -1,11 +1,12 @@
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertAll;
class AppTest {
@Test
- void testAppHasAGreeting() {
- App classUnderTest = new App();
- assertNotNull("app should have a greeting", classUnderTest.getGreeting());
+ void testAppHasMain() {
+ final App classUnderTest = new App();
+ assertAll("app should have a main method.",
+ () -> classUnderTest.getClass().getMethod("main", String[].class));
}
}
diff --git a/examples/java/version.properties b/examples/java/version.properties
index b1704b5..f5bf6aa 100644
--- a/examples/java/version.properties
+++ b/examples/java/version.properties
@@ -1,7 +1,8 @@
#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 21:58:49 PDT 2018
-version.prerelease=
-version.buildmeta=
-version.patch=2
+#Fri Sep 25 17:38:33 PDT 2020
+version.buildmeta=20200925173833
version.major=1
version.minor=0
+version.patch=0
+version.prerelease=
+version.semver=1.0.0+20200925173833
diff --git a/examples/kotlin/.editorconfig b/examples/kotlin/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/examples/kotlin/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/examples/kotlin/.gitignore b/examples/kotlin/.gitignore
index 6322c7f..a78c5c2 100644
--- a/examples/kotlin/.gitignore
+++ b/examples/kotlin/.gitignore
@@ -1,29 +1,82 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.sublime-*
-*.iws
+!.vscode/extensions.json
+!.vscode/launch.json
+!.vscode/settings.json
+!.vscode/tasks.json
+!gradle-wrapper.jar
.classpath
.DS_Store
.gradle
+.history
+.idea_modules/
+.idea/**/contentModel.xml
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/dataSources/
+.idea/**/dbnavigator.xml
+.idea/**/dictionaries
+.idea/**/dynamic.xml
+.idea/**/gradle.xml
+.idea/**/libraries
+.idea/**/mongoSettings.xml
+.idea/**/shelf
+.idea/**/sqlDataSources.xml
+.idea/**/tasks.xml
+.idea/**/uiDesigner.xml
+.idea/**/usage.statistics.xml
+.idea/**/workspace.xml
+.idea/caches/build_file_checksums.ser
+.idea/httpRequests
+.idea/replstate.xml
.kobalt
+.mtj.tmp/
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
.nb-gradle
.project
+.scannerwork
.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
+.vscode/*
+*.class
+*.code-workspace
+*.ctxt
+*.ear
+*.iws
+*.jar
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.war
+*.zip
+atlassian-ide-plugin.xml
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
ehthumbs.db
+fabric.properties
+gen/
+gradle.properties
+hs_err_pid*
kobaltBuild
-Thumbs.db
\ No newline at end of file
+kobaltw*-test
+lib/kotlin*
+libs/
+local.properties
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
diff --git a/examples/kotlin/.idea/compiler.xml b/examples/kotlin/.idea/compiler.xml
new file mode 100644
index 0000000..3628231
--- /dev/null
+++ b/examples/kotlin/.idea/compiler.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/encodings.xml b/examples/kotlin/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/examples/kotlin/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/inspectionProfiles/Project_Default.xml b/examples/kotlin/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8ff795e
--- /dev/null
+++ b/examples/kotlin/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/misc.xml b/examples/kotlin/.idea/misc.xml
new file mode 100644
index 0000000..db06c18
--- /dev/null
+++ b/examples/kotlin/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/modules.xml b/examples/kotlin/.idea/modules.xml
new file mode 100644
index 0000000..825faa5
--- /dev/null
+++ b/examples/kotlin/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/modules/examples-kotlin.iml b/examples/kotlin/.idea/modules/examples-kotlin.iml
new file mode 100644
index 0000000..81fc2ee
--- /dev/null
+++ b/examples/kotlin/.idea/modules/examples-kotlin.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/modules/examples-kotlin.main.iml b/examples/kotlin/.idea/modules/examples-kotlin.main.iml
new file mode 100644
index 0000000..9848c98
--- /dev/null
+++ b/examples/kotlin/.idea/modules/examples-kotlin.main.iml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/modules/examples-kotlin.test.iml b/examples/kotlin/.idea/modules/examples-kotlin.test.iml
new file mode 100644
index 0000000..7925939
--- /dev/null
+++ b/examples/kotlin/.idea/modules/examples-kotlin.test.iml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/vcs.xml b/examples/kotlin/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/examples/kotlin/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts
index 586d170..d54e882 100644
--- a/examples/kotlin/build.gradle.kts
+++ b/examples/kotlin/build.gradle.kts
@@ -1,21 +1,26 @@
-import net.thauvin.erik.gradle.semver.SemverConfig
+import net.thauvin.erik.gradle.semver.SemverIncrementBuildMetaTask
+import java.lang.String.format
+import java.time.LocalDateTime
+import java.time.format.DateTimeFormatter
plugins {
- kotlin("jvm") version "1.2.50"
+ kotlin("jvm").version("1.4.10")
application
- id("net.thauvin.erik.gradle.semver") version "0.9.4-beta"
+ id("net.thauvin.erik.gradle.semver").version("1.0.4")
+ id("com.github.ben-manes.versions").version("0.36.0")
}
// ./gradlew
// ./gradlew incrementPatch run
// ./gradlew incrementMinor run
// ./gradlew incrementMajor run
+// ./gradlew incrementBuildMeta run
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
dependencies {
- compile(kotlin("stdlib"))
- testCompile("org.testng:testng:6.14.3")
+ implementation(kotlin("stdlib"))
+ testImplementation("org.testng:testng:7.3.0")
}
repositories {
@@ -24,13 +29,16 @@ repositories {
application {
mainClassName = "com.example.MainKt"
+// project.afterEvaluate {
+// println("Version: $version")
+// }
}
-configure {
- //properties = "example.properties"
- //keysPrefix = "example."
- //preReleaseKey = "release"
- //buildMetaKey = "meta"
+semver {
+// properties = "example.properties"
+// keysPrefix = "example."
+// preReleaseKey = "release"
+// buildMetaKey = "meta"
}
tasks {
@@ -38,9 +46,19 @@ tasks {
useTestNG()
}
- val run by getting {
+ "incrementBuildMeta"(SemverIncrementBuildMetaTask::class) {
+ doFirst {
+// buildMeta = format("%03d", buildMeta.toInt() + 1)
+ buildMeta = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
+ }
+ }
+
+ "run"(JavaExec::class) {
doFirst {
println("Version: $version")
}
+
+// args = listOf("example.properties")
+ args = listOf("version.properties")
}
}
diff --git a/examples/kotlin/example.properties b/examples/kotlin/example.properties
index 4832c99..849d314 100644
--- a/examples/kotlin/example.properties
+++ b/examples/kotlin/example.properties
@@ -1,7 +1,7 @@
#Generated by the Semver Plugin for Gradle
-#Sun Jul 01 20:17:52 PDT 2018
+#Thu Nov 01 18:52:15 PDT 2018
example.major=1
-example.release=
-example.meta=
+example.meta=20181101185211
example.minor=0
example.patch=0
+example.release=beta
diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/kotlin/gradle/wrapper/gradle-wrapper.jar
index 758de96..e708b1c 100644
Binary files a/examples/kotlin/gradle/wrapper/gradle-wrapper.jar and b/examples/kotlin/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
index 2d80b69..be52383 100644
--- a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/kotlin/gradlew b/examples/kotlin/gradlew
old mode 100644
new mode 100755
index cccdd3d..4f906e0
--- a/examples/kotlin/gradlew
+++ b/examples/kotlin/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ 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=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ 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
@@ -109,10 +126,11 @@ 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
+# 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
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# 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"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/examples/kotlin/gradlew.bat b/examples/kotlin/gradlew.bat
index f955316..107acd3 100644
--- a/examples/kotlin/gradlew.bat
+++ b/examples/kotlin/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ 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%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%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
diff --git a/examples/kotlin/src/main/kotlin/com/example/Main.kt b/examples/kotlin/src/main/kotlin/com/example/Main.kt
index f6cdb3c..caaa0c1 100644
--- a/examples/kotlin/src/main/kotlin/com/example/Main.kt
+++ b/examples/kotlin/src/main/kotlin/com/example/Main.kt
@@ -1,3 +1,16 @@
package com.example
-fun main(args: Array) = println("Hello world.")
\ No newline at end of file
+import java.io.File
+
+fun main(args: Array) {
+ if (args.size == 1) {
+ File(args[0]).apply {
+ if (exists()) {
+ println("> cat $name")
+ forEachLine {
+ println(it)
+ }
+ }
+ }
+ }
+}
diff --git a/examples/kotlin/src/test/kotlin/com/example/MainTest.kt b/examples/kotlin/src/test/kotlin/com/example/MainTest.kt
index 96458e9..e49aac0 100644
--- a/examples/kotlin/src/test/kotlin/com/example/MainTest.kt
+++ b/examples/kotlin/src/test/kotlin/com/example/MainTest.kt
@@ -5,4 +5,4 @@ import org.testng.annotations.Test
class ExampleTest {
@Test
fun f() = println("Running test")
-}
\ No newline at end of file
+}
diff --git a/examples/kotlin/version.properties b/examples/kotlin/version.properties
index c2bc416..98e937a 100644
--- a/examples/kotlin/version.properties
+++ b/examples/kotlin/version.properties
@@ -1,7 +1,8 @@
#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 12:34:38 PDT 2018
-version.prerelease=
-version.minor=0
-version.buildmeta=
-version.patch=0
+#Mon Nov 09 21:24:16 PST 2020
+version.buildmeta=20201109212416
version.major=1
+version.minor=2
+version.patch=4
+version.prerelease=beta
+version.semver=1.2.4-beta+20201109212416
diff --git a/examples/settings.gradle b/examples/settings.gradle
deleted file mode 100644
index 306a83f..0000000
--- a/examples/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-include 'java', 'kotlin', 'annotation-processor:java', 'annotation-processor:kotlin'
-rootProject.name = 'examples'
\ No newline at end of file
diff --git a/examples/test/.editorconfig b/examples/test/.editorconfig
new file mode 100644
index 0000000..a6971e1
--- /dev/null
+++ b/examples/test/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline=true
diff --git a/examples/test/.gitignore b/examples/test/.gitignore
index 6322c7f..4d64aee 100644
--- a/examples/test/.gitignore
+++ b/examples/test/.gitignore
@@ -1,29 +1,83 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.sublime-*
-*.iws
+!.vscode/extensions.json
+!.vscode/launch.json
+!.vscode/settings.json
+!.vscode/tasks.json
+!gradle-wrapper.jar
.classpath
.DS_Store
.gradle
+.history
+.idea_modules/
+.idea/**/contentModel.xml
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/dataSources/
+.idea/**/dbnavigator.xml
+.idea/**/dictionaries
+.idea/**/dynamic.xml
+.idea/**/gradle.xml
+.idea/**/libraries
+.idea/**/mongoSettings.xml
+.idea/**/shelf
+.idea/**/sqlDataSources.xml
+.idea/**/tasks.xml
+.idea/**/uiDesigner.xml
+.idea/**/usage.statistics.xml
+.idea/**/workspace.xml
+.idea/caches/build_file_checksums.ser
+.idea/httpRequests
+.idea/replstate.xml
.kobalt
+.mtj.tmp/
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
.nb-gradle
.project
+.scannerwork
.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
+.vscode/*
+*.class
+*.code-workspace
+*.ctxt
+*.ear
+*.iws
+*.jar
+*.log
+*.nar
+*.rar
+*.sublime-*
+*.tar.gz
+*.war
+*.zip
+atlassian-ide-plugin.xml
+bin/
+build/
+cmake-build-*/
+com_crashlytics_export_strings.xml
+crashlytics-build.properties
+crashlytics.properties
+dependency-reduced-pom.xml
+deploy/
+dist/
ehthumbs.db
+fabric.properties
+gen/
+gradle.properties
+hs_err_pid*
kobaltBuild
-Thumbs.db
\ No newline at end of file
+kobaltw*-test
+lib/kotlin*
+libs/
+local.properties
+out/
+pom.xml.next
+pom.xml.releaseBackup
+pom.xml.tag
+pom.xml.versionsBackup
+proguard-project.txt
+project.properties
+release.properties
+target/
+test-output
+Thumbs.db
+version.properties
diff --git a/examples/test/build.gradle b/examples/test/build.gradle
index a05b3ea..9813e76 100644
--- a/examples/test/build.gradle
+++ b/examples/test/build.gradle
@@ -1,9 +1,10 @@
buildscript {
repositories {
mavenLocal()
+ mavenCentral()
}
dependencies {
- classpath "net.thauvin.erik.gradle:semver:0.9.4-beta"
+ classpath "net.thauvin.erik.gradle:semver:1.0.5-beta"
}
}
@@ -13,31 +14,51 @@ apply plugin: 'net.thauvin.erik.gradle.semver'
mainClassName = 'App'
-version = 1.0
+//version = 1.0
+
+def f = new File("version.properties")
+
+def semverProcessor = 'net.thauvin.erik:semver:1.2.0'
dependencies {
-
+ annotationProcessor semverProcessor
+ compileOnly semverProcessor
}
repositories {
+ mavenLocal()
jcenter()
}
-task cleanVersion {
- delete "test.properties"
-}
-
-clean.dependsOn("cleanVersion")
-
-run {
- //dependsOn("incrementPatch")
- doFirst {
- println("Version: $version")
+application {
+ println(project.version)
+ project.afterEvaluate {
+ println(project.version)
}
}
+
+incrementBuildMeta {
+ doFirst {
+ //buildMeta = sprintf("%03d", (buildMeta as Integer) + 1)
+ buildMeta = new Date().format("yyyyMMddHHmmss")
+ }
+}
+
+run {
+ doFirst {
+ println("Version: $semver.major$semver.separator$semver.minor$semver.separator$semver.patch$semver.preReleasePrefix$semver.preRelease$semver.buildMetaPrefix$semver.buildMeta")
+ args = [f.name]
+ }
+}
+
+task echoVersion(type:Exec) {
+ commandLine "echo", "${-> version}"
+}
+
semver {
- properties = "example.properties"
- keysPrefix = "example."
+ properties = "${f.name}"
+ keysPrefix = f.name.substring(0, f.name.indexOf(".") + 1)
buildMetaKey = "meta"
-}
\ No newline at end of file
+ semverKey = "fullversion"
+}
diff --git a/examples/test/example.properties b/examples/test/example.properties
deleted file mode 100644
index d002a26..0000000
--- a/examples/test/example.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 23:03:45 PDT 2018
-example.major=1
-example.meta=007
-example.prerelease=
-example.minor=1
-example.patch=1
diff --git a/examples/test/gradle/wrapper/gradle-wrapper.jar b/examples/test/gradle/wrapper/gradle-wrapper.jar
index 758de96..5c2d1cf 100644
Binary files a/examples/test/gradle/wrapper/gradle-wrapper.jar and b/examples/test/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/examples/test/gradle/wrapper/gradle-wrapper.properties b/examples/test/gradle/wrapper/gradle-wrapper.properties
index 2d80b69..4b7e1f3 100644
--- a/examples/test/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/test/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/test/gradlew b/examples/test/gradlew
index cccdd3d..8e25e6c 100755
--- a/examples/test/gradlew
+++ b/examples/test/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ 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=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
diff --git a/examples/test/gradlew.bat b/examples/test/gradlew.bat
index f955316..9618d8d 100644
--- a/examples/test/gradlew.bat
+++ b/examples/test/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
diff --git a/examples/test/locked b/examples/test/locked
new file mode 100644
index 0000000..e69de29
diff --git a/examples/test/locked.properties b/examples/test/locked.properties
new file mode 100644
index 0000000..03fc5bd
--- /dev/null
+++ b/examples/test/locked.properties
@@ -0,0 +1,8 @@
+#Generated by the Semver Plugin for Gradle
+#Fri Apr 19 13:31:37 PDT 2019
+version.fullversion=11.0.0-alpha+20190419133137
+version.major=11
+version.meta=20190419133137
+version.minor=0
+version.patch=0
+version.prerelease=alpha
diff --git a/examples/test/src/main/java/App.class b/examples/test/src/main/java/App.class
index 08ab694..04cd607 100644
Binary files a/examples/test/src/main/java/App.class and b/examples/test/src/main/java/App.class differ
diff --git a/examples/test/src/main/java/App.java b/examples/test/src/main/java/App.java
index bd9132e..318ac03 100644
--- a/examples/test/src/main/java/App.java
+++ b/examples/test/src/main/java/App.java
@@ -1,12 +1,22 @@
-/*
- * This Java source file was generated by the Gradle 'init' task.
- */
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
public class App {
- public String getGreeting() {
- return "Hello world.";
+ public static void main(String[] args) {
+ new App().cat(args[0]);
}
- public static void main(String[] args) {
- System.out.println(new App().getGreeting());
+ public void cat(String name) {
+ try {
+ final List content = Files.readAllLines(Paths.get(name));
+ System.out.println("> cat " + name);
+ for (String line : content) {
+ System.out.println(line);
+ }
+ } catch (IOException e) {
+ System.out.println(e);
+ }
}
-}
+}
\ No newline at end of file
diff --git a/examples/test/src/test/java/AppTest.java b/examples/test/src/test/java/AppTest.java
deleted file mode 100644
index e611fc7..0000000
--- a/examples/test/src/test/java/AppTest.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * This Java source file was generated by the Gradle 'init' task.
- */
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class AppTest {
- @Test public void testAppHasAGreeting() {
- App classUnderTest = new App();
- assertNotNull("app should have a greeting", classUnderTest.getGreeting());
- }
-}
diff --git a/examples/test/test.groovy b/examples/test/test.groovy
new file mode 100644
index 0000000..7f66d71
--- /dev/null
+++ b/examples/test/test.groovy
@@ -0,0 +1,8 @@
+if (this.args.length > 0) {
+ for (arg in this.args) {
+ f = new File(arg)
+ println("${f.name}\t-> exits: ${f.exists()}, canRead: ${f.canRead()} --> `${f.absoluteFile}`")
+ }
+} else {
+ println("Usage: groovy ${this.class.getName()} filename")
+}
\ No newline at end of file
diff --git a/examples/test/version.properties b/examples/test/version.properties
deleted file mode 100644
index 0a909a3..0000000
--- a/examples/test/version.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 22:37:14 PDT 2018
-version.prerelease=
-version.buildmeta=
-version.patch=3
-version.major=1
-version.minor=0
diff --git a/examples/version.properties b/examples/version.properties
index cd564a3..e60c0e6 100644
--- a/examples/version.properties
+++ b/examples/version.properties
@@ -1,7 +1,8 @@
#Generated by the Semver Plugin for Gradle
-#Mon Jul 02 15:38:33 PDT 2018
-version.prerelease=
-version.minor=1
-version.buildmeta=
-version.patch=0
+#Thu May 23 22:24:06 PDT 2019
+version.fullversion=1.0.0
version.major=1
+version.meta=
+version.minor=0
+version.patch=0
+version.prerelease=
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 758de96..e708b1c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 2d80b69..be52383 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index cccdd3d..4f906e0 100755
--- a/gradlew
+++ b/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ 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=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -66,6 +82,7 @@ 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
@@ -109,10 +126,11 @@ 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
+# 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
@@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
# 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"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index f955316..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ 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%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%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
diff --git a/preflightcheck.sh b/preflightcheck.sh
new file mode 100644
index 0000000..f95e229
--- /dev/null
+++ b/preflightcheck.sh
@@ -0,0 +1,212 @@
+#!/bin/bash
+
+# set source and test locations
+src="src/main/kotlin/net/thauvin/erik/gradle/semver/"
+test="src/main/kotlin/net/thauvin/erik/gradle/semver/"
+# e.g: .java, .kt, etc.
+ext=".kt"
+java8=true
+# e.g:
+declare -a examples=(
+ "examples/java incrementBuildMeta run"
+ "examples/kotlin incrementBuildMeta run"
+ "examples/annotation-processor/java incrementMinor run"
+ "examples/annotation-processor/kotlin incrementMinor run")
+# e.g: empty or javadoc, etc.
+gradle_doc=""
+# e.g. empty or sonarqube
+gradle_sonar="sonarqube"
+# gradle options for examples
+gradle_opts="--console=plain --no-build-cache --no-daemon"
+# maven arguments for examples
+maven_args="compile exec:java"
+
+#
+# Version: 1.1.3
+#
+
+if [ "$java8" = true ]
+then
+ export JAVA_HOME="$JAVA8_HOME"
+ export PATH="$(cygpath "$JAVA_HOME")/bin:$PATH"
+fi
+
+pwd=$PWD
+red=$(tput setaf 1)
+cyan=$(tput setaf 6)
+std=$(tput sgr0)
+date=$(date +%Y)
+
+pause() {
+ read -p "Press [Enter] key to continue..."
+}
+
+checkCopyright() {
+ if [ "$(grep -c "$date" "$1")" -eq 0 ]
+ then
+ echo -e " Invalid: ${red}$f${std}"
+ else
+ echo -e " Checked: $1"
+ fi
+}
+
+runGradle() {
+ cd "$1" || exit 1
+ clear
+ reset
+ echo -e "> Project: ${cyan}${1}${std} [Gradle]"
+ shift
+ ./gradlew $@ || exit 1
+ pause
+ cd "$pwd"
+}
+
+runKobalt() {
+ cd "$1" || exit 1
+ if [ -f kobalt/src/Build.kt ]
+ then
+ clear
+ reset
+ echo -e "> Project: ${cyan}${1}${std} [Kobalt]"
+ shift
+ ./kobaltw $@ || exit 1
+ pause
+ fi
+ cd "$pwd"
+}
+
+runMaven() {
+ cd "$1" || exit 1
+ if [ -f pom.xml ]
+ then
+ clear
+ reset
+ echo -e "> Project: ${cyan}${1}${std} [Maven]"
+ shift
+ mvn $@ || exit 1
+ pause
+ fi
+ cd "$pwd"
+}
+
+updateWrappers() {
+ clear
+ ./updatewrappers.sh
+ pause
+}
+
+checkDeps() {
+ clear
+ echo -e "${cyan}Checking depencencies...${std}"
+ gradle --console=plain dU || exit 1
+ read -p "Check Examples depencencies? [y/n] " cont
+ clear
+ case $cont in
+ [Nn] ) return ;;
+ * ) for ex in "${!examples[@]}"
+ do
+ runGradle $(echo "${examples[ex]}" | cut -d " " -f 1) dU
+ runKobalt $(echo "${examples[ex]}" | cut -d " " -f 1) checkVersions
+ runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) versions:display-dependency-updates
+ if [ "$ex" -eq "${#examples}" ]
+ then
+ read -p "Continue? [y/n]: " cont
+ clear
+ case $cont in
+ * ) continue ;;
+ [Nn] ) return ;;
+ esac
+ fi
+ done ;;
+ esac
+}
+
+gradleCheck() {
+ clear
+ echo -e "${cyan}Checking Gradle build....${std}"
+ gradle $gradle_opts clean check $gradle_doc $gradle_sonar || exit 1
+ pause
+}
+
+runExamples() {
+ for ex in "${!examples[@]}"
+ do
+ runGradle ${examples[ex]} clean $gradle_opts
+ runKobalt ${examples[ex]} clean
+ runMaven $(echo "${examples[ex]}" | cut -d " " -f 1) clean $maven_args
+ done
+}
+
+examplesMenu() {
+ clear
+ echo -e "${cyan}Examples${std}"
+ for ex in "${!examples[@]}"
+ do
+ printf ' %d. %s\n' $(($ex + 1)) $(echo "${examples[ex]}" | cut -d " " -f 1)
+ done
+ echo " $((${#examples[@]} + 1)). Run All Examples"
+ read -p "Enter choice [1-${#examples[@]}]: " choice
+ clear
+ case $choice in
+ [0-9] ) if [ "$choice" -gt "${#examples[@]}" ]
+ then
+ runExamples
+ examplesMenu
+ else
+ runGradle ${examples[$(($choice - 1))]}
+ runKobalt ${examples[$(($choice - 1))]}
+ runMaven $(echo "${examples[$(($choice - 1))]}" | cut -d " " -f 1) $maven_args
+ examplesMenu
+ fi ;;
+ * ) return ;;
+ esac
+}
+
+validateCopyrights() {
+ clear
+ echo -e "${cyan}Validating copyrights...${std}"
+ for f in LICENSE.TXT ${src}/*${ext} ${test}/*${ext}
+ do
+ checkCopyright "$f"
+ done
+ pause
+}
+
+everything() {
+ updateWrappers
+ checkDeps
+ gradleCheck
+ runExamples
+ validateCopyrights
+}
+
+showMenu() {
+ clear
+ echo "${cyan}Preflight Check${std}"
+ echo " 1. Update Wrappers"
+ echo " 2. Check Dependencies"
+ echo " 3. Check Gradle Build"
+ echo " 4. Run Examples"
+ echo " 5. Validate Copyrights"
+ echo " 6. Check Everything"
+}
+
+readOptions() {
+ local choice
+ read -p "Enter choice [1-6]: " choice
+ case $choice in
+ 1) updateWrappers ;;
+ 2) checkDeps ;;
+ 3) gradleCheck ;;
+ 4) examplesMenu ;;
+ 5) validateCopyrights ;;
+ 6) everything ;;
+ *) exit 0 ;;
+ esac
+}
+
+while true
+do
+ showMenu
+ readOptions
+done
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 849893a..e9b895f 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,2 +1,17 @@
+plugins {
+ id("com.gradle.enterprise").version("3.3.4")
+}
+
+gradleEnterprise {
+ buildScan {
+ link("GitHub", "https://github.com/ethauvin/semver-gradle/tree/master")
+ if ("true" == System.getenv("CI")) {
+ publishOnFailure()
+ tag("CI")
+ }
+ termsOfServiceUrl = "https://gradle.com/terms-of-service"
+ termsOfServiceAgree = "yes"
+ }
+}
+
rootProject.name = "semver"
-enableFeaturePreview("STABLE_PUBLISHING")
\ No newline at end of file
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt
index 0ebc6b2..06a8f7b 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverConfig.kt
@@ -1,7 +1,7 @@
/*
* SemverConfig.kt
*
- * Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,12 +29,18 @@
* 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
-open class SemverConfig {
+import javax.inject.Inject
+
+open class SemverConfig @Inject constructor(
+ private val semVersion: Version
+) {
companion object {
const val DEFAULT_KEYS_PREFIX = "version."
const val DEFAULT_PROPERTIES = "${DEFAULT_KEYS_PREFIX}properties"
+ const val DEFAULT_SEMVER_KEY = "semver"
const val DEFAULT_MAJOR_KEY = "major"
const val DEFAULT_MINOR_KEY = "minor"
const val DEFAULT_PATCH_KEY = "patch"
@@ -46,6 +52,10 @@ open class SemverConfig {
}
var properties = DEFAULT_PROPERTIES
+
+ // Keys
+ var semverKey = DEFAULT_SEMVER_KEY
+ get() = "$keysPrefix$field"
var majorKey = DEFAULT_MAJOR_KEY
get() = "$keysPrefix$field"
var minorKey = DEFAULT_MINOR_KEY
@@ -63,4 +73,51 @@ open class SemverConfig {
var separatorKey = DEFAULT_SEPARATOR
get() = "$keysPrefix$field"
var keysPrefix = DEFAULT_KEYS_PREFIX
-}
\ No newline at end of file
+
+ // Extension Properties
+ val semver: String
+ get() = semVersion.semver
+ val version: String
+ get() = semVersion.semver
+ val major: Int
+ get() = semVersion.major
+ val minor: Int
+ get() = semVersion.minor
+ val patch: Int
+ get() = semVersion.patch
+ val preRelease: String
+ get() = semVersion.preRelease
+ val buildMeta: String
+ get() = semVersion.buildMeta
+ val preReleasePrefix: String
+ get() = semVersion.preReleasePrefix
+ val buildMetaPrefix: String
+ get() = semVersion.buildMetaPrefix
+ val separator: String
+ 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'" +
+ ')'
+ }
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt
new file mode 100644
index 0000000..7463ba0
--- /dev/null
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementBuildMetaTask.kt
@@ -0,0 +1,65 @@
+/*
+ * SemverIncrementBuildMetaTask.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.DefaultTask
+import org.gradle.api.tasks.CacheableTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.TaskAction
+import javax.inject.Inject
+
+@CacheableTask
+open class SemverIncrementBuildMetaTask @Inject constructor(
+ private val config: SemverConfig,
+ private val version: Version
+) : DefaultTask() {
+ init {
+ group = "version"
+ description = "Increments Build version metadata."
+ }
+
+ @Suppress("MemberVisibilityCanBePrivate")
+ @Input
+ var buildMeta: String = ""
+
+ @Suppress("unused")
+ @TaskAction
+ fun increment() {
+ if (version.buildMeta != buildMeta) {
+ version.buildMeta = buildMeta
+ project.version = version.semver
+ logger.lifecycle("Version: ${project.version}")
+ Utils.saveProperties(project.projectDir, config, version)
+ }
+ }
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt
index ec282c4..9e5af44 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverIncrementTask.kt
@@ -1,7 +1,7 @@
/*
* SemverIncrementTask.kt
*
- * Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,17 +29,20 @@
* 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.DefaultTask
+import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject
+@CacheableTask
open class SemverIncrementTask @Inject constructor(
private val config: SemverConfig,
private val version: Version,
- private val type: String)
- : DefaultTask() {
+ private val type: String
+) : DefaultTask() {
init {
group = "version"
description = "Increments ${type.capitalize()} version number."
@@ -51,9 +54,10 @@ open class SemverIncrementTask @Inject constructor(
version.increment(
isMajor = type == SemverConfig.DEFAULT_MAJOR_KEY,
isMinor = type == SemverConfig.DEFAULT_MINOR_KEY,
- isPatch = type == SemverConfig.DEFAULT_PATCH_KEY)
+ isPatch = type == SemverConfig.DEFAULT_PATCH_KEY
+ )
project.version = version.semver
logger.lifecycle("Version: ${project.version}")
- SemverPlugin.saveProperties(config, version)
+ Utils.saveProperties(project.projectDir, config, version)
}
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt
index b7ac40c..1e137e7 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SemverPlugin.kt
@@ -1,7 +1,7 @@
/*
* SemverPlugin.kt
*
- * Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,78 +29,72 @@
* 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 org.gradle.api.Plugin
import org.gradle.api.Project
-import java.io.File
-import java.io.FileInputStream
-import java.io.FileOutputStream
-import java.util.Properties
+import org.gradle.util.GradleVersion
class SemverPlugin : Plugin {
+ private val simpleName = SemverPlugin::class.simpleName
private var version = Version()
private lateinit var config: SemverConfig
-
- companion object {
- fun saveProperties(config: SemverConfig, version: Version) {
- Properties().apply {
- put(config.majorKey, version.major)
- put(config.minorKey, version.minor)
- put(config.patchKey, version.patch)
- put(config.preReleaseKey, version.preRelease)
- put(config.buildMetaKey, version.buildMeta)
- if (version.buildMetaPrefix != Version.DEFAULT_BUILDMETA_PREFIX)
- put(config.buildMetaPrefixKey, version.buildMetaPrefix)
- if (version.preReleasePrefix != Version.DEFAULT_PRERELEASE_PREFIX)
- put(config.preReleasePrefixKey, version.preReleasePrefix)
- if (version.separator != Version.DEFAULT_SEPARATOR)
- put(config.separatorKey, version.separator)
- FileOutputStream(config.properties).use { output ->
- store(output, "Generated by the Semver Plugin for Gradle")
- }
- }
+ override fun apply(project: Project) {
+ if (GradleVersion.current() < GradleVersion.version("4.8.1")) {
+ throw GradleException("The $simpleName plugin requires Gradle version 4.8.1 or greater.")
}
- }
-
- override fun apply(project: Project?) {
- project!!.afterEvaluate(this::afterEvaluate)
- config = project.extensions.create("semver", SemverConfig::class.java)
+ config = project.extensions.create("semver", SemverConfig::class.java, version)
+ project.afterEvaluate(this::afterEvaluate)
project.tasks.apply {
create("incrementMajor", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_MAJOR_KEY)
create("incrementMinor", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_MINOR_KEY)
create("incrementPatch", SemverIncrementTask::class.java, config, version, SemverConfig.DEFAULT_PATCH_KEY)
+ create("incrementBuildMeta", SemverIncrementBuildMetaTask::class.java, config, version)
}
}
private fun afterEvaluate(project: Project) {
+ val propsFile = Utils.getPropertiesFile(project.projectDir, config.properties)
+
if (project.version != "unspecified") {
- project.logger.warn("Please specify the version in ${config.properties} and remove it from ${project.buildFile.name}")
+ project.logger.warn(
+ "Please specify the version in ${propsFile.name} and remove it from ${project.buildFile.name}"
+ )
}
- File(config.properties).apply {
- project.logger.info("[${SemverPlugin::class.simpleName}] Attempting to read properties from: `${this.absoluteFile}`.")
- if (canRead()) {
- FileInputStream(this).use { fis ->
- Properties().apply {
- load(fis)
- version.major = getProperty(config.majorKey, Version.DEFAULT_MAJOR)
- version.minor = getProperty(config.minorKey, Version.DEFAULT_MINOR)
- version.patch = getProperty(config.patchKey, Version.DEFAULT_PATCH)
- version.preRelease = getProperty(config.preReleaseKey, Version.DEFAULT_EMPTY)
- version.preReleasePrefix = getProperty(config.preReleasePrefixKey, Version.DEFAULT_PRERELEASE_PREFIX)
- version.buildMeta = getProperty(config.buildMetaKey, Version.DEFAULT_EMPTY)
- version.buildMetaPrefix = getProperty(config.buildMetaPrefixKey, Version.DEFAULT_BUILDMETA_PREFIX)
- version.separator = getProperty(config.separatorKey, Version.DEFAULT_SEPARATOR)
- }
- }
- } else if (exists()) {
- throw GradleException("Unable to read version from ${config.properties}")
+
+ propsFile.apply {
+ val isNew = !exists()
+
+ project.logger.info(
+ "[$simpleName] Attempting to read properties from: `$absoluteFile`. " +
+ "[exists: $isNew, isFile: $isFile, canRead: ${canRead()}]"
+ )
+
+ val props = Utils.loadProperties(this)
+ val requiredProps = setOf(
+ config.semverKey, config.majorKey, config.minorKey, config.patchKey,
+ config.preReleaseKey, config.buildMetaKey
+ )
+ val hasReqProps = !isNew && props.stringPropertyNames().containsAll(requiredProps) &&
+ Utils.isNotSystemProperty(requiredProps)
+
+ Utils.loadVersion(config, version, props)
+
+ project.tasks.withType(SemverIncrementBuildMetaTask::class.java) {
+ buildMeta = version.buildMeta
}
+
project.version = version.semver
- saveProperties(config, version)
+ project.logger.info("[$simpleName] Project version set to: ${project.version}")
+
+ if (!hasReqProps || !isFile) {
+ project.logger.info("[$simpleName] Saving version properties to `$absoluteFile`.")
+ Utils.saveProperties(project.projectDir, config, version)
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt
new file mode 100644
index 0000000..1a99d15
--- /dev/null
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/SortedProperties.kt
@@ -0,0 +1,48 @@
+/*
+ * SortedProperties.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 java.util.Collections
+import java.util.Enumeration
+import java.util.Properties
+
+internal class SortedProperties : Properties() {
+ override val entries: MutableSet>
+ get() = super.entries.sortedWith(Comparator { a, b -> a.toString().compareTo(b.toString()) }).toMutableSet()
+
+ override fun keys(): Enumeration {
+ val keys = Collections.list(super.keys())
+ keys.sortWith(Comparator { a, b -> a.toString().compareTo(b.toString()) })
+ return Collections.enumeration(keys)
+ }
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/Utils.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/Utils.kt
new file mode 100644
index 0000000..e7cd681
--- /dev/null
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/Utils.kt
@@ -0,0 +1,223 @@
+/*
+ * Utils.kt
+ *
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.thauvin.erik.gradle.semver
+
+import org.gradle.api.GradleException
+import java.io.File
+import java.io.FileInputStream
+import java.io.FileOutputStream
+import java.io.IOException
+import java.util.Properties
+
+/**
+ * The Utils
class.
+ *
+ * @author Erik C. Thauvin
+ * @created 2019-04-10
+ * @since 1.0
+ */
+object Utils {
+ fun File.canReadFile(): Boolean {
+ return canRead() && isFile
+ }
+
+ private fun Properties.put(key: String, value: String, isValidCondition: Boolean) {
+ if (isValidCondition) put(key, value)
+ }
+
+ fun isNotSystemProperty(keys: Set): Boolean {
+ keys.forEach {
+ if (System.getProperties().containsKey(it)) return false
+ }
+ return true
+ }
+
+ fun getPropertiesFile(projectDir: File, propsFile: String): File {
+ return if (File(propsFile).isAbsolute) {
+ File(propsFile)
+ } else {
+ File(projectDir, propsFile)
+ }
+ }
+
+ fun loadProperties(file: File): Properties {
+ var isNew = false
+ val props = Properties()
+ file.apply {
+ try {
+ if (!exists() && createNewFile()) {
+ isNew = true
+ }
+ } catch (e: IOException) {
+ throw GradleException("Unable to create: `$absoluteFile`", e)
+ }
+ if (canReadFile()) {
+ FileInputStream(this).reader().use { reader ->
+ props.apply {
+ if (!isNew) {
+ load(reader)
+ }
+ }
+ }
+ } else {
+ throw GradleException("Unable to read version from: `$absoluteFile`")
+ }
+ }
+ return props
+ }
+
+ fun loadIntProperty(props: Properties, key: String, default: Int): Int {
+ try {
+ return loadProperty(props, key, default.toString()).toInt()
+ } catch (e: java.lang.NumberFormatException) {
+ throw GradleException("Unable to parse $key property. (${e.message})", e)
+ }
+ }
+
+ fun loadProperty(props: Properties, key: String, default: String): String {
+ return System.getProperty(key, if (props.isNotEmpty()) props.getProperty(key, default) else default)
+ }
+
+ fun loadVersion(config: SemverConfig, version: Version, props: Properties) {
+ props.apply {
+ if (!parseSemVer(System.getProperty(config.semverKey), version)) {
+ version.major = loadIntProperty(this, config.majorKey, Version.DEFAULT_MAJOR)
+ version.minor = loadIntProperty(this, config.minorKey, Version.DEFAULT_MINOR)
+ version.patch = loadIntProperty(this, config.patchKey, Version.DEFAULT_PATCH)
+ version.preRelease = loadProperty(this, config.preReleaseKey, Version.DEFAULT_EMPTY)
+ version.buildMeta = loadProperty(this, config.buildMetaKey, Version.DEFAULT_EMPTY)
+ }
+
+ if (!isEmpty) {
+ version.preReleasePrefix =
+ getProperty(config.preReleasePrefixKey, Version.DEFAULT_PRERELEASE_PREFIX)
+ version.buildMetaPrefix =
+ getProperty(config.buildMetaPrefixKey, Version.DEFAULT_BUILDMETA_PREFIX)
+ version.separator = getProperty(config.separatorKey, Version.DEFAULT_SEPARATOR)
+ }
+ }
+ }
+
+ fun parseSemVer(input: String?, version: Version): Boolean {
+ if (input.isNullOrBlank()) return false
+
+ try {
+ val max = 5
+ val min = 3
+
+ val parts = input.split(
+ Regex("[\\Q${version.separator}${version.preReleasePrefix}${version.buildMetaPrefix}\\E]"),
+ max
+ )
+
+ if (parts.size >= min) {
+ version.major = parts[0].toInt()
+ version.minor = parts[1].toInt()
+ version.patch = parts[2].toInt()
+ version.preRelease = ""
+ version.buildMeta = ""
+
+ if (parts.size > min) {
+ when {
+ parts.size == max -> {
+ version.preRelease = parts[3]
+ version.buildMeta = parts[4]
+ }
+ parts.size == 4 -> {
+ if (input.endsWith(version.buildMetaPrefix + parts[3])) {
+ version.buildMeta = parts[3]
+ } else {
+ version.preRelease = parts[3]
+ }
+ }
+ }
+ }
+ } else {
+ throw NumberFormatException("Not enough parts.")
+ }
+ } catch (e: NumberFormatException) {
+ throw GradleException("Unable to parse version: \"$input\" (${e.message})", e)
+ }
+
+ return true
+ }
+
+ fun saveProperties(projectDir: File, config: SemverConfig, version: Version) {
+ val propsFile = getPropertiesFile(projectDir, config.properties)
+ SortedProperties().apply {
+ try {
+ propsFile.apply {
+ if (canReadFile()) {
+ FileInputStream(this).reader().use { load(it) }
+ } else {
+ createNewFile()
+ }
+
+ put(config.semverKey, version.semver)
+ put(config.majorKey, version.major.toString())
+ put(config.minorKey, version.minor.toString())
+ put(config.patchKey, version.patch.toString())
+ put(config.preReleaseKey, version.preRelease)
+ put(config.buildMetaKey, version.buildMeta)
+ put(config.semverKey, version.semver)
+
+ put(
+ config.buildMetaPrefixKey, version.buildMetaPrefix,
+ version.buildMetaPrefix != Version.DEFAULT_BUILDMETA_PREFIX ||
+ containsKey(config.buildMetaPrefixKey)
+ )
+ put(
+ config.preReleasePrefixKey, version.preReleasePrefix,
+ version.preReleasePrefix != Version.DEFAULT_PRERELEASE_PREFIX ||
+ containsKey(config.preReleasePrefixKey)
+ )
+ put(
+ config.separatorKey, version.separator,
+ version.separator != Version.DEFAULT_SEPARATOR ||
+ containsKey(config.separatorKey)
+ )
+
+ if (canWrite()) {
+ FileOutputStream(this).writer().use {
+ store(it, "Generated by the Semver Plugin for Gradle")
+ }
+ } else {
+ throw IOException("Can't write.")
+ }
+ }
+ } catch (e: IOException) {
+ throw GradleException("Unable to write version to: `${propsFile.absoluteFile}`", e)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt b/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt
index e752c04..eedbf38 100644
--- a/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt
+++ b/src/main/kotlin/net/thauvin/erik/gradle/semver/Version.kt
@@ -1,7 +1,7 @@
/*
* Version.kt
*
- * Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,13 +29,14 @@
* 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
class Version {
companion object {
- const val DEFAULT_MAJOR: String = "1"
- const val DEFAULT_MINOR: String = "0"
- const val DEFAULT_PATCH: String = "0"
+ const val DEFAULT_MAJOR: Int = 1
+ const val DEFAULT_MINOR: Int = 0
+ const val DEFAULT_PATCH: Int = 0
const val DEFAULT_EMPTY: String = ""
const val DEFAULT_PRERELEASE_PREFIX = "-"
const val DEFAULT_BUILDMETA_PREFIX = "+"
@@ -58,14 +59,27 @@ class Version {
fun increment(isMajor: Boolean = false, isMinor: Boolean = false, isPatch: Boolean = false) {
if (isMajor) {
- major = (major.toInt() + 1).toString()
+ major++
minor = DEFAULT_MINOR
patch = DEFAULT_PATCH
}
if (isMinor) {
- minor = (minor.toInt() + 1).toString()
+ minor++
patch = DEFAULT_PATCH
}
- if (isPatch) patch = (patch.toInt() + 1).toString()
+ 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', " +
+ ')'
}
}
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt
index 0dccdd2..45105a0 100644
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt
+++ b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverConfigSpec.kt
@@ -1,7 +1,7 @@
/*
* SemverConfigSpec.kt
*
- * Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,21 +29,21 @@
* 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.jetbrains.spek.api.Spek
-import org.jetbrains.spek.api.dsl.describe
-import org.jetbrains.spek.api.dsl.given
-import org.jetbrains.spek.api.dsl.it
-import org.jetbrains.spek.api.dsl.on
+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({
- describe("config test") {
- given("a config") {
- val config = SemverConfig()
+ Feature("SemverConfig") {
+ val config = SemverConfig(Version())
+ Scenario("Testing configs") {
val vars = listOf(
+ config.semverKey,
config.majorKey,
config.minorKey,
config.patchKey,
@@ -54,6 +54,7 @@ object SemverConfigSpec : Spek({
config.separatorKey
)
val defaults = listOf(
+ SemverConfig.DEFAULT_SEMVER_KEY,
SemverConfig.DEFAULT_MAJOR_KEY,
SemverConfig.DEFAULT_MINOR_KEY,
SemverConfig.DEFAULT_PATCH_KEY,
@@ -63,16 +64,25 @@ object SemverConfigSpec : Spek({
SemverConfig.DEFAULT_BUILDMETA_PREFIX_KEY,
SemverConfig.DEFAULT_SEPARATOR
)
- on("defaults") {
- defaults.forEachIndexed { i, d ->
- it("should be the same: ${vars[i]}, ${config.keysPrefix}$d") {
- assertTrue(vars[i] == "${config.keysPrefix}$d")
- }
+
+ When("checking defaults") {}
+
+ defaults.forEachIndexed { i, d ->
+ Then(" ${vars[i]} should be the same: ${config.keysPrefix}$d") {
+ assertEquals(vars[i], "${config.keysPrefix}$d")
}
}
- on("set keys to test.xxx") {
+
+ Then("config.properties should be version.properties") {
+ assertEquals(config.properties, "version.properties")
+ }
+
+ lateinit var newKeys: List
+
+ When("setting keyPrefix to test.") {
config.keysPrefix = "test."
- val keys = listOf(
+ newKeys = listOf(
+ config.semverKey,
config.majorKey,
config.minorKey,
config.patchKey,
@@ -80,14 +90,35 @@ object SemverConfigSpec : Spek({
config.preReleasePrefixKey,
config.buildMetaKey,
config.buildMetaPrefixKey,
- config.separatorKey)
+ config.separatorKey
+ )
+ }
- keys.forEach { k ->
- it("should all start with test.xxx: $k") {
- assertTrue(k.startsWith("test."))
- }
+ 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)
+ }
}
}
-})
\ No newline at end of file
+})
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt
index 5555b3f..3dc5f1e 100644
--- a/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt
+++ b/src/test/kotlin/net/thauvin/erik/gradle/semver/SemverVersionSpec.kt
@@ -1,7 +1,7 @@
/*
* SemverVersionSpec.kt
*
- * Copyright (c) 2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,94 +29,175 @@
* 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.jetbrains.spek.api.Spek
-import org.jetbrains.spek.api.dsl.describe
-import org.jetbrains.spek.api.dsl.given
-import org.jetbrains.spek.api.dsl.it
-import org.jetbrains.spek.api.dsl.on
+import org.spekframework.spek2.Spek
+import org.spekframework.spek2.style.gherkin.Feature
import kotlin.test.assertEquals
@Suppress("unused")
object SemverVersionSpec : Spek({
- describe("version test") {
- given("a version") {
- val version = Version()
- on("increment major") {
+ 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)
- it("should return 2.0.0") {
- assertEquals("2.0.0", version.semver)
- }
}
- on("increment minor") {
+
+ Then("should return 2.0.0") {
+ assertEquals("2.0.0", version.semver)
+ }
+
+ When("incrementing minor") {
version.increment(isMinor = true)
- it("should return 2.1.0") {
- assertEquals("2.1.0", version.semver)
- }
}
- on("increment patch") {
+
+ Then("should return 2.1.0") {
+ assertEquals("2.1.0", version.semver)
+ }
+
+ When("incrementing patch") {
version.increment(isPatch = true)
- it("should return 2.1.1") {
- assertEquals("2.1.1", version.semver)
- }
}
- on("increment patch") {
+
+ Then("should return 2.1.1") {
+ assertEquals("2.1.1", version.semver)
+ }
+
+ When("incrementing minor again") {
version.increment(isMinor = true)
- it("should return 2.1.0") {
- assertEquals("2.1.0", version.semver)
- }
}
- on("increment patch") {
+
+ Then("should return 2.2.0") {
+ assertEquals("2.2.0", version.semver)
+ }
+
+ When("incrementing major again") {
version.increment(isMajor = true)
- it("should return 3.0.0") {
- assertEquals("3.0.0", version.semver)
- }
}
- on("increment all") {
- version.increment(true, true, true)
- it("should return 3.1.1") {
- assertEquals("3.1.1", version.semver)
- }
+
+ Then("should return 3.0.0") {
+ assertEquals("3.0.0", version.semver)
}
- on("reset version") {
- version.major = "1"
- version.minor = "0"
- version.patch = "0"
- it("should return 1.0.0") {
- assertEquals("1.0.0", version.semver)
- }
+
+ When("incrementing all") {
+ version.increment(isMajor = true, isMinor = true, isPatch = true)
}
- on("add prerelease") {
+
+ 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"
- it("should return 1.0.0-beta") {
- assertEquals("1.0.0-beta", version.semver)
- }
}
- on("add metadata") {
+
+ Then("should return 1.0.0-beta") {
+ assertEquals("1.0.0-beta", version.semver)
+ }
+
+ When("adding metadata") {
version.buildMeta = "007"
- it("should return 1.0.0-beta+007") {
- assertEquals("1.0.0-beta+007", version.semver)
- }
}
- on("change prerelease prefix") {
+
+ Then("should return 1.0.0-beta+007") {
+ assertEquals("1.0.0-beta+007", version.semver)
+ }
+
+ When("changing prerelease prefix") {
version.preReleasePrefix = "--"
- it("should return 1.0.0--beta+007") {
- assertEquals("1.0.0--beta+007", version.semver)
- }
}
- on("change prerelease prefix") {
+
+ Then("should return 1.0.0--beta+007") {
+ assertEquals("1.0.0--beta+007", version.semver)
+ }
+
+ When("changing meta prefix") {
version.buildMetaPrefix = "++"
- it("should return 1.0.0--beta+=007") {
- assertEquals("1.0.0--beta++007", version.semver)
- }
}
- on("change sperator") {
+
+ Then("should return 1.0.0--beta++007") {
+ assertEquals("1.0.0--beta++007", version.semver)
+ }
+
+ When("changing separator") {
version.separator = "-"
- it("should return 1-0-0--beta+007") {
- assertEquals("1-0-0--beta+007", version.semver)
- }
+ }
+
+ Then("should return 1-0-0--beta++007") {
+ assertEquals("1-0-0--beta++007", version.semver)
}
}
}
-})
\ No newline at end of file
+})
diff --git a/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsSpec.kt b/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsSpec.kt
new file mode 100644
index 0000000..3ad050f
--- /dev/null
+++ b/src/test/kotlin/net/thauvin/erik/gradle/semver/UtilsSpec.kt
@@ -0,0 +1,269 @@
+/*
+ * UtilsSpec.kt
+ *
+ * Copyright (c) 2018-2020, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package net.thauvin.erik.gradle.semver
+
+import net.thauvin.erik.gradle.semver.Utils.canReadFile
+import org.gradle.api.GradleException
+import org.spekframework.spek2.Spek
+import org.spekframework.spek2.style.gherkin.Feature
+import java.io.File
+import java.util.*
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
+import kotlin.test.assertNull
+import kotlin.test.assertTrue
+
+@Suppress("unused")
+object UtilsSpec : Spek(
+ {
+ Feature("Utils") {
+ val version = Version()
+ val config = SemverConfig(version)
+ val propsFile = File("test.properties")
+ val projectDir = File("./")
+ lateinit var props: Properties
+
+ Scenario("Save/Load Properties") {
+ When("saving the property") {
+ config.properties = propsFile.name
+ Utils.saveProperties(projectDir, config, version)
+ }
+
+ Then("properties file should exists and be readable") {
+ assertEquals(propsFile.canReadFile(), propsFile.canRead() && propsFile.isFile)
+ }
+
+ When("loading the properties file") {
+ props = Utils.loadProperties(propsFile)
+ propsFile.delete()
+ }
+
+ Then("version and properties should be the same.") {
+ assertEquals(props.getProperty(config.majorKey), version.major.toString(), "Major")
+ assertEquals(props.getProperty(config.minorKey), version.minor.toString(), "Minor")
+ assertEquals(props.getProperty(config.patchKey), version.patch.toString(), "Patch")
+ assertEquals(props.getProperty(config.preReleaseKey), version.preRelease, "PreRelease")
+ assertNull(props.getProperty(config.preReleasePrefixKey), "PreRelease Prefix")
+ assertEquals(props.getProperty(config.buildMetaKey), version.buildMeta, "Build Meta")
+ assertNull(props.getProperty(config.buildMetaPrefixKey), "Build Meta Prefix")
+ assertNull(props.getProperty(config.separatorKey), "Separator")
+ assertEquals(props.getProperty(config.semverKey), version.semver, "semver")
+ }
+ }
+
+ Scenario("System Properties") {
+ lateinit var sysProps: Array>
+
+ Given("new system properties") {
+ sysProps = arrayOf(
+ Pair(config.majorKey, "2"),
+ Pair(config.minorKey, "1"),
+ Pair(config.patchKey, "1"),
+ Pair(config.preReleaseKey, "beta"),
+ Pair(config.buildMetaKey, "007")
+ )
+ }
+
+ Then("none should already exists") {
+ assertTrue(
+ Utils.isNotSystemProperty(
+ setOf(
+ config.majorKey,
+ config.minorKey,
+ config.patchKey,
+ config.preReleaseKey,
+ config.buildMetaKey
+ )
+ )
+ )
+ }
+
+ Then("version should match system properties") {
+ sysProps.forEach {
+ System.getProperties().setProperty(it.first, it.second)
+ if (it.first == config.majorKey || it.first == config.minorKey || it.first == config.patchKey) {
+ assertEquals(Utils.loadIntProperty(props, it.first, -1), it.second.toInt())
+ } else {
+ assertEquals(Utils.loadProperty(props, it.first, ""), it.second)
+ }
+ }
+ }
+
+ When("loading version") {
+ Utils.loadVersion(config, version, props)
+ }
+
+ Then("version should be identical") {
+ assertEquals(version.semver, "2.1.1-beta+007")
+ }
+
+ When("saving properties") {
+ Utils.saveProperties(projectDir, config, version)
+ }
+
+ lateinit var newProps: Properties
+
+ And("loading properties file") {
+ newProps = Utils.loadProperties(propsFile)
+ }
+
+ Then("new properties should validate") {
+ sysProps.forEach {
+ assertEquals(newProps.getProperty(it.first), it.second, it.second)
+ }
+ propsFile.delete()
+ }
+
+ When("setting the version as system property") {
+ System.getProperties().setProperty(config.semverKey, "3.2.2")
+ }
+
+ And("loading the properties") {
+ Utils.loadVersion(config, version, props)
+ }
+
+ Then("versions should match") {
+ assertEquals(version.semver, System.getProperty(config.semverKey))
+ }
+ }
+
+ Scenario("Version Parsing") {
+ When("validating version parsing") {}
+
+ Then("versions should parse") {
+ listOf(
+ "1.0.0",
+ "2.1.0-beta",
+ "3.2.1-beta+007",
+ "4.3.2+007",
+ "11.11.1",
+ "111.11.11-beta",
+ "1111.111.11-beta+001.12"
+ ).forEach {
+ assertTrue(Utils.parseSemVer(it, version), "parsing semver: $it")
+ assertEquals(it, version.semver, it)
+ }
+ }
+
+ Then("should throw exceptions") {
+ assertFailsWith("2.1.1a") {
+ Utils.parseSemVer("2.1.1a", version)
+ }
+ assertFailsWith("2a.1.1") {
+ Utils.parseSemVer("2a.1.1", version)
+ }
+ assertFailsWith("2.1a.1") {
+ Utils.parseSemVer("2.1a.1", version)
+ }
+ assertFailsWith("2.1") {
+ Utils.parseSemVer("2.1", version)
+ }
+ }
+
+ Given("new prefixes") {
+ version.preReleasePrefix = "."
+ version.buildMetaPrefix = "."
+ }
+
+ Then("prefixes should parse") {
+ listOf("2.1.0.beta.1", "2.1.1.1", "3.2.1.beta.1.007").forEach {
+ assertTrue(Utils.parseSemVer(it, version), "parsing semver: $it")
+ assertEquals(it, version.semver, it)
+ }
+ }
+
+ Then("last pre-release and meta should match") {
+ assertEquals(version.preRelease, "beta")
+ assertEquals(version.buildMeta, "1.007")
+ }
+ }
+
+ Scenario("Load locked properties") {
+ lateinit var locked: File
+
+ Given("the locked location") {
+ locked = File("locked")
+ }
+
+ Then("loading locked properties") {
+ assertFailsWith {
+ Utils.loadProperties(File(locked, propsFile.name))
+ }
+ locked.delete()
+ }
+ }
+
+ Scenario("Save to locked properties") {
+ lateinit var propsLocked: File
+ Given("the locked properties") {
+ propsLocked = File(System.getProperty("user.home") + File.separator + "locked.properties")
+ propsLocked.createNewFile()
+ propsLocked.setReadOnly()
+ config.properties = propsLocked.name
+ }
+
+ Then("saving the locked properties file") {
+ assertFailsWith {
+ Utils.saveProperties(propsLocked.parentFile, config, version)
+ }
+ propsLocked.delete()
+ }
+ }
+
+ Scenario("Save/Load Properties in foo") {
+ lateinit var fooDir: File
+ lateinit var fooProps: File
+ When("saving the foo property") {
+ fooDir = File("foo")
+ fooDir.mkdir()
+ fooProps = File(fooDir, propsFile.name)
+ config.properties = fooProps.absolutePath
+ Utils.saveProperties(projectDir, config, version)
+ }
+
+ Then("foo properties file should exists and be readable") {
+ assertEquals(fooProps.canReadFile(), fooProps.canRead() && fooProps.isFile)
+ }
+
+ When("loading the foo properties file") {
+ props = Utils.loadProperties(fooProps)
+ fooProps.delete()
+ fooDir.delete()
+ }
+
+ Then("version in foo properties should be the same") {
+ assertEquals(props.getProperty(config.semverKey), version.semver)
+ }
+ }
+ }
+ }
+)
diff --git a/updatewrappers.sh b/updatewrappers.sh
new file mode 100644
index 0000000..e98cca5
--- /dev/null
+++ b/updatewrappers.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+
+#
+# Version: 1.0.2
+#
+
+# set the examples directories
+declare -a dirs=(
+ "${PWD##*/}"
+ "examples/java"
+ "examples/kotlin"
+ "examples/annotation-processor/java"
+ "examples/annotation-processor/kotlin")
+java8=true
+
+###
+
+pwd=$PWD
+cyan=$(tput setaf 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
+ if [ "$curVer" != "$(./gradlew --version | awk '/Gradle/ {print $2}')" ]; then
+ gradle -q --console=plain wrapper
+ echo -e " $(./gradlew --version | awk '/Gradle/') ${green}UPDATED${std}"
+ else
+ echo -e " Gradle $curVer UP-TO-DATE"
+ fi
+ fi
+ if [ -d kobalt ]; then
+ kw=$(cut -d "=" -f 2 kobalt/wrapper/kobalt-wrapper.properties)
+ if [ "$kw" = "$kVer" ]
+ then
+ echo -e " Kobalt $kw UP-TO-DATE"
+ else
+ echo -e "kobalt.version=$kVer" > kobalt/wrapper/kobalt-wrapper.properties
+ echo -e " Kobalt $kVer ${green}UPDATED${std}"
+ fi
+ fi
+}
+
+echo -e "Updating wrappers..."
+
+for d in "${!dirs[@]}"; do
+ if [ "$d" -ne 0 ]; then
+ cd "${dirs[d]}" || exit 1
+ fi
+ echo -e " ${cyan}${dirs[d]}${std}"
+ updateWrappers
+ cd "$pwd"
+done