diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d9e04b..361f8c9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,6 +4,19 @@ + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a22e047 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,48 @@ +# Change Log + +## [Unreleased](https://github.com/ethauvin/semver/tree/HEAD) + +[Full Changelog](https://github.com/ethauvin/semver/compare/1.1.1...HEAD) + +**Implemented enhancements:** + +- kapt and Kotlin 1.3.30 require kapt.use.worker.api=true [\#2](https://github.com/ethauvin/semver/issues/2) + +**Fixed bugs:** + +- kapt and Kotlin 1.3.30 require kapt.use.worker.api=true [\#2](https://github.com/ethauvin/semver/issues/2) + +## [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) + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/build.gradle b/build.gradle index eb6ce8e..e4f2379 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ plugins { id 'java' id 'jacoco' id 'maven-publish' + id 'pmd' id 'com.jfrog.bintray' version '1.8.4' id 'com.github.ben-manes.versions' version '0.21.0' - id 'net.thauvin.erik.gradle.semver' version '0.9.9-beta' + id 'net.thauvin.erik.gradle.semver' version '1.0.0' id 'com.github.spotbugs' version '1.7.1' id 'org.sonarqube' version '2.7' } @@ -27,7 +28,7 @@ def mavenScmDevCon = 'git@github.com:ethauvin/semver.git' def pkgLicenses = ['BSD 3-Clause'] def pkgIssueTrackerUrl = mavenUrl + '/issues' -def pkgLabels = ['java', 'annotation', 'processor', 'semantic', 'version'] +def pkgLabels = ['java', 'kotlin', 'annotation', 'processor', 'semantic', 'version'] sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -51,6 +52,11 @@ dependencies { testImplementation 'org.testng:testng:6.14.3' } +pmd { + ruleSetFiles = files("config/pmd.xml") + ruleSets = [] +} + bintray { user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') diff --git a/config/pmd.xml b/config/pmd.xml new file mode 100644 index 0000000..6e60806 --- /dev/null +++ b/config/pmd.xml @@ -0,0 +1,254 @@ + + + Erik's Ruleset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ^ignore$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/java/build.gradle b/examples/java/build.gradle index d8240a5..6fce5c9 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -4,7 +4,8 @@ plugins { id 'com.github.ben-manes.versions' version '0.21.0' } -// ./gradlew +// ./gradlew run +// ./gradlew runExample defaultTasks 'run' @@ -15,7 +16,7 @@ targetCompatibility = 1.8 compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java") -mainClassName = 'com.example.Example' +mainClassName = 'com.example.App' repositories { mavenLocal() @@ -26,3 +27,10 @@ dependencies { annotationProcessor semverProcessor compileOnly semverProcessor } + +task runExample(type: JavaExec) { + group = 'application' + classpath = sourceSets.main.runtimeClasspath + + main = 'com.example.Example' +} diff --git a/examples/java/example.mustache b/examples/java/example.mustache index 9279c7f..70125c1 100644 --- a/examples/java/example.mustache +++ b/examples/java/example.mustache @@ -10,11 +10,6 @@ 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 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 BUILDMETA = "{{buildMeta}}"; public static final String VERSION = "{{version}}"; /** diff --git a/examples/java/example.properties b/examples/java/example.properties new file mode 100644 index 0000000..d0b5ce4 --- /dev/null +++ b/examples/java/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/java/gradle/wrapper/gradle-wrapper.properties index 5f1b120..f4d7b2b 100644 --- a/examples/java/gradle/wrapper/gradle-wrapper.properties +++ b/examples/java/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/java/src/generated/java/com/example/ExampleVersion.java b/examples/java/src/generated/java/com/example/ExampleVersion.java new file mode 100644 index 0000000..1b14175 --- /dev/null +++ b/examples/java/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(1556420335650L); + 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/src/generated/java/com/example/GeneratedVersion.java b/examples/java/src/generated/java/com/example/GeneratedVersion.java index fdaf6f7..c6647f2 100644 --- a/examples/java/src/generated/java/com/example/GeneratedVersion.java +++ b/examples/java/src/generated/java/com/example/GeneratedVersion.java @@ -6,15 +6,23 @@ package com.example; import java.util.Date; +/** + * Provides semantic version information. + * + * @author Semantic Version Annotation Processor + */ public final class GeneratedVersion { - public final static String PROJECT = "Java Example"; - public final static Date BUILDDATE = new Date(1555703771370L); - public final static int MAJOR = 2; - public final static int MINOR = 0; - public final static int PATCH = 52; + public final static String PROJECT = "Java App"; + public final static Date BUILDDATE = new Date(1556420335600L); + public final static int MAJOR = 11; + public final static int MINOR = 11; + public final static int PATCH = 20; public final static String PRERELEASE = "beta"; + public final static String PRERELEASE_PREFIX = "-"; public final static String BUILDMETA = "007"; - public final static String VERSION = "2.0.52-beta+007"; + public final static String BUILDMETA_PREFIX = "+"; + public final static String SEPARATOR = "."; + public final static String VERSION = "11.11.20-beta+007"; /** * Disables the default constructor. diff --git a/examples/java/src/main/java/com/example/App.java b/examples/java/src/main/java/com/example/App.java new file mode 100644 index 0000000..9875a22 --- /dev/null +++ b/examples/java/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 SimpleDateFormat 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/src/main/java/com/example/Example.java b/examples/java/src/main/java/com/example/Example.java index 9b654ce..324030f 100644 --- a/examples/java/src/main/java/com/example/Example.java +++ b/examples/java/src/main/java/com/example/Example.java @@ -3,24 +3,25 @@ package com.example; import net.thauvin.erik.semver.Version; import java.text.SimpleDateFormat; +import java.util.Locale; -//@Version(properties = "version.properties", template = "example.mustache") -@Version(properties = "version.properties") -public class Example { +@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("EEE, d MMM yyyy 'at' HH:mm:ss z"); + final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US); - System.out.println("-----------------------------------------------------"); + System.out.println("-- From Example -------------------------------------"); - 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(" " + ExampleVersion.PROJECT + ' ' + ExampleVersion.VERSION + + " (" + sdf.format(ExampleVersion.BUILDDATE) + ')'); System.out.println("-----------------------------------------------------"); } } + diff --git a/examples/java/version.properties b/examples/java/version.properties index ac49981..dc68bf3 100644 --- a/examples/java/version.properties +++ b/examples/java/version.properties @@ -1,8 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Sat Mar 30 15:48:08 PDT 2019 +#Sat Apr 27 17:05:34 PDT 2019 version.buildmeta=007 -version.major=2 -version.minor=0 -version.patch=52 +version.major=11 +version.minor=11 +version.patch=20 version.prerelease=beta -version.project=Java Example +version.project=Java App +version.semver=11.11.20-beta+007 diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts index cb6f70d..e783526 100644 --- a/examples/kotlin/build.gradle.kts +++ b/examples/kotlin/build.gradle.kts @@ -6,8 +6,10 @@ plugins { } // ./gradlew +// ./gradlew run // ./gradlew runJava -// ./gradlew run runJava +// ./gradlew runExample +// ./gradlew runJavaExample defaultTasks(ApplicationPlugin.TASK_RUN_NAME) @@ -32,11 +34,25 @@ repositories { } application { - mainClassName = "com.example.Main" + mainClassName = "com.example.App" } tasks { register("runJava", JavaExec::class) { + group = "application" + main = "com.example.JavaApp" + classpath = sourceSets["main"].runtimeClasspath + + } + + register("runJavaExample", JavaExec::class) { + group = "application" + main = "com.example.JavaExample" + classpath = sourceSets["main"].runtimeClasspath + } + + register("runExample", JavaExec::class) { + group = "application" main = "com.example.Example" classpath = sourceSets["main"].runtimeClasspath } diff --git a/examples/kotlin/example.mustache b/examples/kotlin/example.mustache index 6ac1c06..50b6b1a 100644 --- a/examples/kotlin/example.mustache +++ b/examples/kotlin/example.mustache @@ -18,15 +18,5 @@ object {{className}} { @JvmField val BUILDDATE = Date({{epoch}}L) @JvmField - val MAJOR = {{major}} - @JvmField - val MINOR = {{minor}} - @JvmField - val PATCH = {{patch}} - @JvmField - val PRERELEASE = "{{preRelease}}" - @JvmField - val BUILDMETA = "{{buildMeta}}" - @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/wrapper/gradle-wrapper.properties b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties index 5f1b120..f4d7b2b 100644 --- a/examples/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/examples/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists 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 ba23235..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 ----------------------------------------"); 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..cf6918c --- /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 89% rename from examples/kotlin/src/main/kotlin/com/example/Main.kt rename to examples/kotlin/src/main/kotlin/com/example/App.kt index 682132a..6af44aa 100644 --- a/examples/kotlin/src/main/kotlin/com/example/Main.kt +++ b/examples/kotlin/src/main/kotlin/com/example/App.kt @@ -2,14 +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", template = "example.mustache") @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") + val sdf = SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z", Locale.US) println("-----------------------------------------------------") 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..81bf914 --- /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 d097cae..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=Kotlin Example +version.project=Kotlin App +version.semver=11.11.20-beta+007 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5f1b120..f4d7b2b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/preflightcheck.sh b/preflightcheck.sh index 951db6e..67359b9 100644 --- a/preflightcheck.sh +++ b/preflightcheck.sh @@ -8,8 +8,8 @@ ext=".java" java8=true # e.g: declare -a examples=( - "examples/java run" - "examples/kotlin run runJava") + "examples/java run runExample" + "examples/kotlin run runJava runExample runJavaExample") # e.g: empty or javadoc, etc. gradle_doc="javadoc pandoc" # e.g. empty or sonarqube diff --git a/src/main/java/net/thauvin/erik/semver/VersionInfo.java b/src/main/java/net/thauvin/erik/semver/VersionInfo.java index 61d015c..45904ac 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionInfo.java +++ b/src/main/java/net/thauvin/erik/semver/VersionInfo.java @@ -39,6 +39,7 @@ package net.thauvin.erik.semver; * @created 2016-01-16 * @since 1.0 */ +@SuppressWarnings("PMD.DataClass") public class VersionInfo { private final long epoch = System.currentTimeMillis(); diff --git a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java index a50e66e..886b98f 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java +++ b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java @@ -70,6 +70,7 @@ import java.util.Set; * @created 2016-01-13 * @since 1.0 */ +@SuppressWarnings("PMD.GuardLogStatement") @SupportedOptions({Constants.KAPT_KOTLIN_GENERATED_OPTION_NAME, Constants.SEMVER_PROJECT_DIR_ARG}) public class VersionProcessor extends AbstractProcessor { private Filer filer; @@ -84,7 +85,7 @@ public class VersionProcessor extends AbstractProcessor { log(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s)); } - @SuppressFBWarnings(value = {"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"}) + @SuppressFBWarnings({"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"}) private VersionInfo findValues(final Version version) throws IOException { final VersionInfo versionInfo = new VersionInfo(version); @@ -137,7 +138,7 @@ public class VersionProcessor extends AbstractProcessor { return versionInfo; } - private String getProjectDir(String fileName) { + private String getProjectDir(final String fileName) { if (processingEnv != null) { // null when testing. final String prop = processingEnv.getOptions().get(Constants.SEMVER_PROJECT_DIR_ARG); if (prop != null) { @@ -169,6 +170,7 @@ public class VersionProcessor extends AbstractProcessor { /** * {@inheritDoc} */ + @SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel") @Override public synchronized void init(final ProcessingEnvironment processingEnv) { super.init(processingEnv); @@ -201,6 +203,7 @@ public class VersionProcessor extends AbstractProcessor { */ @Override public boolean process(final Set annotations, final RoundEnvironment roundEnv) { + final boolean isLocalTemplate = new File(Constants.DEFAULT_TEMPLATE_NAME).exists(); for (final Element element : roundEnv.getElementsAnnotatedWith(Version.class)) { final Version version = element.getAnnotation(Version.class); if (element.getKind() == ElementKind.CLASS) { @@ -215,7 +218,7 @@ public class VersionProcessor extends AbstractProcessor { note("Found version: " + versionInfo.getVersion()); final String template; if (Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template()) - && new File(Constants.DEFAULT_TEMPLATE_NAME).exists()) { + && isLocalTemplate) { template = Constants.DEFAULT_TEMPLATE_NAME; } else if (Constants.DEFAULT_JAVA_TEMPLATE.equals(version.template()) && Constants.KOTLIN_TYPE.equals(version.type())) { @@ -238,7 +241,7 @@ public class VersionProcessor extends AbstractProcessor { log(Diagnostic.Kind.WARNING, s); } - @SuppressFBWarnings(value = {"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"}) + @SuppressFBWarnings({"PATH_TRAVERSAL_IN", "UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"}) private void writeTemplate(final String type, final VersionInfo versionInfo, final String template) diff --git a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java index 4972d63..d8e09dd 100644 --- a/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java +++ b/src/test/java/net/thauvin/erik/semver/VersionInfoTest.java @@ -50,6 +50,7 @@ public class VersionInfoTest { private final Calendar now = Calendar.getInstance(); private VersionInfo versionInfo = new VersionInfo(); + @SuppressWarnings("PMD.AvoidUsingHardCodedIP") @Test public void testGetVersion() { Assert.assertEquals(versionInfo.getVersion(), "1.0.0", "getVersion(1.0.0)"); diff --git a/version.properties b/version.properties index 66b85c5..448ca88 100644 --- a/version.properties +++ b/version.properties @@ -1,7 +1,8 @@ #Generated by the Semver Plugin for Gradle -#Sat Mar 30 18:10:32 PDT 2019 +#Fri Apr 26 18:43:34 PDT 2019 version.buildmeta= version.major=1 version.minor=2 version.patch=0 version.prerelease= +version.semver=1.2.0