diff --git a/.github_changelog_generator b/.github_changelog_generator deleted file mode 100644 index 13dd68d..0000000 --- a/.github_changelog_generator +++ /dev/null @@ -1 +0,0 @@ -future-release=1.2.1 diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 40012f2..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/BSD_3_Clause.xml b/.idea/copyright/BSD_3_Clause.xml index 025a880..956f692 100644 --- a/.idea/copyright/BSD_3_Clause.xml +++ b/.idea/copyright/BSD_3_Clause.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index dd82085..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index 4e9cedf..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index f8467b4..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 32dcb40..dbc8bc6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -6,16 +6,10 @@ - - - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index c98f120..55adcb9 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,7 +4,6 @@ - \ No newline at end of file diff --git a/.idea/modules/examples-java.main.iml b/.idea/modules/examples-java.main.iml deleted file mode 100644 index 807b620..0000000 --- a/.idea/modules/examples-java.main.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/scopes/Source_Code.xml b/.idea/scopes/Source_Code.xml deleted file mode 100644 index 1753056..0000000 --- a/.idea/scopes/Source_Code.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6224f..41eb07d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,9 @@ # Changelog -## [1.2.1](https://github.com/ethauvin/semver/tree/1.2.1) (2023-09-29) +## [1.2.1](https://github.com/ethauvin/semver/tree/1.2.1) (2021-04-29) [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) diff --git a/README.md b/README.md index 0469a21..c13ec3d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Semantic Version Annotation Processor +# Semantic Version Annotation Processor [![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) -[![bld](https://img.shields.io/badge/1.7.2-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) +[![bld](https://img.shields.io/badge/1.7.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![release](https://img.shields.io/github/release/ethauvin/semver.svg)](https://github.com/ethauvin/semver/releases/latest) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/semver) [![Nexus Snapshot](https://img.shields.io/nexus/s/net.thauvin.erik/semver?label=snapshot&server=https%3A%2F%2Foss.sonatype.org%2F)](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/semver/) -[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/semver.svg)](https://central.sonatype.com/artifact/net.thauvin.erik/semver) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_semver&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_semver) [![GitHub CI](https://github.com/ethauvin/semver/actions/workflows/gradle.yml/badge.svg)](https://github.com/ethauvin/semver/actions/workflows/gradle.yml) @@ -17,7 +17,6 @@ An [annotation processor](https://docs.oracle.com/javase/8/docs/api/javax/annota 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 - - [Examples](#examples) - [Template](#template) - [Default Template](#default-template) @@ -34,7 +33,7 @@ This processor was inspired by Cédric Beust's [version-processor](https://githu ## Examples -- Using annotation elements: +* Using annotation elements: ```java import net.thauvin.erik.semver.Version; @@ -45,7 +44,7 @@ public class A { } ``` -- Or using a [properties](hhttps://github.com/ethauvin/semver/blob/master/examples/java/version.properties) file: +* Or using a [properties](hhttps://github.com/ethauvin/semver/blob/master/examples/java/version.properties) file: ```java import net.thauvin.erik.semver.Version; @@ -221,8 +220,8 @@ public class ExampleBuild extends Project { } } ``` +Please look at [ExamapleBuild](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. -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). ## Gradle @@ -240,7 +239,7 @@ dependencies { compileOnly 'net.thauvin.erik:semver:1.2.1-SNAPSHOT' } -tasks.withType(JavaCompile).configureEach { +tasks.withType(JavaCompile) { options.compilerArgs += [ "-Asemver.project.dir=$projectDir" ] } ``` @@ -256,7 +255,7 @@ Please look at [build.gradle](https://github.com/ethauvin/semver/blob/master/exa 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 { +tasks.withType(JavaCompile) { options.generatedSourceOutputDirectory.set(file("${projectDir}/src/generated/java")) } ``` @@ -277,7 +276,6 @@ 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 [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. diff --git a/examples/java/gradle/build.gradle b/examples/java/gradle/build.gradle index 6107ccf..a89c79b 100644 --- a/examples/java/gradle/build.gradle +++ b/examples/java/gradle/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'application' - id 'com.github.ben-manes.versions' version '0.48.0' + id 'com.github.ben-manes.versions' version '0.47.0' } // ./gradlew run @@ -11,6 +11,11 @@ defaultTasks 'run' final def semverProcessor = 'net.thauvin.erik:semver:1.2.1-SNAPSHOT' +sourceCompatibility = 17 +targetCompatibility = 17 + +mainClassName = 'com.example.App' + repositories { mavenLocal() mavenCentral() @@ -22,21 +27,12 @@ dependencies { implementation semverProcessor } -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -application { - mainClassName = 'com.example.App' -} - -tasks.withType(JavaCompile).configureEach { +tasks.withType(JavaCompile) { options.generatedSourceOutputDirectory.set(file("${projectDir}/src/generated/java")) options.compilerArgs += ["-Asemver.project.dir=$projectDir"] } -tasks.register("runExample", JavaExec) { +task runExample(type: JavaExec) { group = 'application' classpath = sourceSets.main.runtimeClasspath mainClass.set('com.example.Example') diff --git a/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java b/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java index f2140d0..943ebb0 100644 --- a/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java +++ b/examples/java/gradle/src/generated/java/com/example/ExampleVersion.java @@ -9,7 +9,7 @@ import java.util.Date; public final class ExampleVersion { public static final String PROJECT = "Java Example"; - public static final Date BUILDDATE = new Date(1696019617021L); + public static final Date BUILDDATE = new Date(1692564205424L); public static final String VERSION = "8.4.97-alpha+T800"; /** diff --git a/examples/java/gradle/src/generated/java/com/example/GeneratedVersion.java b/examples/java/gradle/src/generated/java/com/example/GeneratedVersion.java index d397944..28b778b 100644 --- a/examples/java/gradle/src/generated/java/com/example/GeneratedVersion.java +++ b/examples/java/gradle/src/generated/java/com/example/GeneratedVersion.java @@ -14,7 +14,7 @@ import java.util.Date; */ public final class GeneratedVersion { public static final String PROJECT = "Java App"; -public static final Date BUILDDATE = new Date(1696019617081L); +public static final Date BUILDDATE = new Date(1692564205452L); public static final int MAJOR = 11; public static final int MINOR = 11; public static final int PATCH = 20; diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts index 6a714d9..9c52a47 100644 --- a/examples/kotlin/build.gradle.kts +++ b/examples/kotlin/build.gradle.kts @@ -1,8 +1,8 @@ plugins { id("application") - id("com.github.ben-manes.versions") version "0.48.0" - kotlin("jvm") version "1.9.10" - kotlin("kapt") version "1.9.10" + id("com.github.ben-manes.versions") version "0.47.0" + kotlin("jvm") version "1.9.0" + kotlin("kapt") version "1.9.0" } // ./gradlew diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 675f518..dd33837 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -1,9 +1,10 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true +bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.2 +bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.0 +bld.extension-testng=com.uwyn.rife2:bld-testng:0.9.1-SNAPSHOT bld.extension-exec=com.uwyn.rife2:bld-exec:0.9.0-SNAPSHOT -bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1-SNAPSHOT -bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.3-SNAPSHOT -bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES +bld.repositories=MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.downloadLocation= bld.sourceDirectories= bld.version=1.7.2 diff --git a/src/main/java/net/thauvin/erik/semver/Constants.java b/src/main/java/net/thauvin/erik/semver/Constants.java index a8bc374..8dbc3d5 100644 --- a/src/main/java/net/thauvin/erik/semver/Constants.java +++ b/src/main/java/net/thauvin/erik/semver/Constants.java @@ -137,11 +137,13 @@ public final class Constants { * 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. */ diff --git a/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/src/main/resources/META-INF/services/javax.annotation.processing.Processor index 44488e0..5ae1016 100644 --- a/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ b/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -1 +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/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java index 2abb01a..0ebbbf5 100644 --- a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java +++ b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java @@ -34,7 +34,7 @@ package net.thauvin.erik.semver; import org.junit.jupiter.api.Test; -import java.util.Date; +import java.util.Date; // NOPMD import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..3966686 --- /dev/null +++ b/version.properties @@ -0,0 +1,8 @@ +#Generated by the Semver Plugin for Gradle +#Sun May 02 21:54:48 PDT 2021 +version.buildmeta= +version.major=1 +version.minor=2 +version.patch=1 +version.prerelease=SNAPSHOT +version.semver=1.2.1-SNAPSHOT