diff --git a/.circleci/config.yml b/.circleci/config.yml
index 7fdfcb3..5697c0d 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,75 +1,42 @@
-defaults: &defaults
- working_directory: ~/repo
- docker:
- - image: circleci/openjdk:8-jdk
- environment:
- JVM_OPTS: -Xmx3200m
- TERM: dumb
+version: 2.1
-version: 2.0
+commands:
+ build_and_test:
+ parameters:
+ reports-dir:
+ type: string
+ default: "build/reports/test_results"
+ steps:
+ - checkout
+ - run:
+ name: Download dependencies
+ command: ./bld download
+ - run:
+ name: Compile source
+ command: ./bld compile
+ - run:
+ name: Run tests
+ command: ./bld jacoco -reports-dir=<< parameters.reports-dir >>
+ - store_test_results:
+ path: << parameters.reports-dir >>
+ - store_artifacts:
+ path: build/reports/jacoco/test/html
jobs:
- build_gradle:
- <<: *defaults
-
+ bld_jdk17:
+ docker:
+ - image: cimg/openjdk:17.0
steps:
- - checkout
- - restore_cache:
- keys:
- - gradle-dependencies-{{ checksum "build.gradle" }}
- # fallback to using the latest cache if no exact match is found
- - gradle-dependencies-
-
- - run:
- name: Gradle Dependencies
- command: ./gradlew dependencies
-
- - save_cache:
- paths: ~/.m2
- key: gradle-dependencies-{{ checksum "build.gradle" }}
-
- - run:
- name: Run All Checks
- command: ./gradlew check
-
- - store_artifacts:
- path: build/reports/
- destination: reports
- - store_test_results:
- path: build/reports/
-
- build_kobalt:
- <<: *defaults
+ - build_and_test
+ bld_jdk21:
+ docker:
+ - image: cimg/openjdk:21.0
steps:
- - checkout
- - restore_cache:
- keys:
- - kobalt-dependencies-{{ checksum "kobalt/src/Build.kt" }}
- # fallback to using the latest cache if no exact match is found
- - kobalt-dependencies-
-
- - run:
- name: Check Versions
- command: ./kobaltw checkVersions
-
- - save_cache:
- paths: ~/.kobalt
- key: kobalt-dependencies-{{ checksum "kobalt/src/Build.kt" }}
-
- - run:
- name: Assemble & Test
- command: ./kobaltw assemble test
-
- - store_artifacts:
- path: kobaltBuild/test-output/
- destination: test-output
- - store_test_results:
- path: kobaltBuild/test-output/
+ - build_and_test
workflows:
- version: 2
- build_gradle_and_kobalt:
+ bld:
jobs:
- - build_gradle
- - build_kobalt
\ No newline at end of file
+ - bld_jdk17
+ - bld_jdk21
diff --git a/.editorconfig b/.editorconfig
index a6971e1..1f808de 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,2 +1,2 @@
[*]
-insert_final_newline=true
+insert_final_newline = true
diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml
new file mode 100644
index 0000000..64007ef
--- /dev/null
+++ b/.github/workflows/bld.yml
@@ -0,0 +1,76 @@
+name: bld-ci
+
+on: [push, pull_request, workflow_dispatch]
+
+jobs:
+ build-bld-project:
+ env:
+ COVERAGE_JDK: "17"
+
+ strategy:
+ matrix:
+ java-version: [17, 21, 24]
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
+
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - name: Checkout source repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up JDK ${{ matrix.java-version }}
+ uses: actions/setup-java@v4
+ with:
+ distribution: "zulu"
+ java-version: ${{ matrix.java-version }}
+
+ - name: Download dependencies [bld example]
+ working-directory: examples/java/bld
+ run: ./bld download
+
+ - name: Compile and run [bld example]
+ working-directory: examples/java/bld
+ run: |
+ ./bld compile
+ ./bld run
+ ./bld run-example
+
+ - name: Run example [gradle java examples]
+ working-directory: examples/java/gradle
+ run: |
+ ./gradlew run
+ ./gradlew runExample
+
+ - name: Run example [gradle kotlin examples]
+ working-directory: examples/kotlin
+ run: |
+ ./gradlew run
+ ./gradlew runExample
+
+ - name: Download dependencies
+ run: ./bld download
+
+ - name: Compile source
+ run: ./bld compile
+
+ - name: Run tests
+ run: ./bld jacoco
+
+ - name: Remove pom.xml
+ if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.os == 'ubuntu-latest'
+ run: rm -rf pom.xml
+
+ - name: SonarCloud Scan
+ uses: sonarsource/sonarcloud-github-action@master
+ if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.os == 'ubuntu-latest'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+
+ - name: Upload coverage reports to Codecov
+ uses: codecov/codecov-action@v3
+ if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.os == 'ubuntu-latest'
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github_changelog_generator b/.github_changelog_generator
new file mode 100644
index 0000000..13dd68d
--- /dev/null
+++ b/.github_changelog_generator
@@ -0,0 +1 @@
+future-release=1.2.1
diff --git a/.gitignore b/.gitignore
index ff3d427..dd3e0b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,48 +1,58 @@
-!.vscode/extensions.json
-!.vscode/launch.json
-!.vscode/settings.json
-!.vscode/tasks.json
-.classpath
-.DS_Store
.gradle
-.kobalt
-.nb-gradle
-.project
-.settings
-.vscode/*
-*.code-workspace
-*.iws
-*.sublime-*
-**/.idea/**/dataSources.ids
-**/.idea/**/dataSources.local.xml
-**/.idea/**/dataSources/
-**/.idea/**/dbnavigator.xml
-**/.idea/**/dictionaries
-**/.idea/**/dynamic.xml
-**/.idea/**/gradle.xml
-**/.idea/**/libraries
-**/.idea/**/shelf
-**/.idea/**/sqlDataSources.xml
-**/.idea/**/tasks.xml
-**/.idea/**/uiDesigner.xml
-**/.idea/**/usage.statistics.xml
-**/.idea/**/workspace.xml
-**/*.class
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/lib/kotlin*
-/libs
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
-ehthumbs.db
-kobaltBuild
-kobaltw*-test
-Thumbs.db
\ No newline at end of file
+.DS_Store
+build
+lib/bld/**
+!lib/bld/bld-wrapper.properties
+!lib/bld/bld-wrapper.jar
+lib/compile/
+lib/runtime/
+lib/standalone/
+lib/test/
+
+# IDEA ignores
+
+# User-specific
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+local.properties
+target
diff --git a/.idea/app.iml b/.idea/app.iml
new file mode 100644
index 0000000..6c0f6d7
--- /dev/null
+++ b/.idea/app.iml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/bld.iml b/.idea/bld.iml
new file mode 100644
index 0000000..e63e11e
--- /dev/null
+++ b/.idea/bld.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/encodings.xml b/.idea/bld.xml
similarity index 54%
rename from examples/java/.idea/encodings.xml
rename to .idea/bld.xml
index 97626ba..6600cee 100644
--- a/examples/java/.idea/encodings.xml
+++ b/.idea/bld.xml
@@ -1,6 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
deleted file mode 100644
index d91f848..0000000
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 6d140d3..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/BSD_3_Clause.xml b/.idea/copyright/BSD_3_Clause.xml
new file mode 100644
index 0000000..025a880
--- /dev/null
+++ b/.idea/copyright/BSD_3_Clause.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..8b4ad55
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 8ff795e..1e01b48 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,53 +1,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/.idea/intellij-javadocs-4.0.1.xml b/.idea/intellij-javadocs-4.0.1.xml
new file mode 100644
index 0000000..fbb9478
--- /dev/null
+++ b/.idea/intellij-javadocs-4.0.1.xml
@@ -0,0 +1,204 @@
+
+
+
+
+ UPDATE
+ false
+ true
+
+ FIELD
+ TYPE
+ METHOD
+
+
+ DEFAULT
+ PUBLIC
+ PROTECTED
+
+
+
+
+
+ ^.*(public|protected|private)*.+interface\s+\w+.*
+ /**\n
+ * The interface ${name}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+ */
+
+
+ ^.*(public|protected|private)*.+enum\s+\w+.*
+ /**\n
+ * The enum ${name}.\n
+ */
+
+
+ ^.*(public|protected|private)*.+class\s+\w+.*
+ /**\n
+ * The type ${name}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+ */
+
+
+ .+
+ /**\n
+ * The type ${name}.\n
+ */
+
+
+
+
+ .+
+ /**\n
+ * Instantiates a new ${name}.\n
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+
+
+ ^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+
+ /**\n
+ * Gets ${partName}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if isNotVoid>
+ *\n
+ * @return the ${partName}\n
+</#if>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+ ^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+
+ /**\n
+ * Sets ${partName}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if isNotVoid>
+ *\n
+ * @return the ${partName}\n
+</#if>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+ ^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+
+ /**\n
+ * The entry point of application.\n
+
+ <#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+ * @param ${element.parameterList.parameters[0].name} the input arguments\n
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+ .+
+ /**\n
+ * ${name}<#if isNotVoid> ${return}</#if>.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if isNotVoid>
+ *\n
+ * @return the ${return}\n
+</#if>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+
+
+ ^.*(public|protected|private)*.+static.*(\w\s\w)+.+
+ /**\n
+ * The constant ${element.getName()}.\n
+ */
+
+
+ ^.*(public|protected|private)*.*(\w\s\w)+.+
+ /**\n
+ <#if element.parent.isInterface()>
+ * The constant ${element.getName()}.\n
+<#else>
+ * The ${name}.\n
+</#if> */
+
+
+ .+
+ /**\n
+ <#if element.parent.isEnum()>
+ *${name} ${typeName}.\n
+<#else>
+ * The ${name}.\n
+</#if>*/
+
+
+
+
+
\ 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/libraries/bld.xml b/.idea/libraries/bld.xml
new file mode 100644
index 0000000..a203de8
--- /dev/null
+++ b/.idea/libraries/bld.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
new file mode 100644
index 0000000..5316b95
--- /dev/null
+++ b/.idea/libraries/compile.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
new file mode 100644
index 0000000..d4069f2
--- /dev/null
+++ b/.idea/libraries/runtime.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
new file mode 100644
index 0000000..05f52ce
--- /dev/null
+++ b/.idea/libraries/test.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5d9e04b..61cdf16 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,10 +1,16 @@
-
-
-
+
+
+
+
+
+
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..55adcb9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ 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 33346db..0000000
--- a/.idea/modules/examples-kotlin_main.iml
+++ /dev/null
@@ -1,27 +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 ad47dc2..0000000
--- a/.idea/modules/examples-kotlin_test.iml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml
new file mode 100644
index 0000000..5c0ca65
--- /dev/null
+++ b/.idea/runConfigurations/Run Tests.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/semver.iml b/.idea/semver.iml
deleted file mode 100644
index 78b2cc5..0000000
--- a/.idea/semver.iml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 58e8252..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: java
-
-jdk:
- - oraclejdk8
-
-before_install:
- - chmod +x gradlew
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..f1d1e89
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,79 @@
+# Changelog
+
+## [1.2.1](https://github.com/ethauvin/semver/tree/1.2.1) (2023-10-01)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/1.2.0...1.2.1)
+
+**Implemented enhancements:**
+
+- Move from Gradle to bld [\#7](https://github.com/ethauvin/semver/issues/7)
+
+**Fixed bugs:**
+
+- NPE with Java 12 and Kotlin 1.3.30 [\#1](https://github.com/ethauvin/semver/issues/1)
+
+**Closed issues:**
+
+- Under Java 12 and Gradle 5.4.1 the properties file is not found. [\#6](https://github.com/ethauvin/semver/issues/6)
+
+## [1.2.0](https://github.com/ethauvin/semver/tree/1.2.0) (2019-05-25)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/1.1.1...1.2.0)
+
+**Implemented enhancements:**
+
+- Calculate the version internally. [\#4](https://github.com/ethauvin/semver/issues/4)
+- Attempt to compile non-existent Java source in Gradle project using Kapt [\#3](https://github.com/ethauvin/semver/issues/3)
+- kapt and Kotlin 1.3.30 require kapt.use.worker.api=true [\#2](https://github.com/ethauvin/semver/issues/2)
+
+**Fixed bugs:**
+
+- Default template is not found in 1.1.1 [\#5](https://github.com/ethauvin/semver/issues/5)
+
+## [1.1.1](https://github.com/ethauvin/semver/tree/1.1.1) (2019-03-31)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/1.1.0-beta...1.1.1)
+
+## [1.1.0-beta](https://github.com/ethauvin/semver/tree/1.1.0-beta) (2018-11-04)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/1.0.1...1.1.0-beta)
+
+## [1.0.1](https://github.com/ethauvin/semver/tree/1.0.1) (2017-05-30)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/1.0.0...1.0.1)
+
+## [1.0.0](https://github.com/ethauvin/semver/tree/1.0.0) (2017-05-10)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.6-beta...1.0.0)
+
+## [0.9.6-beta](https://github.com/ethauvin/semver/tree/0.9.6-beta) (2016-07-15)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.5-beta...0.9.6-beta)
+
+## [0.9.5-beta](https://github.com/ethauvin/semver/tree/0.9.5-beta) (2016-02-03)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.4-beta...0.9.5-beta)
+
+## [0.9.4-beta](https://github.com/ethauvin/semver/tree/0.9.4-beta) (2016-01-29)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.3-beta...0.9.4-beta)
+
+## [0.9.3-beta](https://github.com/ethauvin/semver/tree/0.9.3-beta) (2016-01-28)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.2-beta...0.9.3-beta)
+
+## [0.9.2-beta](https://github.com/ethauvin/semver/tree/0.9.2-beta) (2016-01-25)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.1-beta...0.9.2-beta)
+
+## [0.9.1-beta](https://github.com/ethauvin/semver/tree/0.9.1-beta) (2016-01-25)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/0.9.0-beta...0.9.1-beta)
+
+## [0.9.0-beta](https://github.com/ethauvin/semver/tree/0.9.0-beta) (2016-01-24)
+
+[Full Changelog](https://github.com/ethauvin/semver/compare/aeee81544c6d2881ccf02458fcef1f6ba1c9c169...0.9.0-beta)
+
+
+
+\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
diff --git a/LICENSE.txt b/LICENSE.txt
index ca0e615..ae2f49e 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2016-2018, Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2016-2024, 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 cefe757..cada04f 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,62 @@
-# Semantic Version Annotation Processor
+# Semantic Version Annotation Processor
-[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/semver/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver) [  ](https://bintray.com/ethauvin/maven/SemVer/_latestVersion)
-[](https://snyk.io/test/github/ethauvin/semver?targetFile=build.gradle) [](https://travis-ci.org/ethauvin/semver) [](https://ci.appveyor.com/project/ethauvin/semver) [](https://circleci.com/gh/ethauvin/semver/tree/master)
+[](https://opensource.org/licenses/BSD-3-Clause)
+[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
+[](https://rife2.com/bld)
+[](https://github.com/ethauvin/semver/releases/latest)
+[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/semver/)
+[](https://central.sonatype.com/artifact/net.thauvin.erik/semver)
-An [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html) that automatically generates a `GeneratedVersion` class based on a [Mustache](https://mustache.github.io/) template and containing the [semantic version](http://semver.org/) (major, minor, patch, etc.) that is read from a `Properties` file or defined in the [annotation](https://docs.oracle.com/javase/tutorial/java/annotations/basics.html).
+[](https://sonarcloud.io/dashboard?id=ethauvin_semver)
+[](https://github.com/ethauvin/semver/actions/workflows/bld.yml)
+[](https://ci.appveyor.com/project/ethauvin/semver)
+[](https://circleci.com/gh/ethauvin/semver/tree/master)
+
+An [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annotation/processing/Processor.html) that automatically generates a `GeneratedVersion` class based on a [Mustache](https://mustache.github.io/) template and containing the [semantic version](https://semver.org/) (major, minor, patch, etc.) that is read from a [Properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) file or defined in the [annotation](https://docs.oracle.com/javase/tutorial/java/annotations/basics.html).
This processor was inspired by Cédric Beust's [version-processor](https://github.com/cbeust/version-processor) and works well in conjunction with the [__Semantic Version Plugin for Gradle__](https://github.com/ethauvin/semver-gradle).
+## Table of Contents
+
+- [Semantic Version Annotation Processor](#semantic-version-annotation-processor)
+ - [Table of Contents](#table-of-contents)
+ - [Examples](#examples)
+ - [Template](#template)
+ - [Default Template](#default-template)
+ - [Custom Template](#custom-template)
+ - [Elements \& Properties](#elements--properties)
+ - [Maven](#maven)
+ - [bld](#bld)
+ - [Gradle](#gradle)
+ - [Class Generation](#class-generation)
+ - [Class \& Source Generation](#class--source-generation)
+ - [Kotlin](#kotlin)
+ - [Kotlin \& Gradle](#kotlin--gradle)
+ - [Auto-Increment](#auto-increment)
+ - [Contributing](#contributing)
+
## Examples
-* Using annotation elements:
+- Using annotation elements:
```java
import net.thauvin.erik.semver.Version;
-@Version(major = 1, minor = 0, patch = 0, preRelease = "beta")
+@Version(major = 2, minor = 1, patch = 1, preRelease = "beta")
public class A {
-// ...
+ // ...
+}
```
-* Or using a [properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) file:
+- Or using a [properties](hhttps://github.com/ethauvin/semver/blob/master/examples/java/version.properties) file:
```java
import net.thauvin.erik.semver.Version;
@Version(properties = "version.properties")
public class A {
-// ...
+ // ...
+}
```
```ini
@@ -37,11 +67,11 @@ version.patch=0
version.prerelease=beta
```
-[View Example](https://github.com/ethauvin/semver/tree/master/examples)
+[View Examples](https://github.com/ethauvin/semver/tree/master/examples)
## Template
-Upon running the annotation processor, a source file [`GeneratedVersion.java`](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/net/thauvin/erik/semver/examples/java/GeneratedVersion.java) is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable [Mustache](https://mustache.github.io/) template.
+Upon running the annotation processor, a source file [GeneratedVersion.java](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/com/example/GeneratedVersion.java) is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable Mustache [template](https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache).
To use your own template, simply create a `version.mustache` file in the project's root directory. The processor will automatically look for it.
@@ -50,30 +80,27 @@ To specify your own template name, use:
```java
@Version(template = "version.mustache")
public class A {
-// ...
+ // ...
+}
```
### Default Template
-The [default template](https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache) implements the following static fields:
+The [default template](https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache) implements the following static variables:
-Field | Description | Example
-:--------------|:---------------------------------|:-----------------
-`PROJECT` | The project name, if any. | `MyProject`
-`BUILDDATE` | The build date. | [`java.util.Date`](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html)
-`VERSION` | The full version string. | `1.2.3-alpha+001`
-`MAJOR` | The major version. | `1`
-`MINOR` | The minor version. | `2`
-`PATCH` | The patch version. | `3`
-`PRERELEASE` | The pre-release version, if any. | `alpha`
-`BUILDMETA` | The build metadata, if any. | `001`
-
-And the following methods/functions:
-
-Method | Description | Example
-:------------------------|:----------------------------------------------------------|:--------
-`preReleaseWithPrefix()` | Returns the pre-release with a prefix, `-` by default. | `-alpha`
-`buildMetaWithPrefix()` | Returns the build metadata with a prefix, `+` by default. | `+001`
+| Field | Description | Example |
+|:-------------------|:---------------------------------|:----------------------------------------------------------------------------------|
+| `PROJECT` | The project name, if any. | `MyProject` |
+| `BUILDDATE` | The build date. | [`java.util.Date`](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html) |
+| `VERSION` | The full version string. | `1.2.3-alpha+001` |
+| `MAJOR` | The major version. | `1` |
+| `MINOR` | The minor version. | `2` |
+| `PATCH` | The patch version. | `3` |
+| `PRERELEASE` | The pre-release version, if any. | `alpha` |
+| `PRERELASE_PREFIX` | The pre-release prefix | `-` |
+| `BUILDMETA` | The build metadata, if any. | `001` |
+| `BUILDMETA_PREFIX` | The metadata prefix. | `+` |
+| `SEPARATOR` | The version separator. | `.` |
### Custom Template
@@ -81,61 +108,63 @@ A very simple custom template might look something like:
```java
/* version.mustache */
-package {{packageName}}
+package {{packageName}};
import java.util.Date;
public final class {{className}} {
public final static String PROJECT = "{{project}}";
public final static Date DATE = new Date({{epoch}}L);
- public final static int MAJOR = {{major}};
- public final static int MINOR = {{minor}};
- public final static int PATCH = {{patch}};
- public final static String PRERELEASE = "{{preRelease}}";
- public final static String BUILDMETA = "{{buildMeta}}";
+ public final static String VERSION = "{{semver}}";
}
```
+
The mustache variables automatically filled in by the processor are:
-Variable | Description | Type
-:-----------------|:----------------------------|:--------
-`{{packageName}}` | The package name. | `String`
-`{{className}}` | The class name. | `String`
-`{{project}}` | The project name. | `String`
-`{{epoch}}` | The build epoch/unix time. | `long`
-`{{major}}` | The major version. | `int`
-`{{minor}}` | The minor version. | `int`
-`{{patch}}` | The patch version. | `int`
-`{{preRelease}}` | The pre/release version. | `String`
-`{{buildMeta}}` | The build metadata version. | `String`
-
-Please also look at this [example](https://github.com/ethauvin/mobibot/blob/master/version.mustache) using [`java.time`](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html)
+| Variable | Description | Type |
+|:------------------------------|:----------------------------|:---------|
+| `{{packageName}}` | The package name. | `String` |
+| `{{className}}` | The class name. | `String` |
+| `{{project}}` | The project name. | `String` |
+| `{{epoch}}` | The build epoch/unix time. | `long` |
+| `{{major}}` | The major version. | `int` |
+| `{{minor}}` | The minor version. | `int` |
+| `{{patch}}` | The patch version. | `int` |
+| `{{preRelease}}` | The pre-release version. | `String` |
+| `{{preReleasePrefix}}` | The pre-release prefix. | `String` |
+| `{{buildMeta}}` | The build metadata version. | `String` |
+| `{{buildMetaPrefix}}` | The metadata prefix. | `String` |
+| `{{separator}}` | The version separator. | `String` |
+| `{{semver}}` or `{{version}}` | The full semantic version. | `String` |
## Elements & Properties
The following annotation elements and properties are available:
-Element | Property | Description | Default
-:-------------|:---------------------|:----------------------------------|:-------------------------
-`project` | `version.project` | The project name. |
-`major` | `version.major` | The major version number. | `1`
-`minor` | `version.major` | The minor version number. | `0`
-`patch` | `version.patch` | The patch version number. | `0`
-`preRelease` | `version.prerelease` | The pre-release version. |
-`buildMeta` | `version.buildmeta` | The build metadata version. |
-`packageName` | | The package name. | _Same as annotated class_
-`className` | | The name of the generated class. | `GeneratedVersion`
-`properties` | | The properties file. |
-`template` | | The template file. | `version.mustache`
-`type` | | Either `java` or `kt` for Kotlin. | `java`
-`keysPrefix` | | The prefix for all property keys. | `version.`
+| Element | Property | Description | Default |
+|:-------------------|:----------------------------|:----------------------------------|:--------------------------|
+| `project` | `version.project` | The project name. | |
+| `major` | `version.major` | The major version number. | `1` |
+| `minor` | `version.major` | The minor version number. | `0` |
+| `patch` | `version.patch` | The patch version number. | `0` |
+| `preRelease` | `version.prerelease` | The pre-release version. | |
+| `preReleasePrefix` | `version.prerelease.prefix` | The pre-release prefix. | `-` |
+| `buildMeta` | `version.buildmeta` | The build metadata version. | |
+| `buildMetaPrefix` | `version.buildmeta.prefix` | The metadata prefix. | `+` |
+| `separator` | `version.separator` | The version separator. | `.` |
+| `packageName` | | The package name. | _Same as annotated class_ |
+| `className` | | The name of the generated class. | `GeneratedVersion` |
+| `properties` | | The properties file. | |
+| `template` | | The template file. | `version.mustache` |
+| `type` | | Either `java` or `kt` for Kotlin. | `java` |
+| `keysPrefix` | | The prefix for all property keys. | `version.` |
In order to easily incorporate with existing projects, the property keys may be assigned custom values:
```java
@Version(
properties = "example.properties",
- keysPrefix = "example."
+ keysPrefix = "example.",
majorKey = "maj",
minorKey = "min",
patchKey = "build",
@@ -144,7 +173,8 @@ In order to easily incorporate with existing projects, the property keys may be
projectKey = "project"
)
public class Example {
-// ...
+ // ...
+}
```
```ini
@@ -158,64 +188,86 @@ example.meta=
# ...
```
-> :warning: `keysPrefix` is a new element in `1.1.0` and may break older versions when using custom property keys.
+> :warning: `keysPrefix` is a new element staring in `1.1.0` and may break older versions when using custom property keys.\
> :zap: A quick fix is to include `keysPrefix=""` in the annotation to remove the default `version.` prefix.
-## Usage with Maven, Grail, Kobalt and Kotlin
+## Maven
-### Maven
-
-To install and run from [Maven](http://maven.apache.org/), configure an artifact as follows:
+To install and run from [Maven](https://maven.apache.org/), configure an artifact as follows:
```xml
net.thauvin.erik
semver
- 1.1.0-beta
+ 1.2.1
```
-### Gradle
+```console
+mvn verify
+```
-#### Class Generation
+Please look at [pom.xml](https://github.com/ethauvin/semver/blob/master/examples/java/gradle/pom.xml) in the [examples/java/gradle](https://github.com/ethauvin/semver/tree/master/examples/java/gradle) directory for a sample:
-To install and run from [Gradle](https://gradle.org/), add the following to the `build.gradle` file:
-```gradle
-dependencies {
- annotationProcessor 'net.thauvin.erik:semver:1.1.0-beta'
- compileOnly 'net.thauvin.erik:semver:1.1.0-beta'
+## bld
+
+To install and run from [bld](https://rife2.com/bld), just add the dependency to your build file:
+
+```java
+public class ExampleBuild extends Project {
+ public ExampleBuild() {
+ // ...
+ scope(compile)
+ .include(dependency("net.thauvin.erik", "semver", version(1, 2, 1)));
+ }
}
```
-The `GeneratedVersion` class will be automatically created in the `build/generated` directory upon compiling.
+Please look at [ExampleBuild](https://github.com/ethauvin/semver/blob/master/examples/java/bld/src/bld/java/com/example/ExampleBuild.java) in the [examples/java/bld](https://github.com/ethauvin/semver/tree/master/examples/java/bld) directory for a sample. It also shows how to incorporate the generated code into the `source tree`, more information is also available [here](https://forum.uwyn.com/post/36).
-#### Class & Source Generation
+bld also has a [Generated Version](https://github.com/rife2/bld-generated-version) extension which provides similar functionalities.
-In order to also incorporate the generated source code into the `source tree`, add the following to the very top of the `build.gradle` file:
+## Gradle
+
+### Class Generation
+
+To install and run from [Gradle](https://gradle.org/), add the following to [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/gradle/build.gradle):
```gradle
-compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
-```
+repositories {
+ mavenCentral()
+}
-The `GeneratedVersion.java` file will now be located in `src/generated`.
-
-Please look at the [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle) file in the [Java example](https://github.com/ethauvin/semver/tree/master/example/java) module directory for a sample.
-
-### Kobalt
-
-To install and run from [Kobalt](http://beust.com/kobalt/), add the following to the `Build.kt` file:
-
-```gradle
dependencies {
- apt("net.thauvin.erik:semver:1.1.0-beta")
- compileOnly("net.thauvin.erik:semver:1.1.0-beta")
+ annotationProcessor 'net.thauvin.erik:semver:1.2.1'
+ compileOnly 'net.thauvin.erik:semver:1.2.1'
+}
+
+tasks.withType(JavaCompile).configureEach {
+ options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ]
}
```
-Please look at the [Build.kt](https://github.com/ethauvin/semver/blob/master/examples/kotlin/kobalt/src/Build.kt) file in the [Kotlin example](https://github.com/ethauvin/semver/tree/master/examples/kotlin) module directory for a sample.
+The directory containing the configuration files (`version.properties`, `version.mustache`) must be specified using the `semver.project.dir` processor argument.
-### Kotlin
+The [`GeneratedVersion.java`](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/com/example/GeneratedVersion.java) class will be automatically created in the `build/generated` directory upon compiling.
+
+Please look at [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/gradle/build.gradle) in the [examples/java/gradle](https://github.com/ethauvin/semver/tree/master/examples/java/gradle) directory for a sample.
+
+### Class & Source Generation
+
+In order to also incorporate the generated source code into the `source tree`, add the following to [build.gradle](https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle):
+
+```gradle
+tasks.withType(JavaCompile).configureEach {
+ options.generatedSourceOutputDirectory.set(file("${projectDir}/src/generated/java"))
+}
+```
+
+The [`GeneratedVersion.java`](https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/com/example/GeneratedVersion.java) file will now be located in `src/generated`.
+
+## Kotlin
The annotation processor also supports [Kotlin](https://kotlinlang.org/).
@@ -226,15 +278,56 @@ import net.thauvin.erik.semver.Version
@Version(properties = "version.properties", type="kt")
open class Main {
-// ...
+ // ...
+}
```
+
The [Kotlin default template](https://github.com/ethauvin/semver/blob/master/src/main/resources/semver-kt.mustache) implements the same static fields and functions as the [Java template](#default-template).
-Please look at the [Kotlin example](https://github.com/ethauvin/semver/tree/master/examples/kotlin) project for samples on using Gradle ([build.gradle.kts](https://github.com/ethauvin/semver/blob/master/examples/kotlin/build.gradle.kts)) and Kobalt ([Build.kt](https://github.com/ethauvin/semver/blob/master/examples/kotlin/kobalt/src/Build.kt)).
+Please look at the [examples/kotlin](https://github.com/ethauvin/semver/tree/master/examples/kotlin) project for a [build.gradle.kts](https://github.com/ethauvin/semver/blob/master/examples/kotlin/build.gradle.kts) sample.
+### Kotlin & Gradle
+
+To install and run from [Gradle](https://gradle.org/), add the following to [build.gradle.kts](https://github.com/ethauvin/semver/blob/master/examples/kotlin/build.gradle.kts):
+
+```kotlin
+var semverProcessor = "net.thauvin.erik:semver:1.2.1"
+
+dependencies {
+ kapt(semverProcessor)
+ compileOnly(semverProcessor)
+}
+
+kapt {
+ arguments {
+ arg("semver.project.dir", projectDir.absolutePath)
+ }
+}
+```
+
+The directory containing the configuration files (`version.properties`, `version.mustache`) must be specified using the `semver.project.dir` processor argument.
## Auto-Increment
Incrementing the version is best left to your favorite build system. For a solution using Gradle, please have a look at the [__Semver Version Plugin for Gradle__](https://github.com/ethauvin/semver-gradle).
-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.
+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.
+
+## Contributing
+
+If you want to contribute to this project, all you have to do is clone the GitHub
+repository:
+
+```console
+git clone git@github.com:ethauvin/semver.git
+```
+
+Then use [bld](https://rife2.com/bld) to build:
+
+```console
+cd semver
+./bld compile
+```
+
+The project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all
+the dependencies were downloaded and peruse the code.
diff --git a/appveyor.yml b/appveyor.yml
index 0ee7361..05e9258 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,26 +1,18 @@
-version: "{branch} {build}"
-skip_tags: true
+version: build-{build}.{branch}
+clone_depth: 3
-build:
- verbosity: detailed
+platform: x64
+image: Visual Studio 2019
+
+before_build:
+ - set "JAVA_HOME=C:\Program Files\Java\jdk17"
+ - set "PATH=C:\Program Files\Java\jdk17\bin;%PATH%"
build_script:
- - gradlew.bat assemble --info --no-daemon
+ - bld.bat download compile
test_script:
- - gradlew.bat check --info --no-daemon
-
-branches:
- only:
- - master
+ - bld.bat test
cache:
- - C:\Users\appveyor\.gradle
-
-environment:
- matrix:
- - JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- - JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
-
-matrix:
- fast_finish: true
+ - C:\Users\appveyor\.m2
diff --git a/bin/main/META-INF/services/javax.annotation.processing.Processor b/bin/main/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..5ae1016
--- /dev/null
+++ b/bin/main/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1,33 @@
+#
+# javax.annotation.processing.Processor
+#
+# Copyright (c) 2016-2023, 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.
+#
+
+net.thauvin.erik.semver.VersionProcessor
diff --git a/bin/main/net/thauvin/erik/semver/Constants.class b/bin/main/net/thauvin/erik/semver/Constants.class
new file mode 100644
index 0000000..b299307
Binary files /dev/null and b/bin/main/net/thauvin/erik/semver/Constants.class differ
diff --git a/bin/main/net/thauvin/erik/semver/Version.class b/bin/main/net/thauvin/erik/semver/Version.class
new file mode 100644
index 0000000..239b8a2
Binary files /dev/null and b/bin/main/net/thauvin/erik/semver/Version.class differ
diff --git a/bin/main/net/thauvin/erik/semver/VersionInfo.class b/bin/main/net/thauvin/erik/semver/VersionInfo.class
new file mode 100644
index 0000000..8351bcf
Binary files /dev/null and b/bin/main/net/thauvin/erik/semver/VersionInfo.class differ
diff --git a/bin/main/net/thauvin/erik/semver/VersionProcessor.class b/bin/main/net/thauvin/erik/semver/VersionProcessor.class
new file mode 100644
index 0000000..38b5676
Binary files /dev/null and b/bin/main/net/thauvin/erik/semver/VersionProcessor.class differ
diff --git a/bin/main/net/thauvin/erik/semver/package.html b/bin/main/net/thauvin/erik/semver/package.html
new file mode 100644
index 0000000..1b1b126
--- /dev/null
+++ b/bin/main/net/thauvin/erik/semver/package.html
@@ -0,0 +1,12 @@
+
+
+
+ Semantic Version Annotation Processor
+
+
+An annotation processor that automatically generates a GeneratedVersion
class containing the semantic
+version (major, minor, patch, etc.) that is read from a Properties file or defined in the annotation.
+
+@since 1.0
+
+
diff --git a/bin/main/semver-kt.mustache b/bin/main/semver-kt.mustache
new file mode 100644
index 0000000..0a58f86
--- /dev/null
+++ b/bin/main/semver-kt.mustache
@@ -0,0 +1,38 @@
+/*
+* This file is automatically generated.
+* Do not modify! -- ALL CHANGES WILL BE ERASED!
+*/
+
+package {{packageName}}
+
+import java.util.Date
+
+/**
+* Provides semantic version information.
+*
+* @author Semantic Version Annotation Processor
+*/
+object {{className}} {
+@JvmField
+val PROJECT = "{{project}}"
+@JvmField
+val BUILDDATE = Date({{epoch}}L)
+@JvmField
+val MAJOR = {{major}}
+@JvmField
+val MINOR = {{minor}}
+@JvmField
+val PATCH = {{patch}}
+@JvmField
+val PRERELEASE = "{{preRelease}}"
+@JvmField
+val PRERELEASE_PREFIX = "{{preReleasePrefix}}"
+@JvmField
+val BUILDMETA = "{{buildMeta}}"
+@JvmField
+val BUILDMEATA_PREFIX = "{{buildMetaPrefix}}"
+@JvmField
+val SEPARATOR = "{{separator}}"
+@JvmField
+val VERSION = "{{version}}"
+}
diff --git a/bin/main/semver.mustache b/bin/main/semver.mustache
new file mode 100644
index 0000000..cd7c567
--- /dev/null
+++ b/bin/main/semver.mustache
@@ -0,0 +1,34 @@
+/*
+* This file is automatically generated.
+* Do not modify! -- ALL CHANGES WILL BE ERASED!
+*/
+
+package {{packageName}};
+
+import java.util.Date;
+
+/**
+* Provides semantic version information.
+*
+* @author Semantic Version Annotation Processor
+*/
+public final class {{className}} {
+public static final String PROJECT = "{{project}}";
+public static final Date BUILDDATE = new Date({{epoch}}L);
+public static final int MAJOR = {{major}};
+public static final int MINOR = {{minor}};
+public static final int PATCH = {{patch}};
+public static final String PRERELEASE = "{{preRelease}}";
+public static final String PRERELEASE_PREFIX = "{{preReleasePrefix}}";
+public static final String BUILDMETA = "{{buildMeta}}";
+public static final String BUILDMETA_PREFIX = "{{buildMetaPrefix}}";
+public static final String SEPARATOR = "{{separator}}";
+public static final String VERSION = "{{version}}";
+
+/**
+* Disables the default constructor.
+*/
+private {{className}}() {
+throw new UnsupportedOperationException("Illegal constructor call.");
+}
+}
diff --git a/bin/test/net/thauvin/erik/semver/ConstantsTest.class b/bin/test/net/thauvin/erik/semver/ConstantsTest.class
new file mode 100644
index 0000000..934286a
Binary files /dev/null and b/bin/test/net/thauvin/erik/semver/ConstantsTest.class differ
diff --git a/bin/test/net/thauvin/erik/semver/VersionInfoTest.class b/bin/test/net/thauvin/erik/semver/VersionInfoTest.class
new file mode 100644
index 0000000..d6401b4
Binary files /dev/null and b/bin/test/net/thauvin/erik/semver/VersionInfoTest.class differ
diff --git a/bin/test/net/thauvin/erik/semver/VersionProcessorTest.class b/bin/test/net/thauvin/erik/semver/VersionProcessorTest.class
new file mode 100644
index 0000000..af2b771
Binary files /dev/null and b/bin/test/net/thauvin/erik/semver/VersionProcessorTest.class differ
diff --git a/bin/test/net/thauvin/erik/semver/VersionTest.class b/bin/test/net/thauvin/erik/semver/VersionTest.class
new file mode 100644
index 0000000..0047ff2
Binary files /dev/null and b/bin/test/net/thauvin/erik/semver/VersionTest.class differ
diff --git a/bld b/bld
new file mode 100755
index 0000000..824b742
--- /dev/null
+++ b/bld
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build net.thauvin.erik.semver.SemverBuild "$@"
\ No newline at end of file
diff --git a/bld.bat b/bld.bat
new file mode 100644
index 0000000..ab43bcd
--- /dev/null
+++ b/bld.bat
@@ -0,0 +1,4 @@
+@echo off
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build net.thauvin.erik.semver.SemverBuild %*
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 2dccfe3..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,184 +0,0 @@
-plugins {
- id 'java'
- id 'maven-publish'
- id "com.jfrog.bintray" version "1.8.4"
- id "com.github.ben-manes.versions" version "0.20.0"
- id "net.thauvin.erik.gradle.semver" version "0.9.8-beta"
- id "com.github.spotbugs" version "1.6.5"
-}
-
-import com.github.spotbugs.SpotBugsTask
-import org.apache.tools.ant.taskdefs.condition.Os
-
-defaultTasks 'check'
-
-group = 'net.thauvin.erik'
-
-def mavenName = 'SemVer'
-def mavenDescription = 'Semantic Version Annotation Processor'
-def mavenUrl = 'https://github.com/ethauvin/semver'
-def mavenLicense = 'The BSD 3-Clause License'
-def mavenLicenseUrl = 'http://opensource.org/licenses/BSD-3-Clause'
-def mavenScmCon = 'https://github.com/ethauvin/semver.git'
-def mavenScmDevCon = 'git@github.com:ethauvin/semver.git'
-
-def pkgLicenses = ['BSD 3-Clause']
-def pkgIssueTrackerUrl = mavenUrl + '/issues'
-def pkgLabels = ['java', 'annotation', 'processor', 'semantic', 'version']
-
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
-
-repositories {
- mavenLocal()
- jcenter()
-}
-
-dependencies {
- compile 'com.github.spullara.mustache.java:compiler:0.9.5'
- compileOnly 'com.github.spotbugs:spotbugs-annotations:3.1.8'
- testCompile 'org.testng:testng:6.14.3'
-}
-
-bintray {
- user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
- key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
- publications = ['MyPublication']
- dryRun = false
- pkg {
- repo = 'maven'
- name = mavenName
- licenses = pkgLicenses
- desc = mavenDescription
- websiteUrl = mavenUrl
- issueTrackerUrl = pkgIssueTrackerUrl
- vcsUrl = mavenScmCon
- labels = pkgLabels
- publicDownloadNumbers = true
- }
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- group = 'Build'
- description = 'Builds an archive of the javadoc docs.'
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-task sourceJar(type: Jar) {
- group = 'Build'
- description = 'Builds an archive of the source code.'
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-artifacts {
- archives javadocJar
- archives sourceJar
-}
-
-publishing {
- publications {
- MyPublication(MavenPublication) {
- from components.java
- artifact sourceJar
- artifact javadocJar
- groupId project.group
- artifactId rootProject.name
-
- pom {
- name = mavenName
- description = mavenDescription
- url = mavenUrl
- licenses {
- license {
- name = mavenLicense
- url = mavenLicenseUrl
- distribution = 'repo'
- }
- }
- developers {
- developer {
- id = 'ethauvin'
- name = 'Erik C. Thauvin'
- email = 'erik@thauvin.net'
- }
- }
- scm {
- connection = "scm:git:" + mavenScmCon
- developerConnection = "scm:git:" + mavenScmDevCon
- url = mavenScmCon
- }
- }
- }
- }
-}
-
-javadoc {
- doFirst {
- title = "$mavenDescription $project.version API"
- }
- options.with {
- tags = ['created']
- author = true
- //addBooleanOption('html4', true)
- links('https://docs.oracle.com/javase/8/docs/api/')
- addStringOption('Xdoclint:none', '-quiet')
- }
-}
-
-test {
- useTestNG()
-}
-
-tasks.withType(SpotBugsTask) {
- reports {
- xml.enabled = false
- html.enabled = true
- }
- excludeFilter = file("$projectDir/config/spotbugs/excludeFilter.xml")
-}
-
-compileJava {
- options.compilerArgs.add('-proc:none')
-}
-
-compileTestJava {
- options.compilerArgs.add('-proc:none')
-}
-
-bintrayUpload {
- versionName = "$project.version"
- versionDesc = "Beta version $project.version"
- versionVcsTag = "$project.version"
- signVersion = true
-}
-
-task release(dependsOn: ['wrapper', 'clean', 'publishToMavenLocal']) {
- group = 'Publishing'
- description = 'Releases new version to local maven repository.'
- doFirst {
- println("Version: $version")
- }
-}
-
-task pandoc(type: Exec) {
- group = 'Documentation'
- def pandoc_args = ['--from', 'markdown_github',
- '--to', 'html5',
- '-s',
- '-c', 'github-pandoc.css',
- '-o', 'docs/README.html',
- 'README.md']
- if (Os.isFamily(Os.FAMILY_WINDOWS)) {
- commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
- } else {
- executable 'pandoc'
- args pandoc_args
- }
- standardOutput = new ByteArrayOutputStream()
- ext.output = {
- return standardOutput.toString()
- }
-}
diff --git a/clean.sh b/clean.sh
deleted file mode 100755
index 552252d..0000000
--- a/clean.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-DEBUG=false
-
-rm="rm -rf"
-
-if [ "$DEBUG" = true ]; then
- rm="echo rm -rf"
-fi
-
-buildkt="kobalt/src/Build.kt"
-
-name=$(cat $buildkt | grep -m 1 "name = " | cut -d"\"" -f 2)
-group=$(cat $buildkt | grep -m 1 "group = " | cut -d"\"" -f 2)
-
-if [ -z "$1" ]; then
- version=$(cat $buildkt | grep -m 1 "version = " | cut -d"\"" -f 2)
-else
- version="$1"
-fi
-
-maven="/k/maven/repository/${group//.//}/${name}/${version}"
-kobalt="$HOME/.kobalt/cache/${group//.//}/${name}/${version}"
-localRepo="$HOME/.kobalt/localMavenRepo/${group//.//}/${name}/${version}"
-
-read -p "Delete version ${version}? " -n 1 -r
-echo
-if [[ $REPLY =~ ^[Yy]$ ]]; then
- for dir in "$kobalt" "$maven" "$localRepo"; do
- if [ -d "$dir" ]; then
- echo -e "Deleting : \e[32;1m$dir\e[0m"
- $rm "$dir"
- else
- echo -e "Not Found: \e[31;1m$dir\e[0m"
- fi
- done
-fi
\ No newline at end of file
diff --git a/config/pmd.xml b/config/pmd.xml
new file mode 100644
index 0000000..2641880
--- /dev/null
+++ b/config/pmd.xml
@@ -0,0 +1,109 @@
+
+
+ Erik's Ruleset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/spotbugs/excludeFilter.xml b/config/spotbugs/excludeFilter.xml
deleted file mode 100644
index ddb2db1..0000000
--- a/config/spotbugs/excludeFilter.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
diff --git a/docs/README.html b/docs/README.html
index a53c851..3101738 100644
--- a/docs/README.html
+++ b/docs/README.html
@@ -1,91 +1,218 @@
-
+
-
-
-
-
-
-
-
+
-Semantic Version Annotation Processor
-
-
-An annotation processor that automatically generates a GeneratedVersion
class based on a Mustache template and containing the semantic version (major, minor, patch, etc.) that is read from a Properties
file or defined in the annotation .
-This processor was inspired by Cédric Beust's version-processor and works well in conjunction with the Semantic Version Plugin for Gradle .
+Semantic Version
+Annotation Processor
+
+
+An annotation
+processor that automatically generates a
+GeneratedVersion
class based on a Mustache template and containing
+the semantic version (major, minor,
+patch, etc.) that is read from a Properties
+file or defined in the annotation .
+This processor was inspired by Cédric Beust's version-processor
+and works well in conjunction with the Semantic
+Version Plugin for Gradle .
+Table of Contents
+
Examples
Using annotation elements:
-import net.thauvin.erik.semver.Version;
-
-@Version (major = 1 , minor = 0 , patch = 0 , preRelease = "beta" )
-public class A {
-// ...
+import net . thauvin . erik . semver . Version ;
+
+@Version ( major = 2 , minor = 1 , patch = 1 , preRelease = "beta" )
+public class A {
+ // ...
+}
-import net.thauvin.erik.semver.Version;
-
-@Version (properties = "version.properties" )
-public class A {
-// ...
-# version.properties
-version.major = 1
-version.minor = 0
-version.patch = 0
-version.prerelease = beta
-View Example
+import net . thauvin . erik . semver . Version ;
+
+@Version ( properties = "version.properties" )
+public class A {
+ // ...
+}
+# version.properties
+version.major = 1
+version.minor = 0
+version.patch = 0
+version.prerelease = beta
+View
+Examples
Template
-Upon running the annotation processor, a source file GeneratedVersion.java
is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable Mustache template.
-To use your own template, simply create a version.mustache
file in the project's root directory. The processor will automatically look for it.
+Upon running the annotation processor, a source file GeneratedVersion.java
+is automatically generated with static methods to access the semantic
+version data. The source is based on a fully customizable Mustache template .
+To use your own template, simply create a
+version.mustache
file in the project's root directory. The
+processor will automatically look for it.
To specify your own template name, use:
-@Version (template = "version.mustache" )
-public class A {
-// ...
+@Version ( template = "version.mustache" )
+public class A {
+ // ...
+}
Default Template
-The default template implements the following static fields:
+The default
+template implements the following static variables:
BUILDDATE
The build date.
-java.util.Date
+java.util.Date
VERSION
@@ -131,56 +259,42 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
alpha
+PRERELASE_PREFIX
+The pre-release prefix
+-
+
+
BUILDMETA
The build metadata, if any.
001
-
-
-And the following methods/functions:
-
-
-
-
-
-
-
-
-
-
-
-preReleaseWithPrefix()
-Returns the pre-release with a prefix, -
by default.
--alpha
-
-buildMetaWithPrefix()
-Returns the build metadata with a prefix, +
by default.
-+001
+BUILDMETA_PREFIX
+The metadata prefix.
++
+
+
+SEPARATOR
+The version separator.
+.
Custom Template
A very simple custom template might look something like:
-/* version.mustache */
-package {{packageName}}
-
-import java.util.Date;
-
-public final class {{className}} {
- public final static String PROJECT = "{{project}}" ;
- public final static Date DATE = new Date({{epoch}}L);
- public final static int MAJOR = {{major}};
- public final static int MINOR = {{minor}};
- public final static int PATCH = {{patch}};
- public final static String PRERELEASE = "{{preRelease}}" ;
- public final static String BUILDMETA = "{{buildMeta}}" ;
-}
-The mustache variables automatically filled in by the processor are:
+/* version.mustache */
+package {{packageName}} ;
+
+import java . util . Date ;
+
+public final class {{ className}} {
+ public final static String PROJECT = "{{project}}" ;
+ public final static Date DATE = new Date ({{ epoch}} L);
+ public final static String VERSION = "{{semver}}" ;
+}
+The mustache variables automatically filled in by the processor
+are:
{{preRelease}}
-The pre/release version.
+The pre-release version.
String
+{{preReleasePrefix}}
+The pre-release prefix.
+String
+
+
{{buildMeta}}
The build metadata version.
String
+
+{{buildMetaPrefix}}
+The metadata prefix.
+String
+
+
+{{separator}}
+The version separator.
+String
+
+
+{{semver}}
or
+{{version}}
+The full semantic version.
+String
+
-Please also look at this example using java.time
-Elements & Properties
+Elements & Properties
The following annotation elements and properties are available:
@@ -281,42 +415,62 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
+preReleasePrefix
+version.prerelease.prefix
+The pre-release prefix.
+-
+
+
buildMeta
version.buildmeta
The build metadata version.
+
+buildMetaPrefix
+version.buildmeta.prefix
+The metadata prefix.
++
+
+separator
+version.separator
+The version separator.
+.
+
+
packageName
The package name.
Same as annotated class
-
+
className
The name of the generated class.
GeneratedVersion
-
+
properties
The properties file.
-
+
template
The template file.
version.mustache
-
+
type
-Either java
or kt
for Kotlin.
+Either java
or
+kt
for Kotlin.
java
-
+
keysPrefix
The prefix for all property keys.
@@ -324,71 +478,183 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
-In order to easily incorporate with existing projects, the property keys may be assigned custom values:
-@Version (
- properties = "example.properties" ,
- keysPrefix = "example."
- majorKey = "maj" ,
- minorKey = "min" ,
- patchKey = "build" ,
- preReleaseKey = "rel" ,
- buildMetaKey = "meta" ,
- projectKey = "project"
-)
-public class Example {
-// ...
-# example.properties
-example.project = Example
-example.maj = 1
-example.min = 0
-example.build = 0
-example.rel = beta
-example.meta =
-# ...
+In order to easily incorporate with existing projects, the property
+keys may be assigned custom values:
+@Version (
+ properties = "example.properties" ,
+ keysPrefix = "example." ,
+ majorKey = "maj" ,
+ minorKey = "min" ,
+ patchKey = "build" ,
+ preReleaseKey = "rel" ,
+ buildMetaKey = "meta" ,
+ projectKey = "project"
+)
+public class Example {
+ // ...
+}
+# example.properties
+example.project = Example
+example.maj = 1
+example.min = 0
+example.build = 0
+example.rel = beta
+example.meta =
+# ...
-⚠️ keysPrefix
is a new element in 1.1.0
and may break older versions when using custom property keys.
-⚡ A quick fix is to include keysPrefix=""
in the annotation to remove the default version.
prefix.
+⚠️
+keysPrefix
is a new element staring in 1.1.0
+and may break older versions when using custom property keys.
+⚡ A quick fix is to include
+keysPrefix=""
in the annotation to remove the default
+version.
prefix.
-Usage with Maven, Grail, Kobalt and Kotlin
-Maven
-To install and run from Maven , configure an artifact as follows:
-<dependency>
- <groupId> net.thauvin.erik</groupId>
- <artifactId> semver</artifactId>
- <version> 1.1.0-beta</version>
-</dependency>
-Gradle
-Class Generation
-To install and run from Gradle , add the following to the build.gradle
file:
-dependencies {
- annotationProcessor 'net.thauvin.erik:semver:1.1.0-beta'
- compileOnly 'net.thauvin.erik:semver:1.1.0-beta'
-}
-The GeneratedVersion
class will be automatically created in the build/generated
directory upon compiling.
-Class & Source Generation
-In order to also incorporate the generated source code into the source tree
, add the following to the very top of the build.gradle
file:
-compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
-The GeneratedVersion.java
file will now be located in src/generated
.
-Please look at the build.gradle file in the Java example module directory for a sample.
-Kobalt
-To install and run from Kobalt , add the following to the Build.kt
file:
-dependencies {
- apt("net.thauvin.erik:semver:1.1.0-beta")
- compileOnly("net.thauvin.erik:semver:1.1.0-beta")
-}
-Please look at the Build.kt file in the Kotlin example module directory for a sample.
-Kotlin
-The annotation processor also supports Kotlin .
-To generate a Kotlin version file, simply specify the type
as follows:
-import net.thauvin .erik .semver .Version
-
-@Version (properties = "version.properties" , type="kt" )
-open class Main {
-// ...
-The Kotlin default template implements the same static fields and functions as the Java template .
-Please look at the Kotlin example project for samples on using Gradle (build.gradle.kts ) and Kobalt (Build.kt ).
+Maven
+To install and run from Maven , configure an artifact as
+follows:
+ <dependency >
+ <groupId >net.thauvin.erik</groupId >
+ <artifactId >semver</artifactId >
+ <version >1.2.1</version >
+ </dependency >
+Please look at pom.xml
+in the examples/java
+directory for a sample:
+
+bld
+To install and run from bld , just
+add the dependency to your build file:
+public class ExampleBuild extends Project {
+ public ExampleBuild () {
+ // ...
+ scope ( compile)
+ . include ( dependency ( "net.thauvin.erik" , "semver" , version ( 1 , 2 , 1 )));
+ }
+}
+Please look at ExampleBuild
+in the examples/java/bld
+directory for a sample. It also shows how to incorporate the generated
+code into the source tree
, more information is also
+available here .
+bld also has a Generated
+Version extension which provides similar functionalities.
+Gradle
+Class Generation
+To install and run from Gradle , add
+the following to build.gradle :
+ repositories {
+ mavenCentral ()
+}
+
+ dependencies {
+ annotationProcessor 'net.thauvin.erik:semver:1.2.1'
+ compileOnly 'net.thauvin.erik:semver:1.2.1'
+}
+
+ tasks. withType ( JavaCompile). configureEach {
+ options. compilerArgs += [ "-Asemver.project.dir= $projectDir " ]
+}
+The directory containing the configuration files
+(version.properties
, version.mustache
) must be
+specified using the semver.project.dir
processor
+argument.
+The GeneratedVersion.java
+class will be automatically created in the build/generated
+directory upon compiling.
+Please look at build.gradle
+in the examples/java/gradle
+directory for a sample.
+Class & Source Generation
+In order to also incorporate the generated source code into the
+source tree
, add the following to build.gradle :
+ tasks. withType ( JavaCompile). configureEach {
+ options. generatedSourceOutputDirectory. set ( file ( " ${ projectDir} /src/generated/java" ))
+}
+The GeneratedVersion.java
+file will now be located in src/generated
.
+Kotlin
+The annotation processor also supports Kotlin .
+To generate a Kotlin version file, simply specify the
+type
as follows:
+import net . thauvin . erik . semver . Version
+
+@Version ( properties = "version.properties" , type= "kt" )
+open class Main {
+ // ...
+}
+The Kotlin
+default template implements the same static fields and functions as
+the Java template .
+Please look at the examples/kotlin
+project for a build.gradle.kts
+sample.
+Kotlin & Gradle
+To install and run from Gradle , add
+the following to build.gradle.kts :
+var semverProcessor = "net.thauvin.erik:semver:1.2.1"
+
+ dependencies {
+ kapt( semverProcessor)
+ compileOnly( semverProcessor)
+}
+
+ kapt {
+ arguments {
+ arg( "semver.project.dir" , projectDir)
+ }
+}
+The directory containing the configuration files
+(version.properties
, version.mustache
) must be
+specified using the semver.project.dir
processor
+argument.
Auto-Increment
-Incrementing the version is best left to your favorite build system. For a solution using Gradle, please have a look at the Semver Version Plugin for Gradle .
-There are also full examples in both Java and Kotlin showing how to use both the plugin and annotation processor concurrently.
+Incrementing the version is best left to your favorite build system.
+For a solution using Gradle, please have a look at the Semver Version
+Plugin for Gradle .
+There are also full examples
+in both Java
+and Kotlin
+showing how to use both the plugin and annotation processor
+concurrently.
+Contributing
+If you want to contribute to this project, all you have to do is
+clone the GitHub repository:
+git clone git@github.com:ethauvin/semver.git
+Then use bld to build:
+cd semver
+./bld compile
+The project has an IntelliJ
+IDEA project structure. You can just open it after all the
+dependencies were downloaded and peruse the code.
diff --git a/examples/.gitignore b/examples/.gitignore
deleted file mode 100644
index 91cf804..0000000
--- a/examples/.gitignore
+++ /dev/null
@@ -1,32 +0,0 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-**/src/*.class
-*.code-workspace
-*.iws
-*.properties
-*.sublime-*
-.classpath
-.DS_Store
-.gradle
-.kobalt
-.nb-gradle
-.project
-.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/target
-/test-output
-ehthumbs.db
-kobaltBuild
-Thumbs.db
\ No newline at end of file
diff --git a/examples/examples.sh b/examples/examples.sh
index d0895bc..514f874 100755
--- a/examples/examples.sh
+++ b/examples/examples.sh
@@ -1,17 +1,34 @@
#!/bin/bash
+# Version 1.0
+
if [ $# -eq 0 ]; then
- echo "Usage: $0 [...]"
- exit 1
+ echo "Usage: $0 "
+ exit 1
fi
+# set the examples directories
+declare -a examples=(
+ "java/bld"
+ "java/gradle"
+ "kotlin")
+
dir=$(dirname "$(readlink -f "$0")")
-color=$(tput setaf 6)
+cyan=$(tput setaf 6)
normal=$(tput sgr0)
-for ex in "java" "kotlin"; do
- cd "$dir/$ex" || exit 1
- echo "> Project: ${color}${ex}${normal}"
- gradle clean "$@" --console=plain --no-build-cache || exit 1
- echo
-done
\ No newline at end of file
+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}"
+ if [ -x "bld" ]; then
+ ./bld compile "$@" || exit 1
+ else
+ ./gradlew --console=plain --no-build-cache clean "$@" || exit 1
+ fi
+ ((i++))
+done
diff --git a/examples/java/.editorconfig b/examples/java/.editorconfig
deleted file mode 100644
index a6971e1..0000000
--- a/examples/java/.editorconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-[*]
-insert_final_newline=true
diff --git a/examples/java/.gitignore b/examples/java/.gitignore
deleted file mode 100644
index 51e51c5..0000000
--- a/examples/java/.gitignore
+++ /dev/null
@@ -1,28 +0,0 @@
-**/.idea/dictionaries
-**/.idea/gradle.xml
-**/.idea/libraries
-**/.idea/tasks.xml
-**/.idea/workspace.xml
-*.iws
-.DS_Store
-.classpath
-.gradle
-.kobalt
-.nb-gradle
-.project
-.settings
-/bin
-/build
-/deploy
-/dist
-/gen
-/gradle.properties
-/libs
-/local.properties
-/out
-/proguard-project.txt
-/project.properties
-/test-output
-Thumbs.db
-ehthumbs.db
-kobaltBuild
\ No newline at end of file
diff --git a/examples/java/.idea/.name b/examples/java/.idea/.name
deleted file mode 100644
index 1658a34..0000000
--- a/examples/java/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-examples-java
\ No newline at end of file
diff --git a/examples/java/.idea/compiler.xml b/examples/java/.idea/compiler.xml
deleted file mode 100644
index f0a6a7b..0000000
--- a/examples/java/.idea/compiler.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/java/.idea/misc.xml b/examples/java/.idea/misc.xml
deleted file mode 100644
index e707cdd..0000000
--- a/examples/java/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/java/.idea/modules.xml b/examples/java/.idea/modules.xml
deleted file mode 100644
index e27b37a..0000000
--- a/examples/java/.idea/modules.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/java/.idea/modules/examples-java.iml b/examples/java/.idea/modules/examples-java.iml
deleted file mode 100644
index a57fa1a..0000000
--- a/examples/java/.idea/modules/examples-java.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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
deleted file mode 100644
index f9a8e31..0000000
--- a/examples/java/.idea/modules/examples-java_main.iml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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
deleted file mode 100644
index a6695cc..0000000
--- a/examples/java/.idea/modules/examples-java_test.iml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/java/bld/.gitignore b/examples/java/bld/.gitignore
new file mode 100644
index 0000000..b53292f
--- /dev/null
+++ b/examples/java/bld/.gitignore
@@ -0,0 +1,56 @@
+.gradle
+.DS_Store
+build
+lib/bld/**
+!lib/bld/bld-wrapper.jar
+!lib/bld/bld-wrapper.properties
+lib/compile/
+lib/provided/
+lib/runtime/
+lib/standalone/
+lib/test/
+
+# IDEA ignores
+
+# User-specific
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Editor-based Rest Client
+.idea/httpRequests
\ No newline at end of file
diff --git a/examples/java/bld/.idea/.gitignore b/examples/java/bld/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/examples/java/bld/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/examples/java/bld/.idea/.name b/examples/java/bld/.idea/.name
new file mode 100644
index 0000000..4bd9ff6
--- /dev/null
+++ b/examples/java/bld/.idea/.name
@@ -0,0 +1 @@
+semver-examples-bld
\ No newline at end of file
diff --git a/examples/java/bld/.idea/app.iml b/examples/java/bld/.idea/app.iml
new file mode 100644
index 0000000..082bb1c
--- /dev/null
+++ b/examples/java/bld/.idea/app.iml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/bld.iml b/examples/java/bld/.idea/bld.iml
new file mode 100644
index 0000000..e63e11e
--- /dev/null
+++ b/examples/java/bld/.idea/bld.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/bld.xml b/examples/java/bld/.idea/bld.xml
new file mode 100644
index 0000000..6600cee
--- /dev/null
+++ b/examples/java/bld/.idea/bld.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/inspectionProfiles/Project_Default.xml b/examples/java/bld/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1e01b48
--- /dev/null
+++ b/examples/java/bld/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/intellij-javadocs-4.0.1.xml b/examples/java/bld/.idea/intellij-javadocs-4.0.1.xml
new file mode 100644
index 0000000..7653cff
--- /dev/null
+++ b/examples/java/bld/.idea/intellij-javadocs-4.0.1.xml
@@ -0,0 +1,204 @@
+
+
+
+
+ UPDATE
+ false
+ true
+
+ METHOD
+ TYPE
+ FIELD
+
+
+ PUBLIC
+ DEFAULT
+ PROTECTED
+
+
+
+
+
+ ^.*(public|protected|private)*.+interface\s+\w+.*
+ /**\n
+ * The interface ${name}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+ */
+
+
+ ^.*(public|protected|private)*.+enum\s+\w+.*
+ /**\n
+ * The enum ${name}.\n
+ */
+
+
+ ^.*(public|protected|private)*.+class\s+\w+.*
+ /**\n
+ * The type ${name}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+ */
+
+
+ .+
+ /**\n
+ * The type ${name}.\n
+ */
+
+
+
+
+ .+
+ /**\n
+ * Instantiates a new ${name}.\n
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+
+
+ ^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+
+ /**\n
+ * Gets ${partName}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if isNotVoid>
+ *\n
+ * @return the ${partName}\n
+</#if>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+ ^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+
+ /**\n
+ * Sets ${partName}.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if isNotVoid>
+ *\n
+ * @return the ${partName}\n
+</#if>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+ ^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+
+ /**\n
+ * The entry point of application.\n
+
+ <#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+ * @param ${element.parameterList.parameters[0].name} the input arguments\n
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+ .+
+ /**\n
+ * ${name}<#if isNotVoid> ${return}</#if>.\n
+<#if element.typeParameters?has_content> * \n
+</#if>
+<#list element.typeParameters as typeParameter>
+ * @param <${typeParameter.name}> the type parameter\n
+</#list>
+<#if element.parameterList.parameters?has_content>
+ *\n
+</#if>
+<#list element.parameterList.parameters as parameter>
+ * @param ${parameter.name} the ${paramNames[parameter.name]}\n
+</#list>
+<#if isNotVoid>
+ *\n
+ * @return the ${return}\n
+</#if>
+<#if element.throwsList.referenceElements?has_content>
+ *\n
+</#if>
+<#list element.throwsList.referenceElements as exception>
+ * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
+</#list>
+ */
+
+
+
+
+ ^.*(public|protected|private)*.+static.*(\w\s\w)+.+
+ /**\n
+ * The constant ${element.getName()}.\n
+ */
+
+
+ ^.*(public|protected|private)*.*(\w\s\w)+.+
+ /**\n
+ <#if element.parent.isInterface()>
+ * The constant ${element.getName()}.\n
+<#else>
+ * The ${name}.\n
+</#if> */
+
+
+ .+
+ /**\n
+ <#if element.parent.isEnum()>
+ *${name} ${typeName}.\n
+<#else>
+ * The ${name}.\n
+</#if>*/
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/libraries/bld.xml b/examples/java/bld/.idea/libraries/bld.xml
new file mode 100644
index 0000000..153a060
--- /dev/null
+++ b/examples/java/bld/.idea/libraries/bld.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/java/bld/.idea/libraries/compile.xml b/examples/java/bld/.idea/libraries/compile.xml
new file mode 100644
index 0000000..5316b95
--- /dev/null
+++ b/examples/java/bld/.idea/libraries/compile.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/libraries/runtime.xml b/examples/java/bld/.idea/libraries/runtime.xml
new file mode 100644
index 0000000..d4069f2
--- /dev/null
+++ b/examples/java/bld/.idea/libraries/runtime.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/libraries/test.xml b/examples/java/bld/.idea/libraries/test.xml
new file mode 100644
index 0000000..05f52ce
--- /dev/null
+++ b/examples/java/bld/.idea/libraries/test.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/misc.xml b/examples/java/bld/.idea/misc.xml
new file mode 100644
index 0000000..5238960
--- /dev/null
+++ b/examples/java/bld/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/modules.xml b/examples/java/bld/.idea/modules.xml
new file mode 100644
index 0000000..55adcb9
--- /dev/null
+++ b/examples/java/bld/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/runConfigurations/Run Tests.xml b/examples/java/bld/.idea/runConfigurations/Run Tests.xml
new file mode 100644
index 0000000..2b503e5
--- /dev/null
+++ b/examples/java/bld/.idea/runConfigurations/Run Tests.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.idea/vcs.xml b/examples/java/bld/.idea/vcs.xml
new file mode 100644
index 0000000..c2365ab
--- /dev/null
+++ b/examples/java/bld/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/bld/.vscode/launch.json b/examples/java/bld/.vscode/launch.json
new file mode 100644
index 0000000..30a8889
--- /dev/null
+++ b/examples/java/bld/.vscode/launch.json
@@ -0,0 +1,11 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "Run Tests",
+ "request": "launch",
+ "mainClass": "com.example.ExampleTest"
+ }
+ ]
+}
diff --git a/examples/java/bld/.vscode/settings.json b/examples/java/bld/.vscode/settings.json
new file mode 100644
index 0000000..ba429d0
--- /dev/null
+++ b/examples/java/bld/.vscode/settings.json
@@ -0,0 +1,15 @@
+{
+ "java.project.sourcePaths": [
+ "src/main/java",
+ "src/main/resources",
+ "src/test/java",
+ "src/test/resources",
+ "src/bld/java",
+ "src/bld/resources"
+ ],
+ "java.configuration.updateBuildConfiguration": "automatic",
+ "java.project.referencedLibraries": [
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar"
+ ]
+}
diff --git a/examples/java/bld/README.md b/examples/java/bld/README.md
new file mode 100644
index 0000000..d1f800f
--- /dev/null
+++ b/examples/java/bld/README.md
@@ -0,0 +1,10 @@
+## Examples
+
+To compile & run the examples:
+
+```console
+./bld compile
+
+./bld run
+./bld run-example
+```
diff --git a/examples/java/bld/bld b/examples/java/bld/bld
new file mode 100755
index 0000000..80d2986
--- /dev/null
+++ b/examples/java/bld/bld
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ExampleBuild "$@"
\ No newline at end of file
diff --git a/examples/java/bld/bld.bat b/examples/java/bld/bld.bat
new file mode 100644
index 0000000..084bb72
--- /dev/null
+++ b/examples/java/bld/bld.bat
@@ -0,0 +1,4 @@
+@echo off
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.ExampleBuild %*
\ No newline at end of file
diff --git a/examples/java/bld/example.mustache b/examples/java/bld/example.mustache
new file mode 100644
index 0000000..70125c1
--- /dev/null
+++ b/examples/java/bld/example.mustache
@@ -0,0 +1,21 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package {{packageName}};
+
+import java.util.Date;
+
+public final class {{className}} {
+ public static final String PROJECT = "{{project}}";
+ public static final Date BUILDDATE = new Date({{epoch}}L);
+ public static final String VERSION = "{{version}}";
+
+ /**
+ * Disables the default constructor.
+ */
+ private {{className}}() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
+}
diff --git a/examples/java/bld/example.properties b/examples/java/bld/example.properties
new file mode 100644
index 0000000..d0b5ce4
--- /dev/null
+++ b/examples/java/bld/example.properties
@@ -0,0 +1,9 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Apr 27 17:04:13 PDT 2019
+example.buildmeta=T800
+example.major=8
+example.minor=4
+example.patch=97
+example.prerelease=alpha
+example.project=Java Example
+example.semver=8.4.97-alpha+T800
diff --git a/examples/java/bld/lib/bld/bld-wrapper.jar b/examples/java/bld/lib/bld/bld-wrapper.jar
new file mode 100644
index 0000000..ecc7a41
Binary files /dev/null and b/examples/java/bld/lib/bld/bld-wrapper.jar differ
diff --git a/examples/java/bld/lib/bld/bld-wrapper.properties b/examples/java/bld/lib/bld/bld-wrapper.properties
new file mode 100644
index 0000000..78bca2d
--- /dev/null
+++ b/examples/java/bld/lib/bld/bld-wrapper.properties
@@ -0,0 +1,7 @@
+bld.downloadExtensionJavadoc=false
+bld.downloadExtensionSources=true
+bld.downloadLocation=
+bld.extensions=
+bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
+bld.sourceDirectories=
+bld.version=2.2.1
diff --git a/examples/java/bld/src/bld/java/com/example/ExampleBuild.java b/examples/java/bld/src/bld/java/com/example/ExampleBuild.java
new file mode 100644
index 0000000..9c4199d
--- /dev/null
+++ b/examples/java/bld/src/bld/java/com/example/ExampleBuild.java
@@ -0,0 +1,53 @@
+package com.example;
+
+import rife.bld.BuildCommand;
+import rife.bld.Project;
+import rife.bld.operations.JavacOptions.Processing;
+
+import java.io.File;
+import java.util.List;
+
+import static rife.bld.dependencies.Repository.*;
+import static rife.bld.dependencies.Scope.provided;
+
+/**
+ * Example build.
+ */
+public class ExampleBuild extends Project {
+ public ExampleBuild() {
+ pkg = "com.example";
+ name = "Example";
+ version = version(0, 1, 0);
+
+ mainClass = "com.example.App";
+
+ testOperation().mainClass("com.example.ExampleTest");
+
+ repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
+
+ scope(provided).include(dependency("net.thauvin.erik", "semver", version(1, 2, 2, "SNAPSHOT")));
+ }
+
+ public static void main(String[] args) {
+ new ExampleBuild().start(args);
+ }
+
+ /**
+ * Saves generated source files in the {@code build/generated} directory.
+ *
+ * To incorporate the generated source code into the source tree, add this directory as an additional source
+ * location in your IDE.
+ */
+ @Override
+ public void compile() throws Exception {
+ var generated = new File(buildDirectory(), "generated");
+ var ignore = generated.mkdir();
+ compileOperation().compileOptions().process(Processing.FULL).sourceOutput(generated);
+ super.compile();
+ }
+
+ @BuildCommand(value = "run-example", summary = "Runs the example")
+ public void runExample() throws Exception {
+ runOperation().fromProject(this).mainClass("com.example.Example").execute();
+ }
+}
diff --git a/examples/java/src/main/java/com/example/Example.java b/examples/java/bld/src/main/java/com/example/App.java
similarity index 79%
rename from examples/java/src/main/java/com/example/Example.java
rename to examples/java/bld/src/main/java/com/example/App.java
index ba725b3..91134b7 100644
--- a/examples/java/src/main/java/com/example/Example.java
+++ b/examples/java/bld/src/main/java/com/example/App.java
@@ -1,12 +1,19 @@
package com.example;
import net.thauvin.erik.semver.Version;
+
import java.text.SimpleDateFormat;
+import java.util.Locale;
@Version(properties = "version.properties")
-public class Example {
+public final class App {
+ /**
+ * Command line interface.
+ *
+ * @param args The command line parameters.
+ */
public static void main(final String... args) {
- final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
+ final var sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z", Locale.US);
System.out.println("-----------------------------------------------------");
diff --git a/examples/java/bld/src/main/java/com/example/Example.java b/examples/java/bld/src/main/java/com/example/Example.java
new file mode 100644
index 0000000..1829d52
--- /dev/null
+++ b/examples/java/bld/src/main/java/com/example/Example.java
@@ -0,0 +1,21 @@
+package com.example;
+
+import net.thauvin.erik.semver.Version;
+
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+@Version(properties = "example.properties", template = "example.mustache", className = "ExampleVersion",
+ keysPrefix = "example.")
+public class Example {
+ public static void main(final String... args) {
+ final var sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
+
+ System.out.println("-- From Example -------------------------------------");
+
+ System.out.println(" " + ExampleVersion.PROJECT + ' ' + ExampleVersion.VERSION
+ + " (" + sdf.format(ExampleVersion.BUILDDATE) + ')');
+
+ System.out.println("-----------------------------------------------------");
+ }
+}
diff --git a/examples/java/bld/src/test/java/com/example/ExampleTest.java b/examples/java/bld/src/test/java/com/example/ExampleTest.java
new file mode 100644
index 0000000..f0452f2
--- /dev/null
+++ b/examples/java/bld/src/test/java/com/example/ExampleTest.java
@@ -0,0 +1,18 @@
+package com.example;
+
+public class ExampleTest {
+ private static final String HELLO = "Hello!";
+
+ public static void main(String[] args) {
+ var hello = new ExampleTest().verifyHello();
+ if (HELLO.equals(hello)) {
+ System.out.println("Succeeded");
+ } else {
+ throw new AssertionError();
+ }
+ }
+
+ String verifyHello() {
+ return HELLO;
+ }
+}
diff --git a/examples/java/bld/version.properties b/examples/java/bld/version.properties
new file mode 100644
index 0000000..dc68bf3
--- /dev/null
+++ b/examples/java/bld/version.properties
@@ -0,0 +1,9 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Apr 27 17:05:34 PDT 2019
+version.buildmeta=007
+version.major=11
+version.minor=11
+version.patch=20
+version.prerelease=beta
+version.project=Java App
+version.semver=11.11.20-beta+007
diff --git a/examples/java/build.gradle b/examples/java/build.gradle
deleted file mode 100644
index 031d82e..0000000
--- a/examples/java/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-apply plugin: 'java'
-apply plugin: 'application'
-
-// ./gradlew
-
-defaultTasks 'run'
-
-def semverProcessor = 'net.thauvin.erik:semver:1.1.0-beta'
-
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
-compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
-
-mainClassName = 'com.example.Example'
-
-repositories {
- mavenLocal()
- mavenCentral()
-}
-
-dependencies {
- annotationProcessor semverProcessor
- compileOnly semverProcessor
-}
diff --git a/examples/java/gradle/.editorconfig b/examples/java/gradle/.editorconfig
new file mode 100644
index 0000000..1f808de
--- /dev/null
+++ b/examples/java/gradle/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline = true
diff --git a/examples/java/.gitattributes b/examples/java/gradle/.gitattributes
similarity index 100%
rename from examples/java/.gitattributes
rename to examples/java/gradle/.gitattributes
diff --git a/examples/java/gradle/.gitignore b/examples/java/gradle/.gitignore
new file mode 100644
index 0000000..a78c5c2
--- /dev/null
+++ b/examples/java/gradle/.gitignore
@@ -0,0 +1,82 @@
+!.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
+.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
+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/gradle/.idea/.name b/examples/java/gradle/.idea/.name
new file mode 100644
index 0000000..2ba6afe
--- /dev/null
+++ b/examples/java/gradle/.idea/.name
@@ -0,0 +1 @@
+semver-examples-java-gradle
\ No newline at end of file
diff --git a/examples/java/gradle/.idea/compiler.xml b/examples/java/gradle/.idea/compiler.xml
new file mode 100644
index 0000000..a83902e
--- /dev/null
+++ b/examples/java/gradle/.idea/compiler.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/examples/java/gradle/.idea/encodings.xml
similarity index 100%
rename from .idea/encodings.xml
rename to examples/java/gradle/.idea/encodings.xml
diff --git a/examples/java/gradle/.idea/gradle.iml b/examples/java/gradle/.idea/gradle.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/examples/java/gradle/.idea/gradle.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/.idea/inspectionProfiles/Project_Default.xml b/examples/java/gradle/.idea/inspectionProfiles/Project_Default.xml
similarity index 100%
rename from examples/java/.idea/inspectionProfiles/Project_Default.xml
rename to examples/java/gradle/.idea/inspectionProfiles/Project_Default.xml
diff --git a/examples/java/gradle/.idea/jarRepositories.xml b/examples/java/gradle/.idea/jarRepositories.xml
new file mode 100644
index 0000000..4e9cedf
--- /dev/null
+++ b/examples/java/gradle/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/gradle/.idea/misc.xml b/examples/java/gradle/.idea/misc.xml
new file mode 100644
index 0000000..d2dd9ed
--- /dev/null
+++ b/examples/java/gradle/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/gradle/.idea/modules.xml b/examples/java/gradle/.idea/modules.xml
new file mode 100644
index 0000000..be92c07
--- /dev/null
+++ b/examples/java/gradle/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/gradle/.idea/modules/examples-java.main.iml b/examples/java/gradle/.idea/modules/examples-java.main.iml
new file mode 100644
index 0000000..974d8b3
--- /dev/null
+++ b/examples/java/gradle/.idea/modules/examples-java.main.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/gradle/.idea/vcs.xml b/examples/java/gradle/.idea/vcs.xml
new file mode 100644
index 0000000..def3818
--- /dev/null
+++ b/examples/java/gradle/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/gradle/README.md b/examples/java/gradle/README.md
new file mode 100644
index 0000000..f9153e3
--- /dev/null
+++ b/examples/java/gradle/README.md
@@ -0,0 +1,9 @@
+## Examples
+
+To run the examples:
+
+```console
+./gradlew run
+./gradlew runExample
+```
+
diff --git a/examples/java/gradle/build.gradle b/examples/java/gradle/build.gradle
new file mode 100644
index 0000000..5f1581e
--- /dev/null
+++ b/examples/java/gradle/build.gradle
@@ -0,0 +1,40 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'com.github.ben-manes.versions' version '0.51.0'
+}
+
+defaultTasks 'run'
+
+final def semverProcessor = 'net.thauvin.erik:semver:1.2.2-SNAPSHOT'
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+ maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
+}
+
+dependencies {
+ annotationProcessor semverProcessor
+ implementation semverProcessor
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+}
+
+application {
+ mainClass = 'com.example.App'
+}
+
+tasks.withType(JavaCompile).configureEach {
+ options.generatedSourceOutputDirectory.set(file("${projectDir}/src/generated/java"))
+ options.compilerArgs += ["-Asemver.project.dir=$projectDir"]
+}
+
+tasks.register("runExample", JavaExec) {
+ group = 'application'
+ classpath = sourceSets.main.runtimeClasspath
+ mainClass.set('com.example.Example')
+}
diff --git a/examples/java/gradle/example.mustache b/examples/java/gradle/example.mustache
new file mode 100644
index 0000000..70125c1
--- /dev/null
+++ b/examples/java/gradle/example.mustache
@@ -0,0 +1,21 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package {{packageName}};
+
+import java.util.Date;
+
+public final class {{className}} {
+ public static final String PROJECT = "{{project}}";
+ public static final Date BUILDDATE = new Date({{epoch}}L);
+ public static final String VERSION = "{{version}}";
+
+ /**
+ * Disables the default constructor.
+ */
+ private {{className}}() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
+}
diff --git a/examples/java/gradle/example.properties b/examples/java/gradle/example.properties
new file mode 100644
index 0000000..d0b5ce4
--- /dev/null
+++ b/examples/java/gradle/example.properties
@@ -0,0 +1,9 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Apr 27 17:04:13 PDT 2019
+example.buildmeta=T800
+example.major=8
+example.minor=4
+example.patch=97
+example.prerelease=alpha
+example.project=Java Example
+example.semver=8.4.97-alpha+T800
diff --git a/examples/java/gradle/gradle/wrapper/gradle-wrapper.jar b/examples/java/gradle/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..1b33c55
Binary files /dev/null and b/examples/java/gradle/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/examples/java/gradle/gradle/wrapper/gradle-wrapper.properties
similarity index 74%
rename from gradle/wrapper/gradle-wrapper.properties
rename to examples/java/gradle/gradle/wrapper/gradle-wrapper.properties
index e0b3fb8..ca025c8 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/java/gradle/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/java/gradle/gradlew b/examples/java/gradle/gradlew
new file mode 100755
index 0000000..23d15a9
--- /dev/null
+++ b/examples/java/gradle/gradlew
@@ -0,0 +1,251 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH="\\\"\\\""
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/examples/java/gradle/gradlew.bat b/examples/java/gradle/gradlew.bat
new file mode 100644
index 0000000..db3a6ac
--- /dev/null
+++ b/examples/java/gradle/gradlew.bat
@@ -0,0 +1,94 @@
+@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
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/examples/java/gradle/pom.xml b/examples/java/gradle/pom.xml
new file mode 100644
index 0000000..7ad7184
--- /dev/null
+++ b/examples/java/gradle/pom.xml
@@ -0,0 +1,64 @@
+
+
+ 4.0.0
+
+ com.example
+ Example
+ 1.0.0
+ Example
+
+
+ 1.2.0
+
+
+
+
+ net.thauvin.erik
+ semver
+ ${semver.version}
+ compile
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.14.0
+
+ 17
+ UTF-8
+ src/generated/java
+
+
+ net.thauvin.erik
+ semver
+ ${semver.version}
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.5.0
+
+
+ run
+ verify
+
+ java
+
+
+
+
+ com.example.App
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/java/settings.gradle b/examples/java/gradle/settings.gradle
similarity index 100%
rename from examples/java/settings.gradle
rename to examples/java/gradle/settings.gradle
diff --git a/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java b/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java
new file mode 100644
index 0000000..340e525
--- /dev/null
+++ b/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java
@@ -0,0 +1,21 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package com.example;
+
+import java.util.Date;
+
+public final class ExampleVersion {
+ public static final String PROJECT = "Java Example";
+ public static final Date BUILDDATE = new Date(1742447853077L);
+ public static final String VERSION = "8.4.97-alpha+T800";
+
+ /**
+ * Disables the default constructor.
+ */
+ private ExampleVersion() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
+}
diff --git a/examples/java/gradle/src/generated/java/com/example/GeneratedVersion.java b/examples/java/gradle/src/generated/java/com/example/GeneratedVersion.java
new file mode 100644
index 0000000..942ec1c
--- /dev/null
+++ b/examples/java/gradle/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 App";
+public static final Date BUILDDATE = new Date(1742447853101L);
+public static final int MAJOR = 11;
+public static final int MINOR = 11;
+public static final int PATCH = 20;
+public static final String PRERELEASE = "beta";
+public static final String PRERELEASE_PREFIX = "-";
+public static final String BUILDMETA = "007";
+public static final String BUILDMETA_PREFIX = "+";
+public static final String SEPARATOR = ".";
+public static final String VERSION = "11.11.20-beta+007";
+
+/**
+* Disables the default constructor.
+*/
+private GeneratedVersion() {
+throw new UnsupportedOperationException("Illegal constructor call.");
+}
+}
diff --git a/examples/java/gradle/src/main/java/com/example/App.java b/examples/java/gradle/src/main/java/com/example/App.java
new file mode 100644
index 0000000..91134b7
--- /dev/null
+++ b/examples/java/gradle/src/main/java/com/example/App.java
@@ -0,0 +1,31 @@
+package com.example;
+
+import net.thauvin.erik.semver.Version;
+
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+@Version(properties = "version.properties")
+public final class App {
+ /**
+ * Command line interface.
+ *
+ * @param args The command line parameters.
+ */
+ public static void main(final String... args) {
+ final var sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z", Locale.US);
+
+ System.out.println("-----------------------------------------------------");
+
+ System.out.println(" Version: " + GeneratedVersion.PROJECT + ' ' + GeneratedVersion.VERSION);
+
+ System.out.println(" Built on: " + sdf.format(GeneratedVersion.BUILDDATE));
+ System.out.println(" Major: " + GeneratedVersion.MAJOR);
+ System.out.println(" Minor: " + GeneratedVersion.MINOR);
+ System.out.println(" Patch: " + GeneratedVersion.PATCH);
+ System.out.println(" PreRelease: " + GeneratedVersion.PRERELEASE);
+ System.out.println(" BuildMetaData: " + GeneratedVersion.BUILDMETA);
+
+ System.out.println("-----------------------------------------------------");
+ }
+}
diff --git a/examples/java/gradle/src/main/java/com/example/Example.java b/examples/java/gradle/src/main/java/com/example/Example.java
new file mode 100644
index 0000000..ce7b795
--- /dev/null
+++ b/examples/java/gradle/src/main/java/com/example/Example.java
@@ -0,0 +1,27 @@
+package com.example;
+
+import net.thauvin.erik.semver.Version;
+
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+@Version(properties = "example.properties", template = "example.mustache", className = "ExampleVersion",
+ keysPrefix = "example.")
+public final class Example {
+ /**
+ * Command line interface.
+ *
+ * @param args The command line parameters.
+ */
+ public static void main(final String... args) {
+ final var sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
+
+ System.out.println("-- From Example -------------------------------------");
+
+ System.out.println(" " + ExampleVersion.PROJECT + ' ' + ExampleVersion.VERSION
+ + " (" + sdf.format(ExampleVersion.BUILDDATE) + ')');
+
+ System.out.println("-----------------------------------------------------");
+ }
+}
+
diff --git a/examples/java/gradle/version.properties b/examples/java/gradle/version.properties
new file mode 100644
index 0000000..dc68bf3
--- /dev/null
+++ b/examples/java/gradle/version.properties
@@ -0,0 +1,9 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Apr 27 17:05:34 PDT 2019
+version.buildmeta=007
+version.major=11
+version.minor=11
+version.patch=20
+version.prerelease=beta
+version.project=Java App
+version.semver=11.11.20-beta+007
diff --git a/examples/java/gradle/wrapper/gradle-wrapper.jar b/examples/java/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 29953ea..0000000
Binary files a/examples/java/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/examples/java/gradlew b/examples/java/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/examples/java/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# 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
deleted file mode 100644
index f955316..0000000
--- a/examples/java/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-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=
-
-@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
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%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%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/examples/java/kobalt/src/Build.kt b/examples/java/kobalt/src/Build.kt
deleted file mode 100644
index 911a863..0000000
--- a/examples/java/kobalt/src/Build.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-import com.beust.kobalt.*
-import com.beust.kobalt.plugin.application.*
-import com.beust.kobalt.plugin.apt.*
-import com.beust.kobalt.plugin.java.javaCompiler
-import com.beust.kobalt.plugin.publish.*
-import com.beust.kobalt.plugin.packaging.*
-import java.io.FileInputStream
-import java.util.*
-
-// ./kobaltw run
-
-val bs = buildScript {
- repos(localMaven())
-}
-
-fun StringBuilder.prepend(s: String): StringBuilder {
- if (this.isNotEmpty()) {
- this.insert(0, s)
- }
- return this
-}
-
-val example = project {
-
- name = "example"
-
- fun versionFor(): String {
- val propsFile = "version.properties"
- val majorKey = "version.major"
- val minorKey = "version.minor"
- val patchKey = "version.patch"
- val metaKey = "version.buildmeta"
- val preKey = "version.prerelease"
-
- val p = Properties().apply { FileInputStream(propsFile).use { fis -> load(fis) } }
-
- return (p.getProperty(majorKey, "1") + "." + p.getProperty(minorKey, "0") + "." + p.getProperty(patchKey, "0")
- + StringBuilder(p.getProperty(preKey, "")).prepend("-")
- + StringBuilder(p.getProperty(metaKey, "")).prepend("+"))
- }
-
- version = versionFor()
-
- val mainClassName = "com.example.Example"
- val processorJar = "net.thauvin.erik:semver:1.0.1"
-
- dependencies {
- apt(processorJar)
- compileOnly(processorJar)
- }
-
- apt {
- //outputDir = "../src/generated/java/"
- }
-
- install {
- target = "deploy"
- }
-
- javaCompiler {
- args("-source", "1.8", "-target", "1.8")
- }
-
- assemble {
- jar {
- manifest {
- attributes("Main-Class", mainClassName)
- }
- }
- }
-
- application {
- mainClass = mainClassName
- }
-}
diff --git a/examples/java/kobalt/wrapper/kobalt-wrapper.jar b/examples/java/kobalt/wrapper/kobalt-wrapper.jar
deleted file mode 100644
index 22d3ef5..0000000
Binary files a/examples/java/kobalt/wrapper/kobalt-wrapper.jar and /dev/null differ
diff --git a/examples/java/kobalt/wrapper/kobalt-wrapper.properties b/examples/java/kobalt/wrapper/kobalt-wrapper.properties
deleted file mode 100644
index f16e1df..0000000
--- a/examples/java/kobalt/wrapper/kobalt-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-kobalt.version=1.0.118
\ No newline at end of file
diff --git a/examples/java/kobaltw b/examples/java/kobaltw
deleted file mode 100755
index c5186d5..0000000
--- a/examples/java/kobaltw
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $*
diff --git a/examples/java/kobaltw.bat b/examples/java/kobaltw.bat
deleted file mode 100644
index d578071..0000000
--- a/examples/java/kobaltw.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@echo off
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-java -jar "%DIRNAME%/kobalt/wrapper/kobalt-wrapper.jar" %*
diff --git a/examples/java/src/generated/java/com/example/GeneratedVersion.java b/examples/java/src/generated/java/com/example/GeneratedVersion.java
deleted file mode 100644
index e1c1f06..0000000
--- a/examples/java/src/generated/java/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 = "Example";
- public final static Date BUILDDATE = new Date(1541197895495L);
- public final static int MAJOR = 2;
- public final static int MINOR = 17;
- public final static int PATCH = 52;
- public final static String PRERELEASE = "beta";
- public final static String BUILDMETA = "007";
-
- /**
- * 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/java/version.properties b/examples/java/version.properties
deleted file mode 100644
index d8f031d..0000000
--- a/examples/java/version.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-#Generated by the Semver Plugin for Gradle
-#Wed Jul 11 00:11:38 PDT 2018
-version.prerelease=beta
-version.minor=17
-version.buildmeta=007
-version.patch=52
-version.major=2
-version.project=Example
diff --git a/examples/kotlin/.editorconfig b/examples/kotlin/.editorconfig
index a6971e1..1f808de 100644
--- a/examples/kotlin/.editorconfig
+++ b/examples/kotlin/.editorconfig
@@ -1,2 +1,2 @@
[*]
-insert_final_newline=true
+insert_final_newline = true
diff --git a/examples/kotlin/.gitignore b/examples/kotlin/.gitignore
index 32fe2fe..638960b 100644
--- a/examples/kotlin/.gitignore
+++ b/examples/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/kotlin/.idea/.name b/examples/kotlin/.idea/.name
index e3bef29..891dcea 100644
--- a/examples/kotlin/.idea/.name
+++ b/examples/kotlin/.idea/.name
@@ -1 +1 @@
-examples-kotlin
\ No newline at end of file
+semver-examples-kotlin-gradle
\ No newline at end of file
diff --git a/examples/kotlin/.idea/compiler.xml b/examples/kotlin/.idea/compiler.xml
index ed63cad..7d75596 100644
--- a/examples/kotlin/.idea/compiler.xml
+++ b/examples/kotlin/.idea/compiler.xml
@@ -1,9 +1,9 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/jarRepositories.xml b/examples/kotlin/.idea/jarRepositories.xml
new file mode 100644
index 0000000..4e9cedf
--- /dev/null
+++ b/examples/kotlin/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/kotlin.iml b/examples/kotlin/.idea/kotlin.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/examples/kotlin/.idea/kotlin.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/kotlinc.xml b/examples/kotlin/.idea/kotlinc.xml
index 5806fb3..834c71d 100644
--- a/examples/kotlin/.idea/kotlinc.xml
+++ b/examples/kotlin/.idea/kotlinc.xml
@@ -4,4 +4,7 @@
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/misc.xml b/examples/kotlin/.idea/misc.xml
index e707cdd..d2dd9ed 100644
--- a/examples/kotlin/.idea/misc.xml
+++ b/examples/kotlin/.idea/misc.xml
@@ -1,6 +1,13 @@
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/modules.xml b/examples/kotlin/.idea/modules.xml
index 26eeb73..a168080 100644
--- a/examples/kotlin/.idea/modules.xml
+++ b/examples/kotlin/.idea/modules.xml
@@ -2,9 +2,7 @@
-
-
-
+
\ No newline at end of file
diff --git a/examples/kotlin/.idea/modules/examples-kotlin.iml b/examples/kotlin/.idea/modules/examples-kotlin.iml
deleted file mode 100644
index ae8dcbb..0000000
--- a/examples/kotlin/.idea/modules/examples-kotlin.iml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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
deleted file mode 100644
index f7bffce..0000000
--- a/examples/kotlin/.idea/modules/examples-kotlin_main.iml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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
deleted file mode 100644
index 696a8f5..0000000
--- a/examples/kotlin/.idea/modules/examples-kotlin_test.iml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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/README.md b/examples/kotlin/README.md
new file mode 100644
index 0000000..d48aeba
--- /dev/null
+++ b/examples/kotlin/README.md
@@ -0,0 +1,11 @@
+## Examples
+
+To run the examples:
+
+```console
+./gradlew run
+./gradlew runJava
+./gradlew runExample
+./gradlew runJavaExample
+```
+
diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts
index 86bc0e2..c44f00c 100644
--- a/examples/kotlin/build.gradle.kts
+++ b/examples/kotlin/build.gradle.kts
@@ -1,36 +1,67 @@
-plugins {
- kotlin("jvm") version "1.3.0"
- application
- id("org.jetbrains.kotlin.kapt") version "1.3.0"
-}
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-// ./gradlew
-// ./gradlew runJava
-// ./gradlew run runJava
+plugins {
+ id("application")
+ id("com.github.ben-manes.versions") version "0.51.0"
+ kotlin("jvm") version "2.1.20"
+ kotlin("kapt") version "1.9.25"
+}
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
-var semverProcessor = "net.thauvin.erik:semver:1.1.0-beta"
+val semverProcessor = "net.thauvin.erik:semver:1.2.2-SNAPSHOT"
dependencies {
kapt(semverProcessor)
- compileOnly(semverProcessor)
+ implementation(semverProcessor)
- compile(kotlin("stdlib"))
+ implementation(kotlin("stdlib"))
+}
+
+kapt {
+ arguments {
+ arg("semver.project.dir", projectDir.absolutePath)
+ }
}
repositories {
mavenLocal()
- jcenter()
+ mavenCentral()
+ maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+}
+
+kotlin {
+ compilerOptions {
+ jvmTarget.set(JvmTarget.JVM_17)
+ }
}
application {
- mainClassName = "com.example.Main"
+ mainClass.set("com.example.App")
}
tasks {
register("runJava", JavaExec::class) {
- main = "com.example.Example"
- classpath = sourceSets["main"].runtimeClasspath
+ group = "application"
+ mainClass.set("com.example.JavaApp")
+ classpath = sourceSets.main.get().runtimeClasspath
+
+ }
+
+ register("runJavaExample", JavaExec::class) {
+ group = "application"
+ mainClass.set("com.example.JavaExample")
+ classpath = sourceSets.main.get().runtimeClasspath
+ }
+
+ register("runExample", JavaExec::class) {
+ group = "application"
+ mainClass.set("com.example.Example")
+ classpath = sourceSets.main.get().runtimeClasspath
}
}
diff --git a/examples/kotlin/example.mustache b/examples/kotlin/example.mustache
new file mode 100644
index 0000000..50b6b1a
--- /dev/null
+++ b/examples/kotlin/example.mustache
@@ -0,0 +1,22 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package {{packageName}}
+
+import java.util.Date
+
+/**
+ * Provides semantic version information.
+ *
+ * @author Semantic Version Annotation Processor
+ */
+object {{className}} {
+ @JvmField
+ val PROJECT = "{{project}}"
+ @JvmField
+ val BUILDDATE = Date({{epoch}}L)
+ @JvmField
+ val VERSION = "{{version}}"
+}
diff --git a/examples/kotlin/example.properties b/examples/kotlin/example.properties
new file mode 100644
index 0000000..6875954
--- /dev/null
+++ b/examples/kotlin/example.properties
@@ -0,0 +1,9 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Apr 27 17:04:13 PDT 2019
+example.buildmeta=T800
+example.major=8
+example.minor=4
+example.patch=97
+example.prerelease=alpha
+example.project=Kotlin Example
+example.semver=8.4.97-alpha+T800
diff --git a/examples/kotlin/gradle.properties b/examples/kotlin/gradle.properties
new file mode 100644
index 0000000..93cd554
--- /dev/null
+++ b/examples/kotlin/gradle.properties
@@ -0,0 +1 @@
+#kapt.use.worker.api=true
diff --git a/examples/kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/kotlin/gradle/wrapper/gradle-wrapper.jar
index 29953ea..1b33c55 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 e0b3fb8..ca025c8 100644
--- a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/kotlin/gradlew b/examples/kotlin/gradlew
index cccdd3d..23d15a9 100755
--- a/examples/kotlin/gradlew
+++ b/examples/kotlin/gradlew
@@ -1,78 +1,129 @@
-#!/usr/bin/env sh
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+CLASSPATH="\\\"\\\""
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -81,92 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
fi
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
exec "$JAVACMD" "$@"
diff --git a/examples/kotlin/gradlew.bat b/examples/kotlin/gradlew.bat
index f955316..db3a6ac 100644
--- a/examples/kotlin/gradlew.bat
+++ b/examples/kotlin/gradlew.bat
@@ -1,4 +1,22 @@
-@if "%DEBUG%" == "" @echo off
+@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
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -9,25 +27,29 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@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% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -35,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+set CLASSPATH=
+
@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%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/examples/kotlin/src/main/java/com/example/Example.java b/examples/kotlin/src/main/java/com/example/JavaApp.java
similarity index 82%
rename from examples/kotlin/src/main/java/com/example/Example.java
rename to examples/kotlin/src/main/java/com/example/JavaApp.java
index 51b8b0d..ef9c932 100644
--- a/examples/kotlin/src/main/java/com/example/Example.java
+++ b/examples/kotlin/src/main/java/com/example/JavaApp.java
@@ -1,10 +1,16 @@
package com.example;
import java.text.SimpleDateFormat;
+import java.util.Locale;
-public class Example {
+public final class JavaApp {
+ /**
+ * Command line interface.
+ *
+ * @param args The command line parameters.
+ */
public static void main(final String... args) {
- final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
+ final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z", Locale.US);
System.out.println("-- From Java ----------------------------------------");
@@ -19,4 +25,4 @@ public class Example {
System.out.println("-----------------------------------------------------");
}
-}
\ No newline at end of file
+}
diff --git a/examples/kotlin/src/main/java/com/example/JavaExample.java b/examples/kotlin/src/main/java/com/example/JavaExample.java
new file mode 100644
index 0000000..b9aa8a9
--- /dev/null
+++ b/examples/kotlin/src/main/java/com/example/JavaExample.java
@@ -0,0 +1,22 @@
+package com.example;
+
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+public final class JavaExample {
+ /**
+ * Command line interface.
+ *
+ * @param args The command line parameters.
+ */
+ public static void main(final String... args) {
+ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
+
+ System.out.println("-- From JavaExample -----------------------------------");
+
+ System.out.println(" " + ExampleVersion.PROJECT + ' ' + ExampleVersion.VERSION
+ + " (" + sdf.format(ExampleVersion.BUILDDATE) + ')');
+
+ System.out.println("-------------------------------------------------------");
+ }
+}
diff --git a/examples/kotlin/src/main/kotlin/com/example/Main.kt b/examples/kotlin/src/main/kotlin/com/example/App.kt
similarity index 88%
rename from examples/kotlin/src/main/kotlin/com/example/Main.kt
rename to examples/kotlin/src/main/kotlin/com/example/App.kt
index 0b30a6e..6af44aa 100644
--- a/examples/kotlin/src/main/kotlin/com/example/Main.kt
+++ b/examples/kotlin/src/main/kotlin/com/example/App.kt
@@ -2,12 +2,14 @@ package com.example
import net.thauvin.erik.semver.Version
import java.text.SimpleDateFormat
+import java.util.Locale
@Version(properties = "version.properties", type = "kt")
-class Main {
+class App {
companion object {
- @JvmStatic fun main(args: Array) {
- val sdf = SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z")
+ @JvmStatic
+ fun main(args: Array) {
+ val sdf = SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z", Locale.US)
println("-----------------------------------------------------")
@@ -23,4 +25,4 @@ class Main {
println("-----------------------------------------------------")
}
}
-}
\ No newline at end of file
+}
diff --git a/examples/kotlin/src/main/kotlin/com/example/Example.kt b/examples/kotlin/src/main/kotlin/com/example/Example.kt
new file mode 100644
index 0000000..5db8c0d
--- /dev/null
+++ b/examples/kotlin/src/main/kotlin/com/example/Example.kt
@@ -0,0 +1,23 @@
+package com.example
+
+import net.thauvin.erik.semver.Version
+import java.text.SimpleDateFormat
+import java.util.Locale
+
+@Version(properties = "example.properties", type = "kt", template = "example.mustache", className = "ExampleVersion",
+ keysPrefix = "example.")
+class Example {
+ companion object {
+ @JvmStatic
+ fun main(args: Array) {
+ val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US)
+
+ println("-------------------------------------------------------")
+
+ println(" ${ExampleVersion.PROJECT} ${ExampleVersion.VERSION} ("
+ + sdf.format(ExampleVersion.BUILDDATE) + ')')
+
+ println("-------------------------------------------------------")
+ }
+ }
+}
diff --git a/examples/kotlin/version.properties b/examples/kotlin/version.properties
index da66130..f76b3fa 100644
--- a/examples/kotlin/version.properties
+++ b/examples/kotlin/version.properties
@@ -1,8 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Fri Nov 02 18:26:53 PDT 2018
+#Sat Apr 27 17:04:13 PDT 2019
version.buildmeta=007
-version.major=3
-version.minor=17
-version.patch=52
+version.major=11
+version.minor=11
+version.patch=20
version.prerelease=beta
-version.project=Example
+version.project=Kotlin App
+version.semver=11.11.20-beta+007
diff --git a/examples/test/.editorconfig b/examples/test/.editorconfig
new file mode 100644
index 0000000..1f808de
--- /dev/null
+++ b/examples/test/.editorconfig
@@ -0,0 +1,2 @@
+[*]
+insert_final_newline = true
diff --git a/examples/test/.gitattributes b/examples/test/.gitattributes
new file mode 100644
index 0000000..6ec2ae2
--- /dev/null
+++ b/examples/test/.gitattributes
@@ -0,0 +1,5 @@
+# Set the default behavior, in case people don't have core.autocrlf set.
+* text=auto
+
+# batch files are specific to windows and always crlf
+*.bat eol=crlf
diff --git a/examples/test/.gitignore b/examples/test/.gitignore
new file mode 100644
index 0000000..a78c5c2
--- /dev/null
+++ b/examples/test/.gitignore
@@ -0,0 +1,82 @@
+!.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
+.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
+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/test/build.gradle b/examples/test/build.gradle
new file mode 100644
index 0000000..8909614
--- /dev/null
+++ b/examples/test/build.gradle
@@ -0,0 +1,34 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'com.github.ben-manes.versions' version '0.51.0'
+}
+
+// ./gradlew run
+// ./gradlew runExample
+
+defaultTasks 'run'
+
+final def semverProcessor = 'net.thauvin.erik:semver:1.2.2-SNAPSHOT'
+
+sourceCompatibility = 1.8
+targetCompatibility = 1.8
+
+application {
+ mainClass = 'com.example.Example'
+}
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+}
+
+dependencies {
+ annotationProcessor semverProcessor
+ implementation semverProcessor
+}
+
+tasks.withType(JavaCompile) {
+ options.generatedSourceOutputDirectory.set(file("${projectDir}/src/generated/java"))
+ options.compilerArgs += ["-Asemver.project.dir=${projectDir}/example"]
+}
diff --git a/examples/test/example/example.mustache b/examples/test/example/example.mustache
new file mode 100644
index 0000000..70125c1
--- /dev/null
+++ b/examples/test/example/example.mustache
@@ -0,0 +1,21 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package {{packageName}};
+
+import java.util.Date;
+
+public final class {{className}} {
+ public static final String PROJECT = "{{project}}";
+ public static final Date BUILDDATE = new Date({{epoch}}L);
+ public static final String VERSION = "{{version}}";
+
+ /**
+ * Disables the default constructor.
+ */
+ private {{className}}() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
+}
diff --git a/examples/test/example/example.properties b/examples/test/example/example.properties
new file mode 100644
index 0000000..d0b5ce4
--- /dev/null
+++ b/examples/test/example/example.properties
@@ -0,0 +1,9 @@
+#Generated by the Semver Plugin for Gradle
+#Sat Apr 27 17:04:13 PDT 2019
+example.buildmeta=T800
+example.major=8
+example.minor=4
+example.patch=97
+example.prerelease=alpha
+example.project=Java Example
+example.semver=8.4.97-alpha+T800
diff --git a/examples/java/gradle/wrapper/gradle-wrapper.properties b/examples/test/gradle/wrapper/gradle-wrapper.properties
similarity index 74%
rename from examples/java/gradle/wrapper/gradle-wrapper.properties
rename to examples/test/gradle/wrapper/gradle-wrapper.properties
index e0b3fb8..b82aa23 100644
--- a/examples/java/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/test/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/examples/test/gradlew b/examples/test/gradlew
new file mode 100755
index 0000000..1aa94a4
--- /dev/null
+++ b/examples/test/gradlew
@@ -0,0 +1,249 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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 POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/examples/test/gradlew.bat
similarity index 52%
rename from gradlew.bat
rename to examples/test/gradlew.bat
index f955316..25da30d 100644
--- a/gradlew.bat
+++ b/examples/test/gradlew.bat
@@ -1,4 +1,20 @@
-@if "%DEBUG%" == "" @echo off
+@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
@rem Gradle startup script for Windows
@@ -9,25 +25,29 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@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% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -35,48 +55,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/settings.gradle b/examples/test/settings.gradle
similarity index 82%
rename from settings.gradle
rename to examples/test/settings.gradle
index f8947b7..f170c1a 100644
--- a/settings.gradle
+++ b/examples/test/settings.gradle
@@ -1,6 +1,6 @@
/*
* This settings file was auto generated by the Gradle buildInit task
- * by 'erik' at '1/13/16 1:03 PM' with Gradle 2.10
+ * by 'erik' at '1/14/16 4:59 PM' with Gradle 2.10
*
* The settings file is used to specify which projects to include in your build.
* In a single project build this file can be empty or even removed.
@@ -15,5 +15,5 @@ include 'shared'
include 'api'
include 'services:webservice'
*/
-enableFeaturePreview('STABLE_PUBLISHING')
-rootProject.name = 'semver'
+
+rootProject.name = 'examples-java'
diff --git a/examples/test/src/generated/java/com/example/ExampleVersion.java b/examples/test/src/generated/java/com/example/ExampleVersion.java
new file mode 100644
index 0000000..188422c
--- /dev/null
+++ b/examples/test/src/generated/java/com/example/ExampleVersion.java
@@ -0,0 +1,21 @@
+/*
+ * This file is automatically generated.
+ * Do not modify! -- ALL CHANGES WILL BE ERASED!
+ */
+
+package com.example;
+
+import java.util.Date;
+
+public final class ExampleVersion {
+ public static final String PROJECT = "Java Example";
+ public static final Date BUILDDATE = new Date(1707046879260L);
+ public static final String VERSION = "8.4.97-alpha+T800";
+
+ /**
+ * Disables the default constructor.
+ */
+ private ExampleVersion() {
+ throw new UnsupportedOperationException("Illegal constructor call.");
+ }
+}
diff --git a/examples/test/src/main/java/com/example/Example.java b/examples/test/src/main/java/com/example/Example.java
new file mode 100644
index 0000000..c8c8c0b
--- /dev/null
+++ b/examples/test/src/main/java/com/example/Example.java
@@ -0,0 +1,27 @@
+package com.example;
+
+import net.thauvin.erik.semver.Version;
+
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+@Version(properties = "example.properties", template = "example.mustache", className = "ExampleVersion",
+ keysPrefix = "example.")
+public final class Example {
+ /**
+ * Command line interface.
+ *
+ * @param args The command line parameters.
+ */
+ public static void main(final String... args) {
+ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
+
+ System.out.println("-- From Example -------------------------------------");
+
+ System.out.println(" " + ExampleVersion.PROJECT + ' ' + ExampleVersion.VERSION
+ + " (" + sdf.format(ExampleVersion.BUILDDATE) + ')');
+
+ System.out.println("-----------------------------------------------------");
+ }
+}
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 29953ea..0000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradlew b/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# 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/kobalt/Build.kt.iml b/kobalt/Build.kt.iml
deleted file mode 100644
index 83dc276..0000000
--- a/kobalt/Build.kt.iml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt
deleted file mode 100644
index 34c9ad8..0000000
--- a/kobalt/src/Build.kt
+++ /dev/null
@@ -1,141 +0,0 @@
-import com.beust.kobalt.buildScript
-import com.beust.kobalt.localMaven
-import com.beust.kobalt.plugin.java.javadoc
-import com.beust.kobalt.plugin.java.javaCompiler
-import com.beust.kobalt.plugin.packaging.assemble
-import com.beust.kobalt.plugin.packaging.install
-import com.beust.kobalt.plugin.publish.autoGitTag
-import com.beust.kobalt.plugin.publish.bintray
-import com.beust.kobalt.project
-import net.thauvin.erik.kobalt.plugin.exec.Os
-import net.thauvin.erik.kobalt.plugin.exec.exec
-import net.thauvin.erik.kobalt.plugin.pom2xml.pom2xml
-import org.apache.maven.model.Developer
-import org.apache.maven.model.License
-import org.apache.maven.model.Model
-import org.apache.maven.model.Scm
-import java.io.FileInputStream
-import java.util.*
-
-val bs = buildScript {
- repos(localMaven())
- plugins("net.thauvin.erik:kobalt-exec:",
- "net.thauvin.erik:kobalt-pom2xml:")
-}
-
-fun StringBuilder.prepend(s: String): StringBuilder {
- if (this.isNotEmpty()) {
- this.insert(0, s)
- }
- return this
-}
-
-fun versionFor(directory: String = "./"): String {
- val propsFile = directory + '/' + "version.properties"
- val majorKey = "version.major"
- val minorKey = "version.minor"
- val patchKey = "version.patch"
- val metaKey = "version.buildmeta"
- val preKey = "version.prerelease"
-
- val p = Properties().apply { FileInputStream(propsFile).use { fis -> load(fis) } }
-
- return (p.getProperty(majorKey, "1") + "." + p.getProperty(minorKey, "0") + "." + p.getProperty(patchKey, "0")
- + StringBuilder(p.getProperty(preKey, "")).prepend("-")
- + StringBuilder(p.getProperty(metaKey, "")).prepend("+"))
-}
-
-val semver = project {
-
- name = "semver"
- description = "Semantic Version Annotation Processor"
- group = "net.thauvin.erik"
- artifactId = name
- version = versionFor()
-
- pom = Model().apply {
- description = project.description
- url = "https://github.com/ethauvin/semver"
- licenses = listOf(License().apply {
- name = "BSD 3-Clause"
- url = "https://opensource.org/licenses/BSD-3-Clause"
- })
- scm = Scm().apply {
- url = "https://github.com/ethauvin/semver"
- connection = "https://github.com/ethauvin/semver.git"
- developerConnection = "git@github.com:ethauvin/semver.git"
- }
- developers = listOf(Developer().apply {
- id = "ethauvin"
- name = "Erik C. Thauvin"
- email = "erik@thauvin.net"
- })
- }
-
- dependencies {
- compile("com.github.spullara.mustache.java:compiler:0.9.5")
- compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.2.10")
- compileOnly("com.github.spotbugs:spotbugs-annotations:3.1.8")
- }
-
- dependenciesTest {
- compile("org.testng:testng:6.14.3")
- }
-
- javaCompiler {
- args("-source", "1.8", "-target", "1.8")
- }
-
- assemble {
- jar {
- //fatJar = true
- }
- mavenJars {
- //fatJar = true
- }
- }
-
- install {
- target = "deploy"
- }
-
- autoGitTag {
- enabled = true
- push = false
- message = "Version $version"
- }
-
- bintray {
- name = "SemVer"
- publish = true
- description = "Release version $version"
- issueTrackerUrl = "https://github.com/ethauvin/semver/issues"
- vcsTag = version
- sign = true
- }
-
- javadoc {
- title = "${project.description} ${project.version}"
- tags("created")
- author = true
- //quiet = false
- //verbose = true
- links("http://docs.oracle.com/javase/8/docs/api/")
- }
-
- exec {
- taskName = "pandoc"
- val args = arrayOf("--from", "markdown_github",
- "--to", "html5",
- "-s",
- "-c", "github-pandoc.css",
- "-o", "docs/README.html",
- "README.md")
- commandLine("pandoc", *args, os = setOf(Os.LINUX, Os.MINGW, Os.CYGWIN))
- commandLine("cmd", "/c", "pandoc", *args, os = setOf(Os.WINDOWS))
- }
-
- pom2xml {
-
- }
-}
diff --git a/kobalt/wrapper/kobalt-wrapper.jar b/kobalt/wrapper/kobalt-wrapper.jar
deleted file mode 100644
index 22d3ef5..0000000
Binary files a/kobalt/wrapper/kobalt-wrapper.jar and /dev/null differ
diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties
deleted file mode 100644
index f16e1df..0000000
--- a/kobalt/wrapper/kobalt-wrapper.properties
+++ /dev/null
@@ -1 +0,0 @@
-kobalt.version=1.0.118
\ No newline at end of file
diff --git a/kobaltw b/kobaltw
deleted file mode 100755
index c5186d5..0000000
--- a/kobaltw
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $*
diff --git a/kobaltw-test b/kobaltw-test
deleted file mode 100644
index 06230ec..0000000
--- a/kobaltw-test
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env sh
-JAR=$(ls -1 -t /k/GitHub/kobalt/kobaltBuild/libs/*.jar | egrep -v "(sources|javadoc)" | head -1)
-export KOBALT_JAR=$JAR
-java -jar $JAR $*
diff --git a/kobaltw.bat b/kobaltw.bat
deleted file mode 100644
index d578071..0000000
--- a/kobaltw.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-@echo off
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-java -jar "%DIRNAME%/kobalt/wrapper/kobalt-wrapper.jar" %*
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
new file mode 100644
index 0000000..d143a8a
Binary files /dev/null and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
new file mode 100644
index 0000000..514ff85
--- /dev/null
+++ b/lib/bld/bld-wrapper.properties
@@ -0,0 +1,9 @@
+bld.downloadExtensionJavadoc=false
+bld.downloadExtensionSources=true
+bld.downloadLocation=
+bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
+bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
+bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.3
+bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES,MAVEN_LOCAL,RIFE2_SNAPSHOTS
+bld.sourceDirectories=
+bld.version=2.2.1
diff --git a/pom.xml b/pom.xml
index a1d98eb..6c10533 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,42 +1,38 @@
-
+
4.0.0
net.thauvin.erik
semver
- 1.1.0-beta
- semver
+ 1.2.2-SNAPSHOT
+ SemVer
Semantic Version Annotation Processor
https://github.com/ethauvin/semver
- BSD 3-Clause
+ The BSD 3-Clause License
https://opensource.org/licenses/BSD-3-Clause
+
+
+ com.github.spullara.mustache.java
+ compiler
+ 0.9.14
+ compile
+
+
ethauvin
Erik C. Thauvin
erik@thauvin.net
+ https://erik.thauvin.net/
- https://github.com/ethauvin/semver.git
- git@github.com:ethauvin/semver.git
+ scm:git:https://github.com/ethauvin/semver.git
+ scm:git:git@github.com:ethauvin/semver.git
https://github.com/ethauvin/semver
-
-
- com.github.spullara.mustache.java
- compiler
- 0.9.5
-
-
- org.testng
- testng
- 6.14.3
- test
-
-
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..3c63dd8
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,7 @@
+sonar.organization=ethauvin-github
+sonar.projectKey=ethauvin_semver
+sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
+sonar.sources=src/main/java/
+sonar.tests=src/test/java/
+sonar.java.binaries=build/main,build/test
+sonar.java.libraries=lib/compile/*.jar
diff --git a/src/bld/java/net/thauvin/erik/semver/SemverBuild.java b/src/bld/java/net/thauvin/erik/semver/SemverBuild.java
new file mode 100644
index 0000000..22e91e7
--- /dev/null
+++ b/src/bld/java/net/thauvin/erik/semver/SemverBuild.java
@@ -0,0 +1,167 @@
+/*
+ * SemverBuild.java
+ *
+ * Copyright (c) 2016-2024, 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.semver;
+
+import rife.bld.BuildCommand;
+import rife.bld.Project;
+import rife.bld.extension.ExecOperation;
+import rife.bld.extension.JacocoReportOperation;
+import rife.bld.extension.PmdOperation;
+import rife.bld.publish.*;
+import rife.tools.exceptions.FileUtilsErrorException;
+
+import java.io.File;
+import java.util.List;
+
+import static rife.bld.dependencies.Repository.*;
+import static rife.bld.dependencies.Scope.compile;
+import static rife.bld.dependencies.Scope.test;
+import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
+
+public class SemverBuild extends Project {
+ final PmdOperation pmdOp = new PmdOperation()
+ .fromProject(this)
+ .failOnViolation(true)
+ .ruleSets("config/pmd.xml");
+
+ public SemverBuild() {
+ pkg = "net.thauvin.erik";
+ name = "SemVer";
+ version = version(1, 2, 2, "SNAPSHOT");
+
+ var description = "Semantic Version Annotation Processor";
+ var url = "https://github.com/ethauvin/semver";
+
+ javaRelease = 17;
+
+ downloadSources = true;
+ autoDownloadPurge = true;
+
+ repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
+
+ scope(compile)
+ .include(dependency("com.github.spullara.mustache.java", "compiler", version(0, 9, 14)));
+ scope(test)
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)));
+
+
+ javadocOperation().javadocOptions()
+ .windowTitle(name + ' ' + version.toString() + " API")
+ .docLint(NO_MISSING);
+
+ publishOperation()
+ .repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
+ .withCredentials(property("sonatype.user"), property("sonatype.password"))
+ : repository(SONATYPE_RELEASES_LEGACY.location())
+ .withCredentials(property("sonatype.user"), property("sonatype.password")))
+ .repository(repository("github"))
+ .info(new PublishInfo()
+ .groupId(pkg)
+ .artifactId(name.toLowerCase())
+ .name(name)
+ .version(version)
+ .description(description)
+ .url(url)
+ .developer(new PublishDeveloper()
+ .id("ethauvin")
+ .name("Erik C. Thauvin")
+ .email("erik@thauvin.net")
+ .url("https://erik.thauvin.net/")
+ )
+ .license(new PublishLicense()
+ .name("The BSD 3-Clause License")
+ .url("https://opensource.org/licenses/BSD-3-Clause")
+ )
+ .scm(new PublishScm()
+ .connection("scm:git:" + url + ".git")
+ .developerConnection("scm:git:git@github.com:ethauvin/" + name.toLowerCase() + ".git")
+ .url(url)
+ )
+ .signKey(property("sign.key"))
+ .signPassphrase(property("sign.passphrase")));
+ }
+
+ public static void main(String[] args) {
+ new SemverBuild().start(args);
+ }
+
+ @BuildCommand(summary = "Generates JaCoCo Reports")
+ public void jacoco() throws Exception {
+ new JacocoReportOperation().fromProject(this).execute();
+ }
+
+ @BuildCommand(summary = "Build the docs with Pandoc")
+ public void pandoc() throws Exception {
+ new ExecOperation()
+ .fromProject(this)
+ .command("pandoc",
+ "--from", "gfm",
+ "--to", "html5",
+ "--metadata", "pagetitle=Semantic Version Annotation Processor",
+ "-s",
+ "-c", "docs/github-pandoc.css",
+ "-o", "docs/README.html",
+ "README.md")
+ .execute();
+
+ }
+
+ @BuildCommand(summary = "Runs PMD analysis")
+ public void pmd() throws Exception {
+ pmdOp.execute();
+ }
+
+ @BuildCommand(value = "pmd-cli", summary = "Runs PMD analysis (CLI)")
+ public void pmdCli() throws Exception {
+ pmdOp.includeLineNumber(false).execute();
+ }
+
+ @BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
+ public void pomRoot() throws FileUtilsErrorException {
+ PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
+ new File(workDirectory, "pom.xml"));
+ }
+
+ @Override
+ public void publish() throws Exception {
+ super.publish();
+ pomRoot();
+ }
+
+ @Override
+ public void publishLocal() throws Exception {
+ super.publishLocal();
+ pomRoot();
+ }
+}
diff --git a/src/main/java/net/thauvin/erik/semver/Constants.java b/src/main/java/net/thauvin/erik/semver/Constants.java
index d26a65c..09e2c07 100644
--- a/src/main/java/net/thauvin/erik/semver/Constants.java
+++ b/src/main/java/net/thauvin/erik/semver/Constants.java
@@ -1,7 +1,7 @@
/*
* Constants.java
*
- * Copyright (c) 2016-2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2016-2024, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,7 @@
* 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.semver;
/**
@@ -38,7 +39,12 @@ package net.thauvin.erik.semver;
* @created 2016-01-13
* @since 1.0
*/
+@SuppressWarnings("PMD.DataClass")
public final class Constants {
+ /**
+ * The default metadata prefix.
+ */
+ public static final String DEFAULT_BUILDMETA_PREFIX = "+";
/**
* The default class name.
*/
@@ -54,7 +60,7 @@ public final class Constants {
/**
* The default keys prefix.
*/
- public static final String DEFAULT_KEYS_PREFIX = "version." ;
+ public static final String DEFAULT_KEYS_PREFIX = "version.";
/**
* The default Kotlin mustache template.
*/
@@ -71,18 +77,34 @@ public final class Constants {
* The default patch version.
*/
public static final int DEFAULT_PATCH = 0;
+ /**
+ * The default prerelease prefix.
+ */
+ public static final String DEFAULT_PRERELEASE_PREFIX = "-";
+ /**
+ * The default version separator.
+ */
+ public static final String DEFAULT_SEPARATOR = ".";
/**
* The default mustache template.
*/
- public static final String DEFAULT_TEMPLATE_NAME = "mustache";
+ public static final String DEFAULT_TEMPLATE_NAME = "version.mustache";
/**
* The empty string.
*/
public static final String EMPTY = "";
+ /**
+ * The generated source files directory kotlin option.
+ */
+ public static final String KAPT_KOTLIN_GENERATED_OPTION_NAME = "kapt.kotlin.generated";
/**
* The build metadata property key.
*/
public static final String KEY_VERSION_BUILDMETA = "buildmeta";
+ /**
+ * The build metadata prefix property key.
+ */
+ public static final String KEY_VERSION_BUILDMETA_PREFIX = "buildmeta.prefix";
/**
* The major version property key.
*/
@@ -99,22 +121,31 @@ public final class Constants {
* The pre-release version property key.
*/
public static final String KEY_VERSION_PRERELEASE = "prerelease";
+ /**
+ * The pre-release prefix property key.
+ */
+ public static final String KEY_VERSION_PRERELEASE_PREFIX = "prerelease.prefix";
/**
* The project property key.
*/
public static final String KEY_VERSION_PROJECT = "project";
+ /**
+ * The version separator property key.
+ */
+ public static final String KEY_VERSION_SEPARATOR = "separator";
/**
* The kotlin type.
*/
public static final String KOTLIN_TYPE = "kt";
+ /**
+ * The argument used to specify the project location.
+ */
+ public static final String SEMVER_PROJECT_DIR_ARG = "semver.project.dir";
/**
* Disables the default constructor.
- *
- * @throws UnsupportedOperationException if the constructor is called.
*/
- private Constants()
- throws UnsupportedOperationException {
+ private Constants() {
throw new UnsupportedOperationException("Illegal constructor call.");
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/semver/Version.java b/src/main/java/net/thauvin/erik/semver/Version.java
index 94aee55..821677f 100644
--- a/src/main/java/net/thauvin/erik/semver/Version.java
+++ b/src/main/java/net/thauvin/erik/semver/Version.java
@@ -1,7 +1,7 @@
/*
* Version.java
*
- * Copyright (c) 2016-2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2016-2024, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,7 @@
* 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.semver;
import java.lang.annotation.ElementType;
@@ -43,42 +44,175 @@ import java.lang.annotation.Target;
* @created 2016-01-13
* @since 1.0
*/
+@SuppressWarnings("SameReturnValue")
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Version {
+ /**
+ * Returns the build metadata version.
+ *
+ * @return The build metadata version.
+ */
String buildMeta() default Constants.EMPTY;
+ /**
+ * Returns the build metadata key.
+ *
+ * @return The build metadata key.
+ */
String buildMetaKey() default Constants.KEY_VERSION_BUILDMETA;
+ /**
+ * Returns the build metadata prefix.
+ *
+ * @return The build metadata prefix.
+ */
+ String buildMetaPrefix() default Constants.DEFAULT_BUILDMETA_PREFIX;
+
+ /**
+ * Returns the build metadata prefix key.
+ *
+ * @return The build metadata prefix key.
+ */
+ String buildMetaPrefixKey() default Constants.KEY_VERSION_BUILDMETA_PREFIX;
+
+ /**
+ * Returns the class name.
+ *
+ * @return The class name.
+ */
String className() default Constants.DEFAULT_CLASS_NAME;
+ /**
+ * Returns the keys prefix.
+ *
+ * @return The keys prefix.
+ */
+ String keysPrefix() default Constants.DEFAULT_KEYS_PREFIX;
+
+ /**
+ * Returns the major version.
+ *
+ * @return The major version.
+ */
int major() default Constants.DEFAULT_MAJOR;
+ /**
+ * Returns the major key.
+ *
+ * @return The major key.
+ */
String majorKey() default Constants.KEY_VERSION_MAJOR;
+ /**
+ * Returns the minor version.
+ *
+ * @return The build minor version.
+ */
int minor() default Constants.DEFAULT_MINOR;
+ /**
+ * Returns the minor key.
+ *
+ * @return The minor key.
+ */
String minorKey() default Constants.KEY_VERSION_MINOR;
- int patch() default Constants.DEFAULT_PATCH;
-
+ /**
+ * Returns the package name.
+ *
+ * @return The package name .
+ */
String packageName() default Constants.EMPTY;
+ /**
+ * Returns the patch version.
+ *
+ * @return The patch version.
+ */
+ int patch() default Constants.DEFAULT_PATCH;
+
+ /**
+ * Returns the patch key.
+ *
+ * @return The patch key.
+ */
String patchKey() default Constants.KEY_VERSION_PATCH;
+ /**
+ * Returns the pre-release version.
+ *
+ * @return The pre-release version.
+ */
String preRelease() default Constants.EMPTY;
+ /**
+ * Returns the pre-release key.
+ *
+ * @return The pre-release key.
+ */
String preReleaseKey() default Constants.KEY_VERSION_PRERELEASE;
+ /**
+ * Returns the pre-release prefix.
+ *
+ * @return The pre-release prefix.
+ */
+ String preReleasePrefix() default Constants.DEFAULT_PRERELEASE_PREFIX;
+
+ /**
+ * Returns the pre-release prefix key.
+ *
+ * @return The pre-release prefix key.
+ */
+ String preReleasePrefixKey() default Constants.KEY_VERSION_PRERELEASE_PREFIX;
+
+ /**
+ * Returns the project name.
+ *
+ * @return The project name.
+ */
String project() default Constants.EMPTY;
+ /**
+ * Returns the project key.
+ *
+ * @return The project.
+ */
String projectKey() default Constants.KEY_VERSION_PROJECT;
+ /**
+ * Returns the properties file name.
+ *
+ * @return The properties file name.
+ */
String properties() default Constants.EMPTY;
+ /**
+ * Returns the version separator.
+ *
+ * @return The separator.
+ */
+ String separator() default Constants.DEFAULT_SEPARATOR;
+
+ /**
+ * Returns the version separator key.
+ *
+ * @return The separator key.
+ */
+ String separatorKey() default Constants.KEY_VERSION_SEPARATOR;
+
+ /**
+ * Returns the template name.
+ *
+ * @return The template.
+ */
String template() default Constants.DEFAULT_JAVA_TEMPLATE;
+ /**
+ * Returns the template type.
+ *
+ * @return The type.
+ */
String type() default Constants.DEFAULT_JAVA_TYPE;
-
- String keysPrefix() default Constants.DEFAULT_KEYS_PREFIX;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/semver/VersionInfo.java b/src/main/java/net/thauvin/erik/semver/VersionInfo.java
index 50a3685..b2ea193 100644
--- a/src/main/java/net/thauvin/erik/semver/VersionInfo.java
+++ b/src/main/java/net/thauvin/erik/semver/VersionInfo.java
@@ -1,7 +1,7 @@
/*
* VersionInfo.java
*
- * Copyright (c) 2016-2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2016-2024, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,7 @@
* 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.semver;
/**
@@ -38,47 +39,57 @@ package net.thauvin.erik.semver;
* @created 2016-01-16
* @since 1.0
*/
+@SuppressWarnings("PMD.DataClass")
public class VersionInfo {
private final long epoch = System.currentTimeMillis();
private String buildMeta;
+ private String buildMetaPrefix;
private String className;
private int major;
private int minor;
private String packageName;
private int patch;
private String preRelease;
+ private String preReleasePrefix;
private String project;
+ private String separator;
/**
* Creates a new object with default values.
*/
public VersionInfo() {
- major = Constants.DEFAULT_MAJOR;
- minor = Constants.DEFAULT_MINOR;
- patch = Constants.DEFAULT_PATCH;
buildMeta = Constants.EMPTY;
- preRelease = Constants.EMPTY;
- project = Constants.EMPTY;
+ buildMetaPrefix = Constants.DEFAULT_BUILDMETA_PREFIX;
className = Constants.DEFAULT_CLASS_NAME;
+ minor = Constants.DEFAULT_MINOR;
packageName = Constants.EMPTY;
+ patch = Constants.DEFAULT_PATCH;
+ preRelease = Constants.EMPTY;
+ preReleasePrefix = Constants.DEFAULT_PRERELEASE_PREFIX;
+ project = Constants.EMPTY;
+ separator = Constants.DEFAULT_SEPARATOR;
+ major = Constants.DEFAULT_MAJOR;
}
/**
- * Creates a new object with values from a {@link net.thauvin.erik.semver.Version Version} object.
+ * Creates a new object with values from a {@link net.thauvin.erik.semver.VersionInfo VersionInfo} object.
*
* @param version The version object.
*/
public VersionInfo(final Version version) {
+ buildMeta = version.buildMeta();
+ buildMetaPrefix = version.buildMetaPrefix();
+ className = version.className();
major = version.major();
minor = version.minor();
- patch = version.patch();
- buildMeta = version.buildMeta();
- preRelease = version.preRelease();
- project = version.project();
- className = version.className();
packageName = version.packageName();
+ patch = version.patch();
+ preRelease = version.preRelease();
+ preReleasePrefix = version.preReleasePrefix();
+ project = version.project();
+ separator = version.separator();
}
/**
@@ -91,12 +102,12 @@ public class VersionInfo {
}
/**
- * Sets the build meta-data.
+ * Returns the meta-data prefix.
*
- * @param buildMeta The new build meta-data.
+ * @return The meta-data prefix.
*/
- public void setBuildMeta(final String buildMeta) {
- this.buildMeta = buildMeta;
+ public String getBuildMetaPrefix() {
+ return buildMetaPrefix;
}
/**
@@ -108,15 +119,6 @@ public class VersionInfo {
return className;
}
- /**
- * Sets the class name.
- *
- * @param className The new class name.
- */
- public void setClassName(String className) {
- this.className = className;
- }
-
/**
* Returns the build epoch/Unix timestamp.
*
@@ -135,15 +137,6 @@ public class VersionInfo {
return major;
}
- /**
- * Sets the major version.
- *
- * @param major The new major version.
- */
- public void setMajor(final int major) {
- this.major = major;
- }
-
/**
* Returns the major version.
*
@@ -153,15 +146,6 @@ public class VersionInfo {
return minor;
}
- /**
- * Sets the minor version.
- *
- * @param minor The new minor version.
- */
- public void setMinor(final int minor) {
- this.minor = minor;
- }
-
/**
* Returns the package name.
*
@@ -171,15 +155,6 @@ public class VersionInfo {
return packageName;
}
- /**
- * Sets the package name.
- *
- * @param packageName The new package name.
- */
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
/**
* Returns the patch version.
*
@@ -189,15 +164,6 @@ public class VersionInfo {
return patch;
}
- /**
- * Sets the patch version.
- *
- * @param patch The new patch version.
- */
- public void setPatch(final int patch) {
- this.patch = patch;
- }
-
/**
* Returns the pre-release version.
*
@@ -208,12 +174,12 @@ public class VersionInfo {
}
/**
- * Sets the pre-release version.
+ * Returns the pre-release prefix.
*
- * @param preRelease The new pre-release version.
+ * @return The pre-release prefix.
*/
- public void setPreRelease(final String preRelease) {
- this.preRelease = preRelease;
+ public String getPreReleasePrefix() {
+ return preReleasePrefix;
}
/**
@@ -226,21 +192,34 @@ public class VersionInfo {
}
/**
- * Sets the project name.
+ * Sames as {@link #getVersion()}.
*
- * @param project The new project name.
+ * @return The version string.
*/
- public void setProject(final String project) {
- this.project = project;
+ public String getSemver() {
+ return getVersion();
+ }
+
+ /**
+ * Returns the version separator.
+ *
+ * @return The version separator.
+ */
+ public String getSeparator() {
+ return separator;
}
/**
* Returns the full version string.
- *
- * Formatted as:
- *
MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]
- *
- * For example:
+ *
+ *
Formatted as:
+ *
+ *
+ * [MAJOR][SEPARATOR][MINOR][SEPARATOR][PATCH][[PRERELEASE-PREFIX][PRERELEASE]][[BUILDMETA-PREFIX][BUILDMETA]]
+ *
+ *
+ *
+ * For example:
*
* 1.0.0
* 1.0.0-beta
@@ -251,12 +230,111 @@ public class VersionInfo {
* @return The version string.
*/
public String getVersion() {
- return Integer.toString(major)
- + '.'
- + Integer.toString(minor)
- + '.'
- + Integer.toString(patch)
- + (preRelease.length() > 0 ? '-' + preRelease : "")
- + (buildMeta.length() > 0 ? '+' + buildMeta : "");
+ return major
+ + separator
+ + minor
+ + separator
+ + patch
+ + (!preRelease.isEmpty() ? preReleasePrefix + preRelease : "")
+ + (!buildMeta.isEmpty() ? buildMetaPrefix + buildMeta : "");
}
-}
\ No newline at end of file
+
+ /**
+ * Sets the build meta-data.
+ *
+ * @param buildMeta The new build meta-data.
+ */
+ public void setBuildMeta(final String buildMeta) {
+ this.buildMeta = buildMeta;
+ }
+
+ /**
+ * Sets the meta-data prefix.
+ *
+ * @param buildMetaPrefix The meta-data prefix.
+ */
+ public void setBuildMetaPrefix(final String buildMetaPrefix) {
+ this.buildMetaPrefix = buildMetaPrefix;
+ }
+
+ /**
+ * Sets the class name.
+ *
+ * @param className The new class name.
+ */
+ public void setClassName(final String className) {
+ this.className = className;
+ }
+
+ /**
+ * Sets the major version.
+ *
+ * @param major The new major version.
+ */
+ public void setMajor(final int major) {
+ this.major = major;
+ }
+
+ /**
+ * Sets the minor version.
+ *
+ * @param minor The new minor version.
+ */
+ public void setMinor(final int minor) {
+ this.minor = minor;
+ }
+
+ /**
+ * Sets the package name.
+ *
+ * @param packageName The new package name.
+ */
+ public void setPackageName(final String packageName) {
+ this.packageName = packageName;
+ }
+
+ /**
+ * Sets the patch version.
+ *
+ * @param patch The new patch version.
+ */
+ public void setPatch(final int patch) {
+ this.patch = patch;
+ }
+
+ /**
+ * Sets the pre-release version.
+ *
+ * @param preRelease The new pre-release version.
+ */
+ public void setPreRelease(final String preRelease) {
+ this.preRelease = preRelease;
+ }
+
+ /**
+ * Sets the pre-release prefix.
+ *
+ * @param preReleasePrefix The new pre-release prefix.
+ */
+ public void setPreReleasePrefix(final String preReleasePrefix) {
+ this.preReleasePrefix = preReleasePrefix;
+ }
+
+ /**
+ * Sets the project name.
+ *
+ * @param project The new project name.
+ */
+ public void setProject(final String project) {
+ this.project = project;
+ }
+
+ /**
+ * Sets the version separator.
+ *
+ * @param separator The new version separator.
+ */
+ public void setSeparator(final String separator) {
+ this.separator = separator;
+ }
+}
diff --git a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java
index 826037d..3ffd457 100644
--- a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java
+++ b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java
@@ -1,7 +1,7 @@
/*
* VersionProcessor.java
*
- * Copyright (c) 2016-2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2016-2024, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,12 +29,12 @@
* 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.semver;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
-import com.github.mustachejava.MustacheFactory;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import com.github.mustachejava.MustacheNotFoundException;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
@@ -44,9 +44,9 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
-import javax.tools.StandardLocation;
import java.io.*;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -58,47 +58,83 @@ import java.util.Set;
* @created 2016-01-13
* @since 1.0
*/
+@SuppressWarnings({"PMD.GuardLogStatement", "PMD.BeanMembersShouldSerialize"})
+@SupportedOptions({Constants.KAPT_KOTLIN_GENERATED_OPTION_NAME, Constants.SEMVER_PROJECT_DIR_ARG})
public class VersionProcessor extends AbstractProcessor {
private Filer filer;
private Messager messager;
+ private static String getTemplate(final boolean isLocalTemplate, final Version version) {
+ final String template;
+ if (isLocalTemplate && Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template())) {
+ template = Constants.DEFAULT_TEMPLATE_NAME;
+ } else if (Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template()) && Constants.KOTLIN_TYPE
+ .equals(version.type())) {
+ template = Constants.DEFAULT_KOTLIN_TEMPLATE;
+ } else {
+ template = version.template();
+ }
+ return template;
+ }
+
+ private Mustache compileTemplate(final File dir, final String template) throws IOException {
+ if (Constants.DEFAULT_JAVA_TEMPLATE.equals(template) || Constants.DEFAULT_KOTLIN_TEMPLATE.equals(template)) {
+ try (var in = getClass().getResourceAsStream("/" + template)) {
+ if (in != null) {
+ try (var reader = new BufferedReader(new InputStreamReader(in))) {
+ return new DefaultMustacheFactory().compile(reader, template);
+ }
+ } else {
+ throw new IOException("Resource not found: " + template);
+ }
+ }
+ } else {
+ return new DefaultMustacheFactory(dir).compile(template);
+ }
+ }
+
private void error(final String s) {
log(Diagnostic.Kind.ERROR, s);
}
+ @SuppressWarnings("PMD.UnusedPrivateMethod")
private void error(final String s, final Throwable t) {
- messager.printMessage(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s));
+ log(Diagnostic.Kind.ERROR, t != null ? t.toString() : s);
}
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN")
- private VersionInfo findValues(final Version version)
- throws IOException {
- final VersionInfo versionInfo = new VersionInfo(version);
+ private VersionInfo findValues(final Version version) throws IOException {
+ final var versionInfo = new VersionInfo(version);
- if (version.properties().length() > 0) {
- final File propsFile = new File(version.properties());
+ if (!version.properties().isEmpty()) {
+ final var propsFile = getLocalFile(version.properties());
if (propsFile.isFile() && propsFile.canRead()) {
- note("Found properties: " + propsFile + " (" + propsFile.getAbsoluteFile().getParent() + ')');
+ note("Found properties: " + propsFile.getName() + " (" + propsFile.getAbsoluteFile().getParent() + ')');
- final Properties p = new Properties();
+ final var p = new Properties();
- try (final InputStreamReader reader =
- new InputStreamReader(new FileInputStream(propsFile), StandardCharsets.UTF_8)) {
+ try (var reader = new InputStreamReader(
+ Files.newInputStream(propsFile.toPath()), StandardCharsets.UTF_8)) {
p.load(reader);
versionInfo.setProject(
- p.getProperty(version.keysPrefix() + version.projectKey(), version.project()));
+ p.getProperty(version.keysPrefix() + version.projectKey(), version.project()));
versionInfo.setMajor(
- parseIntProperty(p, version.keysPrefix() + version.majorKey(), version.major()));
+ parseIntProperty(p, version.keysPrefix() + version.majorKey(), version.major()));
versionInfo.setMinor(
- parseIntProperty(p, version.keysPrefix() + version.minorKey(), version.minor()));
+ parseIntProperty(p, version.keysPrefix() + version.minorKey(), version.minor()));
versionInfo.setPatch(
- parseIntProperty(p, version.keysPrefix() + version.patchKey(), version.patch()));
+ parseIntProperty(p, version.keysPrefix() + version.patchKey(), version.patch()));
versionInfo.setBuildMeta(
- p.getProperty(version.keysPrefix() + version.buildMetaKey(), version.buildMeta()));
+ p.getProperty(version.keysPrefix() + version.buildMetaKey(), version.buildMeta()));
+ versionInfo.setBuildMetaPrefix(
+ p.getProperty(version.keysPrefix() + version.buildMetaPrefixKey(), version.buildMetaPrefix()));
versionInfo.setPreRelease(
- p.getProperty(version.keysPrefix() + version.preReleaseKey(), version.preRelease()));
+ p.getProperty(version.keysPrefix() + version.preReleaseKey(), version.preRelease()));
+ versionInfo.setPreReleasePrefix(p.getProperty(version.keysPrefix() + version.preReleasePrefixKey(),
+ version.preReleasePrefix()));
+ versionInfo.setSeparator(
+ p.getProperty(version.keysPrefix() + version.separatorKey(), version.separator()));
}
} else {
final String findOrRead;
@@ -108,14 +144,24 @@ public class VersionProcessor extends AbstractProcessor {
findOrRead = "read";
}
error("Could not " + findOrRead + ": " + propsFile);
- throw new FileNotFoundException("The system cannot " + findOrRead + " the specified file: `"
- + propsFile.getAbsolutePath() + '`');
+ throw new FileNotFoundException(
+ "Could not " + findOrRead + " the specified file: `" + propsFile.getAbsolutePath() + '`');
}
}
return versionInfo;
}
+ private File getLocalFile(final String fileName) {
+ if (processingEnv != null) { // null when testing.
+ final var prop = processingEnv.getOptions().get(Constants.SEMVER_PROJECT_DIR_ARG);
+ if (prop != null) {
+ return new File(prop, fileName);
+ }
+ }
+ return new File(new File("").getAbsolutePath(), fileName);
+ }
+
/**
* {@inheritDoc}
*/
@@ -137,6 +183,7 @@ public class VersionProcessor extends AbstractProcessor {
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
@Override
public synchronized void init(final ProcessingEnvironment processingEnv) {
super.init(processingEnv);
@@ -144,53 +191,29 @@ public class VersionProcessor extends AbstractProcessor {
messager = processingEnv.getMessager();
}
- private void log(final Diagnostic.Kind kind, final String s) {
- messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s);
- }
-
- private void note(final String s) {
- log(Diagnostic.Kind.NOTE, s);
- }
-
- private int parseIntProperty(final Properties p, final String property, final int defaultValue) {
- try {
- return Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)));
- } catch (NumberFormatException ignore) {
- warn("Invalid property value: " + property);
- return defaultValue;
- }
- }
-
/**
* {@inheritDoc}
*/
@Override
public boolean process(final Set extends TypeElement> annotations, final RoundEnvironment roundEnv) {
+ final var isLocalTemplate = getLocalFile(Constants.DEFAULT_TEMPLATE_NAME).exists();
for (final Element element : roundEnv.getElementsAnnotatedWith(Version.class)) {
- final Version version = element.getAnnotation(Version.class);
+ final var version = element.getAnnotation(Version.class);
if (element.getKind() == ElementKind.CLASS) {
- final Element enclosingElement = element.getEnclosingElement();
+ final var enclosingElement = element.getEnclosingElement();
if (enclosingElement.getKind() == ElementKind.PACKAGE) {
- final PackageElement packageElement = (PackageElement) enclosingElement;
+ final var packageElement = (PackageElement) enclosingElement;
try {
- final VersionInfo versionInfo = findValues(version);
- if (version.packageName().equals(Constants.EMPTY)) {
+ final var versionInfo = findValues(version);
+ if (Constants.EMPTY.equals(version.packageName())) {
versionInfo.setPackageName(packageElement.getQualifiedName().toString());
}
note("Found version: " + versionInfo.getVersion());
- final String template;
- if (version.template().equals(Constants.DEFAULT_JAVA_TEMPLATE) &&
- new File(Constants.DEFAULT_TEMPLATE_NAME).exists()) {
- template = Constants.DEFAULT_TEMPLATE_NAME;
- } else if (version.template().equals(Constants.DEFAULT_JAVA_TEMPLATE) &&
- version.type().equals(Constants.KOTLIN_TYPE)) {
- template = Constants.DEFAULT_KOTLIN_TEMPLATE;
- } else {
- template = version.template();
- }
+ final var template = getTemplate(isLocalTemplate, version);
+
writeTemplate(version.type(), versionInfo, template);
- } catch (IOException e) {
- error("IOException occurred while running the annotation processor: " + e.getMessage(), e);
+ } catch (IOException | MustacheNotFoundException e) {
+ error("An error occurred while running the annotation processor: " + e.getMessage(), e);
}
}
}
@@ -198,44 +221,64 @@ public class VersionProcessor extends AbstractProcessor {
return true;
}
+ private void log(final Diagnostic.Kind kind, final String s) {
+ if (messager != null) {
+ messager.printMessage(kind,
+ '[' + VersionProcessor.class.getSimpleName() + "] " + s + System.lineSeparator());
+ }
+ }
+
+ private void note(final String s) {
+ log(Diagnostic.Kind.NOTE, s);
+ }
+
+ private int parseIntProperty(final Properties p, final String key, final int defaultValue) {
+ try {
+ return Math.abs(Integer.parseInt(p.getProperty(key, Integer.toString(defaultValue)).trim()));
+ } catch (NumberFormatException ignore) {
+ warn("Invalid property value: " + key);
+ return defaultValue;
+ }
+ }
+
private void warn(final String s) {
log(Diagnostic.Kind.WARNING, s);
}
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN")
private void writeTemplate(final String type, final VersionInfo versionInfo, final String template)
- throws IOException {
- final MustacheFactory mf = new DefaultMustacheFactory();
- final Mustache mustache = mf.compile(template);
+ throws IOException {
+ final var dir = getLocalFile("");
+ final Mustache mustache = compileTemplate(dir, template);
- final String templateName;
- switch (mustache.getName()) {
- case Constants.DEFAULT_JAVA_TEMPLATE:
- templateName = "default (Java)";
- break;
- case Constants.DEFAULT_KOTLIN_TEMPLATE:
- templateName = "default (Kotlin)";
- break;
- default:
- templateName = mustache.getName();
- break;
- }
+ final var templateName = switch (mustache.getName()) {
+ case Constants.DEFAULT_JAVA_TEMPLATE -> "default (Java)";
+ case Constants.DEFAULT_KOTLIN_TEMPLATE -> "default (Kotlin)";
+ default -> mustache.getName() + " (" + dir.getAbsolutePath() + ')';
+ };
note("Loaded template: " + templateName);
- final FileObject jfo;
- final String fileName = versionInfo.getClassName() + '.' + type;
- if (type.equalsIgnoreCase(Constants.KOTLIN_TYPE)) {
- jfo = filer.createResource(StandardLocation.SOURCE_OUTPUT, versionInfo.getPackageName(),
- fileName);
+ final var fileName = versionInfo.getClassName() + '.' + type;
+ if (Constants.KOTLIN_TYPE.equalsIgnoreCase(type)) {
+ final var kaptGenDir = processingEnv.getOptions().get(Constants.KAPT_KOTLIN_GENERATED_OPTION_NAME);
+ if (kaptGenDir == null) {
+ throw new IOException("Could not find the target directory for generated Kotlin files.");
+ }
+ final var ktFile = new File(kaptGenDir, fileName);
+ if (!ktFile.getParentFile().exists() && !ktFile.getParentFile().mkdirs()) {
+ note("Could not create target directory: " + ktFile.getParentFile().getAbsolutePath());
+ }
+ try (var osw = new OutputStreamWriter(Files.newOutputStream(ktFile.toPath()),
+ StandardCharsets.UTF_8)) {
+ mustache.execute(osw, versionInfo).flush();
+ }
+ note("Generated source: " + fileName + " (" + ktFile.getParentFile().getAbsolutePath() + ')');
} else {
- jfo = filer.createSourceFile(versionInfo.getPackageName() + '.' + versionInfo.getClassName());
+ final FileObject jfo = filer.createSourceFile(
+ versionInfo.getPackageName() + '.' + versionInfo.getClassName());
+ try (var writer = jfo.openWriter()) {
+ mustache.execute(writer, versionInfo).flush();
+ }
+ note("Generated source: " + fileName + " (" + new File(jfo.getName()).getAbsoluteFile().getParent() + ')');
}
-
- try (final Writer writer = jfo.openWriter()) {
- mustache.execute(writer, versionInfo).flush();
- }
-
- note("Generated source: " + fileName + " (" + new File(jfo.getName()).getAbsoluteFile().getParent() + ')');
}
-
}
diff --git a/src/main/java/net/thauvin/erik/semver/package.html b/src/main/java/net/thauvin/erik/semver/package.html
index c63dfc0..1b1b126 100644
--- a/src/main/java/net/thauvin/erik/semver/package.html
+++ b/src/main/java/net/thauvin/erik/semver/package.html
@@ -1,11 +1,12 @@
-
-
- Semantic Version Annotation Processor
-
-
-An annotation processor that automatically generates a GeneratedVersion
class containing the semantic version (major, minor, patch, etc.) that is read from a Properties file or defined in the annotation.
+
+
+ Semantic Version Annotation Processor
+
+
+An annotation processor that automatically generates a GeneratedVersion
class containing the semantic
+version (major, minor, patch, etc.) that is read from a Properties file or defined in the annotation.
@since 1.0
-
-
+
+
diff --git a/src/main/resources/semver-kt.mustache b/src/main/resources/semver-kt.mustache
index b26dc58..cf53df5 100644
--- a/src/main/resources/semver-kt.mustache
+++ b/src/main/resources/semver-kt.mustache
@@ -2,6 +2,7 @@
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
+
package {{packageName}}
import java.util.Date
@@ -12,11 +13,6 @@ import java.util.Date
* @author Semantic Version Annotation Processor
*/
object {{className}} {
- @JvmField
- val PRERELEASE_PREFIX = "-"
- @JvmField
- val BUILDMEATA_PREFIX = "+"
-
@JvmField
val PROJECT = "{{project}}"
@JvmField
@@ -30,43 +26,13 @@ object {{className}} {
@JvmField
val PRERELEASE = "{{preRelease}}"
@JvmField
- val BUILDMETA = "{{buildMeta}}"
-
- /**
- * The full version string formatted as [MAJOR].[MINOR].[PATCH]-[PRERELEASE]+[BUILDMETA]
- */
+ val PRERELEASE_PREFIX = "{{preReleasePrefix}}"
@JvmField
- val VERSION = "$MAJOR.$MINOR.$PATCH" + preReleaseWithPrefix() + buildMetaWithPrefix()
-
- /**
- * Returns the pre-release version with prefix.
- *
- * @param prefix The prefix, defaults to [PRERELEASE_PREFIX].
- * @return The pre-release version, if any.
- */
- @JvmStatic
- @JvmOverloads
- fun preReleaseWithPrefix(prefix: String = PRERELEASE_PREFIX): String {
- return if (PRERELEASE.isNotEmpty() && prefix.isNotEmpty()) {
- "$prefix$PRERELEASE"
- } else {
- PRERELEASE
- }
- }
-
- /**
- * Returns the build metadata with prefix.
- *
- * @param prefix The prefix, defaults to [BUILDMEATA_PREFIX].
- * @return The build metadata, if any.
- */
- @JvmStatic
- @JvmOverloads
- fun buildMetaWithPrefix(prefix: String = BUILDMEATA_PREFIX): String {
- return if (BUILDMETA.isNotEmpty() && prefix.isNotEmpty()) {
- "$prefix$BUILDMETA"
- } else {
- BUILDMETA
- }
- }
-}
\ No newline at end of file
+ val BUILDMETA = "{{buildMeta}}"
+ @JvmField
+ val BUILDMEATA_PREFIX = "{{buildMetaPrefix}}"
+ @JvmField
+ val SEPARATOR = "{{separator}}"
+ @JvmField
+ val VERSION = "{{version}}"
+}
diff --git a/src/main/resources/semver.mustache b/src/main/resources/semver.mustache
index 88becf0..d9eb417 100644
--- a/src/main/resources/semver.mustache
+++ b/src/main/resources/semver.mustache
@@ -2,6 +2,7 @@
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
+
package {{packageName}};
import java.util.Date;
@@ -12,91 +13,22 @@ import java.util.Date;
* @author Semantic Version Annotation Processor
*/
public final class {{className}} {
- public final static String PRERELEASE_PREFIX = "-";
- public final static String BUILDMETA_PREFIX = "+";
-
- public final static String PROJECT = "{{project}}";
- public final static Date BUILDDATE = new Date({{epoch}}L);
- public final static int MAJOR = {{major}};
- public final static int MINOR = {{minor}};
- public final static int PATCH = {{patch}};
- public final static String PRERELEASE = "{{preRelease}}";
- public final static String BUILDMETA = "{{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();
+ public static final String PROJECT = "{{project}}";
+ public static final Date BUILDDATE = new Date({{epoch}}L);
+ public static final int MAJOR = {{major}};
+ public static final int MINOR = {{minor}};
+ public static final int PATCH = {{patch}};
+ public static final String PRERELEASE = "{{preRelease}}";
+ public static final String PRERELEASE_PREFIX = "{{preReleasePrefix}}";
+ public static final String BUILDMETA = "{{buildMeta}}";
+ public static final String BUILDMETA_PREFIX = "{{buildMetaPrefix}}";
+ public static final String SEPARATOR = "{{separator}}";
+ public static final String VERSION = "{{version}}";
/**
* Disables the default constructor.
- *
- * @throws UnsupportedOperationException If the constructor is called.
*/
- private {{className}}()
- throws UnsupportedOperationException {
+ private {{className}}() {
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/src/test/java/net/thauvin/erik/semver/ConstantsTest.java b/src/test/java/net/thauvin/erik/semver/ConstantsTest.java
new file mode 100644
index 0000000..c82f718
--- /dev/null
+++ b/src/test/java/net/thauvin/erik/semver/ConstantsTest.java
@@ -0,0 +1,73 @@
+/*
+ * ConstantsTest.java
+ *
+ * Copyright (c) 2016-2024, 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.semver;
+
+
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The ConstantsTest
class.
+ *
+ * @author Erik C. Thauvin
+ * @created 2019-04-14
+ * @since 1.0
+ */
+class ConstantsTest {
+ @Test
+ void testDefaults() {
+ assertEquals(1, Constants.DEFAULT_MAJOR, "major");
+ assertEquals(0, Constants.DEFAULT_MINOR, "minor");
+ assertEquals(0, Constants.DEFAULT_PATCH, "patch");
+ assertEquals("-", Constants.DEFAULT_PRERELEASE_PREFIX, "preRelease");
+ assertEquals("+", Constants.DEFAULT_BUILDMETA_PREFIX, "buildMeta");
+ assertEquals(".", Constants.DEFAULT_SEPARATOR, "separator");
+ }
+
+ @Test
+ void testTemplates() {
+ final List templates = new ArrayList<>();
+ templates.add(Constants.DEFAULT_JAVA_TEMPLATE);
+ templates.add(Constants.DEFAULT_KOTLIN_TEMPLATE);
+ templates.add(Constants.DEFAULT_TEMPLATE_NAME);
+
+ for (final var tp : templates) {
+ assertTrue(tp.endsWith(".mustache"), tp);
+ }
+ }
+}
diff --git a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java
index 95429de..49d2e7c 100644
--- a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java
+++ b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java
@@ -1,7 +1,7 @@
/*
* VersionInfoTest.java
*
- * Copyright (c) 2016-2018, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2016-2024, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,13 +29,15 @@
* 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.semver;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
-import java.lang.annotation.Annotation;
-import java.util.Calendar;
+import java.util.Date;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The VersionInfoTest
class.
@@ -44,212 +46,150 @@ import java.util.Calendar;
* @created 2016-02-03
* @since 1.0
*/
-public class VersionInfoTest {
- private final Calendar now = Calendar.getInstance();
+class VersionInfoTest {
private VersionInfo versionInfo = new VersionInfo();
+ @SuppressWarnings("PMD.AvoidUsingHardCodedIP")
@Test
- public void testGetVersion() {
-
- Assert.assertEquals(versionInfo.getVersion(), "1.0.0", "getVersion(1.0.0)");
+ void testGetVersion() {
+ assertEquals("1.0.0", versionInfo.getVersion(), "getVersion(1.0.0)");
versionInfo.setMajor(3);
- Assert.assertEquals(versionInfo.getVersion(), "3.0.0", "getVersion(3.0.0)");
+ assertEquals("3.0.0", versionInfo.getVersion(), "getVersion(3.0.0)");
versionInfo.setMinor(2);
- Assert.assertEquals(versionInfo.getVersion(), "3.2.0", "getVersion(3.2.0)");
+ assertEquals("3.2.0", versionInfo.getVersion(), "getVersion(3.2.0)");
versionInfo.setPatch(1);
- Assert.assertEquals(versionInfo.getVersion(), "3.2.1", "getVersion(3.2.1)");
+ assertEquals("3.2.1", versionInfo.getVersion(), "getVersion(3.2.1)");
versionInfo.setPreRelease("beta");
- Assert.assertEquals(versionInfo.getVersion(), "3.2.1-beta", "getVersion(3.2.1-beta)");
+ assertEquals("3.2.1-beta", versionInfo.getVersion(), "getVersion(3.2.1-beta)");
versionInfo.setBuildMeta("001");
- Assert.assertEquals(versionInfo.getVersion(), "3.2.1-beta+001", "getVersion(3.2.1-beta+001)");
+ assertEquals("3.2.1-beta+001", versionInfo.getVersion(), "getVersion(3.2.1-beta+001)");
+
+ versionInfo.setPreReleasePrefix("+");
+
+ assertEquals("3.2.1+beta+001", versionInfo.getVersion(), "getVersion(3.2.1+beta+001)");
+
+ versionInfo.setPreReleasePrefix("-");
versionInfo.setPreRelease("");
- Assert.assertEquals(versionInfo.getVersion(), "3.2.1+001", "getVersion(3.2.1+001)");
+ assertEquals("3.2.1+001", versionInfo.getVersion(), "getVersion(3.2.1+001)");
+
+ versionInfo.setBuildMetaPrefix(".");
+
+ assertEquals("3.2.1.001", versionInfo.getVersion(), "getVersion(3.2.1.001)");
+
+ versionInfo.setBuildMetaPrefix("+");
+
+ versionInfo.setSeparator("-");
+
+ assertEquals("3-2-1+001", versionInfo.getVersion(), "getVersion(3-2-1+001)");
+
+ assertEquals(versionInfo.getSemver(), versionInfo.getVersion(),
+ "getVersion(3-2-1+001) = getSemver(3-2-1+001) ");
}
@Test
- public void testSetGet() {
+ void testSetGet() {
+ versionInfo.setSeparator(".");
versionInfo.setMajor(1);
- Assert.assertEquals(versionInfo.getMajor(), 1, "getMajor(1)");
+ assertEquals(1, versionInfo.getMajor(), "getMajor(1)");
versionInfo.setMinor(2);
- Assert.assertEquals(versionInfo.getMinor(), 2, "getMinor(2)");
+ assertEquals(2, versionInfo.getMinor(), "getMinor(2)");
versionInfo.setPatch(3);
- Assert.assertEquals(versionInfo.getPatch(), 3, "getPatch(3)");
+ assertEquals(3, versionInfo.getPatch(), "getPatch(3)");
versionInfo.setPreRelease("alpha");
- Assert.assertEquals(versionInfo.getPreRelease(), "alpha", "getPreRelease(alpha)");
+ assertEquals("alpha", versionInfo.getPreRelease(), "getPreRelease(alpha)");
versionInfo.setBuildMeta("001");
- Assert.assertEquals(versionInfo.getBuildMeta(), "001", "getBuildMeta(001)");
+ assertEquals("001", versionInfo.getBuildMeta(), "getBuildMeta(001)");
versionInfo.setPackageName("com.example");
- Assert.assertEquals(versionInfo.getPackageName(), "com.example", "getPackageName(com.example)");
+ assertEquals("com.example", versionInfo.getPackageName(), "getPackageName(com.example)");
- Assert.assertEquals(versionInfo.getVersion(), "1.2.3-alpha+001", "getVersion(1.2.3-alpha+001)");
+ assertEquals("1.2.3-alpha+001", versionInfo.getVersion(), "getVersion(1.2.3-alpha+001)");
+
+ assertEquals(versionInfo.getSemver(), versionInfo.getVersion(), "getVersion() = getSemver()");
+
+ versionInfo.setBuildMetaPrefix("");
+
+ assertEquals("", versionInfo.getBuildMetaPrefix(), "getBuildMetaPrefix( )");
+
+ assertEquals("1.2.3-alpha001", versionInfo.getVersion(), "getVersion(1.2.3+alpha001)");
+
+ versionInfo.setPreReleasePrefix(".");
+
+ assertEquals(".", versionInfo.getPreReleasePrefix(), "getPreReleasePrefix(.)");
+
+ assertEquals("1.2.3.alpha001", versionInfo.getVersion(), "getVersion(1.2.3.alpha001");
+
+ versionInfo.setSeparator("-");
+
+ assertEquals("-", versionInfo.getSeparator(), "getSeparator(-)");
+
+ assertEquals("1-2-3.alpha001", versionInfo.getVersion(), "getVersion(1-2-3.alpha001)");
versionInfo.setProject("My Example");
- Assert.assertEquals(versionInfo.getProject(), "My Example", "getProject(My Example)");
+ assertEquals("My Example", versionInfo.getProject(), "getProject(My Example)");
versionInfo.setClassName("Example");
- Assert.assertEquals(versionInfo.getClassName(), "Example", "getClassName(Example");
+ assertEquals("Example", versionInfo.getClassName(), "getClassName(Example");
- Assert.assertTrue((versionInfo.getEpoch() - now.getTimeInMillis()) < 1000,
- "buildDate - now < 1s");
+ assertTrue((versionInfo.getEpoch() - new Date().getTime()) < 1000, "buildDate - now < 1s");
}
@Test
- public void testVersionInfo() {
-
+ void testVersionInfo() {
final Version version = new VersionTest();
versionInfo = new VersionInfo(version);
- Assert.assertEquals(versionInfo.getMajor(), version.major(), "getMajor(major)");
+ assertEquals(version.major(), versionInfo.getMajor(), "getMajor(major)");
- Assert.assertEquals(versionInfo.getMinor(), version.minor(), "getMinor(minor)");
+ assertEquals(version.minor(), versionInfo.getMinor(), "getMinor(minor)");
- Assert.assertEquals(versionInfo.getPatch(), version.patch(), "getPatch(patch)");
+ assertEquals(version.patch(), versionInfo.getPatch(), "getPatch(patch)");
- Assert.assertEquals(versionInfo.getPreRelease(), version.preRelease(), "getPreRelease(preRelease)");
+ assertEquals(version.preRelease(), versionInfo.getPreRelease(), "getPreRelease(preRelease)");
- Assert.assertEquals(versionInfo.getBuildMeta(), version.buildMeta(), "getBuildMeta(buildMeta)");
+ assertEquals(version.preReleasePrefix(), versionInfo.getPreReleasePrefix(),
+ "getPreReleasePrefix(preReleasePrefix)");
- Assert.assertEquals(versionInfo.getPackageName(), version.packageName(),
- "getPackageName(packageName)");
+ assertEquals(version.buildMeta(), versionInfo.getBuildMeta(), "getBuildMeta(buildMeta)");
- Assert.assertEquals(versionInfo.getVersion(),
- version.major()
- + "."
- + version.minor()
- + '.'
- + version.patch()
- + '-'
- + version.preRelease()
- + '+'
- + version.buildMeta(),
- "getVersion(version)");
+ assertEquals(version.buildMetaPrefix(), versionInfo.getBuildMetaPrefix(),
+ "getBuildMetaPrefix(buildMetaPrefix)");
- Assert.assertEquals(versionInfo.getProject(), version.project(), "getProject(project)");
+ assertEquals(version.packageName(), versionInfo.getPackageName(), "getPackageName(packageName)");
- Assert.assertEquals(versionInfo.getClassName(), version.className(), "getClassName(className)");
+ assertEquals(versionInfo.getVersion(),
+ version.major() + "." + version.minor() + '.' + version.patch() + '-' + version.preRelease() + '+'
+ + version.buildMeta(), "getVersion(version)");
+
+ assertEquals(versionInfo.getSemver(), versionInfo.getVersion(), "getVersion(version) = getSemver(version)");
+
+ assertEquals(version.project(), versionInfo.getProject(), "getProject(project)");
+
+ assertEquals(version.className(), versionInfo.getClassName(), "getClassName(className)");
}
}
-
-@SuppressWarnings({"ClassExplicitlyAnnotation", "BadAnnotationImplementation"})
-class VersionTest implements Version {
- @Override
- public Class extends Annotation> annotationType() {
- return null;
- }
-
- @Override
- public String buildMeta() {
- return "007";
- }
-
- @Override
- public String buildMetaKey() {
- return "build.meta";
- }
-
- @Override
- public String className() {
- return "MyTest";
- }
-
- @Override
- public String keysPrefix() {
- return "product.";
- }
-
- @Override
- public int major() {
- return 2;
- }
-
- @Override
- public String majorKey() {
- return "build.major";
- }
-
- @Override
- public int minor() {
- return 17;
- }
-
- @Override
- public String minorKey() {
- return "build.minor";
- }
-
- @Override
- public String packageName() {
- return "com.foo.example";
- }
-
- @Override
- public int patch() {
- return 52;
- }
-
- @Override
- public String patchKey() {
- return "build.patch";
- }
-
- @Override
- public String preRelease() {
- return "beta";
- }
-
- @Override
- public String preReleaseKey() {
- return "build.prerelease";
- }
-
- @Override
- public String project() {
- return "My Test Project";
- }
-
- @Override
- public String projectKey() {
- return "build.project";
- }
-
- @Override
- public String properties() {
- return "test.properties";
- }
-
- @Override
- public String template() {
- return "myversion.mustache";
- }
-
- @Override
- public String type() {
- return "kt";
- }
-}
\ No newline at end of file
diff --git a/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java b/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java
new file mode 100644
index 0000000..c49af74
--- /dev/null
+++ b/src/test/java/net/thauvin/erik/semver/VersionProcessorTest.java
@@ -0,0 +1,186 @@
+/*
+ * VersionProcessorTest.java
+ *
+ * Copyright (c) 2016-2024, 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.semver;
+
+import com.github.mustachejava.Mustache;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The VersionProcessorTest
class.
+ *
+ * @author Erik C. Thauvin
+ * @created 2019-04-02
+ * @since 1.2.0
+ */
+class VersionProcessorTest {
+ private final VersionProcessor processor = new VersionProcessor();
+ private final VersionTest version = new VersionTest();
+
+ /**
+ * Compares two strings by removing all line separators and whitespace.
+ *
+ * @param text1 The first text to compare
+ * @param text2 The second text to compare
+ * @return true if the texts are equivalent when line separators are ignored, false otherwise
+ */
+ static boolean compareTextIgnoringLineSeparators(String text1, String text2) {
+ // Handle null cases
+ if (text1 == null && text2 == null) {
+ return true;
+ }
+ if (text1 == null || text2 == null) {
+ return false;
+ }
+
+ // Remove all line separators and whitespace
+ var cleanedText1 = text1.replaceAll("\\r?\\n|\\r|\\s", "");
+ var cleanedText2 = text2.replaceAll("\\r?\\n|\\r|\\s", "");
+
+ // Compare the cleaned strings
+ return cleanedText1.equals(cleanedText2);
+ }
+
+ @SuppressWarnings("PMD.AvoidAccessibilityAlteration")
+ @Test
+ void testCompileTemplate()
+ throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException {
+ final var method = processor.getClass().getDeclaredMethod("compileTemplate", File.class, String.class);
+ method.setAccessible(true);
+
+ final var mustache = (Mustache) method.invoke(processor, new File("src/main/resources"),
+ Constants.DEFAULT_JAVA_TEMPLATE);
+
+ assertEquals(Constants.DEFAULT_JAVA_TEMPLATE, mustache.getName(), Constants.DEFAULT_JAVA_TEMPLATE);
+
+ try (var writer = new StringWriter()) {
+ mustache.execute(writer, version).flush();
+ assertTrue(compareTextIgnoringLineSeparators(
+ String.format("/*" +
+ " * This file is automatically generated." +
+ " * Do not modify! -- ALL CHANGES WILL BE ERASED!" +
+ " */" +
+ "package %s;" +
+ "import java.util.Date;" +
+ "/**" +
+ " * Provides semantic version information." +
+ " *" +
+ " * @author Semantic Version Annotation Processor " +
+ " */" +
+ "public final class %s {" +
+ " public static final String PROJECT = \"%s\";" +
+ " public static final Date BUILDDATE = new Date(L);" +
+ " public static final int MAJOR = %d;" +
+ " public static final int MINOR = %d;" +
+ " public static final int PATCH = %d;" +
+ " public static final String PRERELEASE = \"%s\";" +
+ " public static final String PRERELEASE_PREFIX = \"%s\";" +
+ " public static final String BUILDMETA = \"%s\";" +
+ " public static final String BUILDMETA_PREFIX = \"%s\";" +
+ " public static final String SEPARATOR = \"%s\";" +
+ " public static final String VERSION = \"\";" +
+ " /**" +
+ " * Disables the default constructor." +
+ " */" +
+ " private %s() {" +
+ " throw new UnsupportedOperationException(\"Illegal constructor call.\");" +
+ " }" +
+ "}", version.packageName(), version.className(), version.project(), version.major(),
+ version.minor(), version.patch(), version.preRelease(), version.preReleasePrefix(),
+ version.buildMeta(), version.buildMetaPrefix(), version.separator(), version.className()),
+ writer.toString()));
+ }
+ }
+
+ @SuppressWarnings("PMD.AvoidAccessibilityAlteration")
+ @Test
+ void testFindValues() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ final var method = processor.getClass().getDeclaredMethod("findValues", Version.class);
+ method.setAccessible(true);
+ final var versionInfo = (VersionInfo) method.invoke(processor, version);
+
+ assertEquals("0-0-7:vodka++martini", versionInfo.getVersion(), "getVersion(0-0-7:vodka++martin)");
+ assertEquals("James Bond", versionInfo.getProject(), "getProject(James Bond)");
+ }
+
+ @Test
+ void testGetSupportedAnnotationTypes() {
+ assertTrue(processor.getSupportedAnnotationTypes().contains("net.thauvin.erik.semver.Version"));
+ }
+
+ @Test
+ void testGetSupportedSourceVersion() {
+ assertTrue(processor.getSupportedSourceVersion().ordinal() >= 17);
+ }
+
+ @SuppressWarnings("PMD.AvoidAccessibilityAlteration")
+ @Test
+ void testGetTemplate() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ final var method = processor.getClass().getDeclaredMethod("getTemplate", boolean.class, Version.class);
+ method.setAccessible(true);
+
+ assertEquals(version.template(), method.invoke(processor, true, version), version.template);
+ version.setTemplate(Constants.DEFAULT_JAVA_TEMPLATE);
+ assertEquals(Constants.DEFAULT_TEMPLATE_NAME, method.invoke(processor, true, version),
+ "default");
+ assertEquals(Constants.DEFAULT_KOTLIN_TEMPLATE, method.invoke(processor, false, version),
+ "kotlin");
+ }
+
+ @SuppressWarnings("PMD.AvoidAccessibilityAlteration")
+ @Test
+ void testParseIntProperty() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ final var p = new Properties();
+ p.setProperty("1", "1");
+ p.setProperty("2", "2.1");
+ p.setProperty("3", "zero");
+ p.setProperty("4", " 4 ");
+
+ final var method = processor.getClass().getDeclaredMethod("parseIntProperty", Properties.class, String.class,
+ int.class);
+ method.setAccessible(true);
+
+ assertEquals(1, method.invoke(processor, p, "1", -1), "parseIntProperty(1)");
+ assertEquals(-1, method.invoke(processor, p, "2", -1), "parseIntProperty(2.1)");
+ assertEquals(-1, method.invoke(processor, p, "3", -1), "parseIntProperty(zero)");
+ assertEquals(4, method.invoke(processor, p, "4", -1), "parseIntProperty( 4 )");
+ }
+}
diff --git a/src/test/java/net/thauvin/erik/semver/VersionTest.java b/src/test/java/net/thauvin/erik/semver/VersionTest.java
new file mode 100644
index 0000000..e27f316
--- /dev/null
+++ b/src/test/java/net/thauvin/erik/semver/VersionTest.java
@@ -0,0 +1,176 @@
+/*
+ * VersionTest.java
+ *
+ * Copyright (c) 2016-2024, 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.semver;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * The VersionTest
class.
+ *
+ * @author Erik C. Thauvin
+ * @created 2019-04-02
+ * @since 1.2.0
+ */
+@SuppressWarnings({"ClassExplicitlyAnnotation", "PMD.TestClassWithoutTestCases"})
+class VersionTest implements Version {
+ String template = "myversion.mustache";
+
+ @Override
+ public Class extends Annotation> annotationType() {
+ return null;
+ }
+
+ @Override
+ public String buildMeta() {
+ return "007";
+ }
+
+ @Override
+ public String buildMetaKey() {
+ return "meta";
+ }
+
+ @Override
+ public String buildMetaPrefix() {
+ return "+";
+ }
+
+ @Override
+ public String buildMetaPrefixKey() {
+ return "meta.prefix";
+ }
+
+ @Override
+ public String className() {
+ return "MyTest";
+ }
+
+ @Override
+ public String keysPrefix() {
+ return "build.";
+ }
+
+ @Override
+ public int major() {
+ return 2;
+ }
+
+ @Override
+ public String majorKey() {
+ return "major";
+ }
+
+ @Override
+ public int minor() {
+ return 17;
+ }
+
+ @Override
+ public String minorKey() {
+ return "minor";
+ }
+
+ @Override
+ public String packageName() {
+ return "com.foo.example";
+ }
+
+ @Override
+ public int patch() {
+ return 52;
+ }
+
+ @Override
+ public String patchKey() {
+ return "patch";
+ }
+
+ @Override
+ public String preRelease() {
+ return "beta";
+ }
+
+ @Override
+ public String preReleaseKey() {
+ return "prerelease";
+ }
+
+ @Override
+ public String preReleasePrefix() {
+ return "-";
+ }
+
+ @Override
+ public String preReleasePrefixKey() {
+ return "prerelease.prefix";
+ }
+
+ @Override
+ public String project() {
+ return "My Test Project";
+ }
+
+ @Override
+ public String projectKey() {
+ return "project";
+ }
+
+ @Override
+ public String properties() {
+ return "test.properties";
+ }
+
+ @Override
+ public String separator() {
+ return ".";
+ }
+
+ @Override
+ public String separatorKey() {
+ return "separator";
+ }
+
+ @Override
+ public String template() {
+ return template;
+ }
+
+ @Override
+ public String type() {
+ return "kt";
+ }
+
+ public void setTemplate(final String template) {
+ this.template = template;
+ }
+}
diff --git a/test.properties b/test.properties
new file mode 100644
index 0000000..98cab4c
--- /dev/null
+++ b/test.properties
@@ -0,0 +1,9 @@
+build.major=0
+build.minor=0
+build.patch=7
+build.prerelease=vodka
+build.prerelease.prefix=:
+build.meta=martini
+build.meta.prefix=++
+build.separator=-
+build.project=James Bond
diff --git a/updatewrappers.sh b/updatewrappers.sh
deleted file mode 100644
index 81cad95..0000000
--- a/updatewrappers.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-echo "semver"
-gradle -q wrapper
-kobaltw --update --log 0
-./kobaltw --version
-cd examples/java
-echo
-echo "examples/java"
-gradle -q wrapper
-kobaltw --update --log 0
-./kobaltw --version
-echo
-echo "examples/kotlin"
-cd ../kotlin
-gradle -q wrapper
-cd ..
diff --git a/version.properties b/version.properties
deleted file mode 100644
index 1f51dae..0000000
--- a/version.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-#Generated by the Semver Plugin for Gradle
-#Sat Nov 03 17:10:00 PDT 2018
-version.buildmeta=
-version.major=1
-version.minor=1
-version.patch=0
-version.prerelease=beta