Added new example with custom properties and template.

This commit is contained in:
Erik C. Thauvin 2019-04-27 20:10:50 -07:00
parent 0fb4324d8d
commit f801ce03fe
28 changed files with 533 additions and 65 deletions

13
.idea/misc.xml generated
View file

@ -4,6 +4,19 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="PDMPlugin">
<option name="customRuleSets">
<list>
<option value="K:\java\semver\config\pmd.xml" />
</list>
</option>
<option name="options">
<map>
<entry key="Encoding" value="" />
<entry key="Target JDK" value="1.8" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>

48
CHANGELOG.md Normal file
View file

@ -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)*

View file

@ -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')

254
config/pmd.xml Normal file
View file

@ -0,0 +1,254 @@
<?xml version="1.0"?>
<ruleset name="erik"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Erik's Ruleset</description>
<!-- BEST PRACTICES -->
<rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/>
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt"/>
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/>
<rule ref="category/java/bestpractices.xml/GuardLogStatement"/>
<rule ref="category/java/bestpractices.xml/LooseCoupling"/>
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray"/>
<rule ref="category/java/bestpractices.xml/MissingOverride"/>
<rule ref="category/java/bestpractices.xml/PositionLiteralsFirstInCaseInsensitiveComparisons"/>
<rule ref="category/java/bestpractices.xml/PositionLiteralsFirstInComparisons"/>
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
<rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator"/>
<rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap"/>
<rule ref="category/java/bestpractices.xml/ReplaceVectorWithList"/>
<rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault"/>
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
<rule ref="category/java/bestpractices.xml/UnusedImports"/>
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
<rule ref="category/java/bestpractices.xml/UseAssertEqualsInsteadOfAssertTrue"/>
<rule ref="category/java/bestpractices.xml/UseAssertNullInsteadOfAssertTrue"/>
<rule ref="category/java/bestpractices.xml/UseAssertSameInsteadOfAssertTrue"/>
<rule ref="category/java/bestpractices.xml/UseAssertTrueInsteadOfAssertEquals"/>
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
<rule ref="category/java/bestpractices.xml/UseVarargs"/>
<!-- NAMING CONVENTIONS -->
<rule ref="category/java/codestyle.xml/FormalParameterNamingConventions"/>
<rule ref="category/java/codestyle.xml/GenericsNaming"/>
<rule ref="category/java/codestyle.xml/LocalVariableNamingConventions"/>
<rule ref="category/java/codestyle.xml/MethodNamingConventions"/>
<rule ref="category/java/codestyle.xml/PackageCase"/>
<!-- OTHER -->
<rule ref="category/java/codestyle.xml/AvoidDollarSigns"/>
<rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/>
<rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/>
<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>
<rule ref="category/java/codestyle.xml/BooleanGetMethodName"/>
<rule ref="category/java/codestyle.xml/CallSuperInConstructor"/>
<rule ref="category/java/codestyle.xml/ControlStatementBraces"/>
<rule ref="category/java/codestyle.xml/DontImportJavaLang"/>
<rule ref="category/java/codestyle.xml/DuplicateImports"/>
<rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract"/>
<rule ref="category/java/codestyle.xml/ExtendsObject"/>
<rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass"/>
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/>
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
<rule ref="category/java/codestyle.xml/LocalVariableCouldBeFinal"/>
<rule ref="category/java/codestyle.xml/MethodArgumentCouldBeFinal"/>
<rule ref="category/java/codestyle.xml/NoPackage"/>
<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>
<rule ref="category/java/codestyle.xml/TooManyStaticImports"/>
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
<rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
<rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
<!-- DESIGN -->
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod"/>
<rule ref="category/java/design.xml/AvoidRethrowingException"/>
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes"/>
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
<rule ref="category/java/design.xml/CollapsibleIfStatements"/>
<rule ref="category/java/design.xml/CouplingBetweenObjects"/>
<rule ref="category/java/design.xml/DataClass"/>
<rule ref="category/java/design.xml/DoNotExtendJavaLangError"/>
<rule ref="category/java/design.xml/ExceptionAsFlowControl"/>
<rule ref="category/java/design.xml/ExcessivePublicCount"/>
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
<rule ref="category/java/design.xml/ImmutableField"/>
<rule ref="category/java/design.xml/LogicInversion"/>
<rule ref="category/java/design.xml/SignatureDeclareThrowsException"/>
<rule ref="category/java/design.xml/SimplifiedTernary"/>
<rule ref="category/java/design.xml/SimplifyBooleanAssertion"/>
<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
<rule ref="category/java/design.xml/SimplifyBooleanReturns"/>
<rule ref="category/java/design.xml/SimplifyConditional"/>
<rule ref="category/java/design.xml/SingularField"/>
<rule ref="category/java/design.xml/SwitchDensity"/>
<rule ref="category/java/design.xml/UselessOverridingMethod"/>
<rule ref="category/java/design.xml/UseUtilityClass"/>
<!-- DOCUMENTATION -->
<rule ref="category/java/documentation.xml/UncommentedEmptyConstructor"/>
<rule ref="category/java/documentation.xml/UncommentedEmptyMethodBody"/>
<!-- ERROR PRONE -->
<rule ref="category/java/errorprone.xml/AssignmentInOperand">
<properties>
<property name="allowWhile" value="true"/>
</properties>
</rule>
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
<rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration"/>
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier"/>
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize"/>
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable"/>
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals"/>
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier"/>
<rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause"/>
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation"/>
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
<rule ref="category/java/errorprone.xml/BadComparison"/>
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
<rule ref="category/java/errorprone.xml/CallSuperFirst"/>
<rule ref="category/java/errorprone.xml/CallSuperLast"/>
<rule ref="category/java/errorprone.xml/CheckSkipResult"/>
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/>
<rule ref="category/java/errorprone.xml/CloneMethodMustBePublic"/>
<rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable"/>
<rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/>
<rule ref="category/java/errorprone.xml/CloneThrowsCloneNotSupportedException"/>
<rule ref="category/java/errorprone.xml/CloseResource"/>
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals"/>
<rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod"/>>
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable"/>
<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard"/>
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally"/>
<rule ref="category/java/errorprone.xml/DontImportSun"/>
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
<rule ref="category/java/errorprone.xml/EqualsNull"/>
<rule ref="category/java/errorprone.xml/FinalizeDoesNotCallSuperFinalize"/>
<rule ref="category/java/errorprone.xml/FinalizeOnlyCallsSuperFinalize"/>
<rule ref="category/java/errorprone.xml/FinalizeOverloaded"/>
<rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected"/>
<rule ref="category/java/errorprone.xml/IdempotentOperations"/>
<rule ref="category/java/errorprone.xml/ImportFromSamePackage"/>
<rule ref="category/java/errorprone.xml/InstantiationToGetClass"/>
<rule ref="category/java/errorprone.xml/InvalidSlf4jMessageFormat"/>
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
<rule ref="category/java/errorprone.xml/JUnitStaticSuite"/>
<rule ref="category/java/errorprone.xml/LoggerIsNotStaticFinal"/>
<rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass"/>
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
<rule ref="category/java/errorprone.xml/MissingBreakInSwitch"/>
<rule ref="category/java/errorprone.xml/MissingSerialVersionUID"/>
<rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass"/>
<rule ref="category/java/errorprone.xml/MoreThanOneLogger"/>
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement"/>
<rule ref="category/java/errorprone.xml/NonStaticInitializer"/>
<rule ref="category/java/errorprone.xml/NullAssignment"/>
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
<rule ref="category/java/errorprone.xml/ProperCloneImplementation"/>
<rule ref="category/java/errorprone.xml/ProperLogger"/>
<rule ref="category/java/errorprone.xml/ReturnEmptyArrayRatherThanNull"/>
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
<rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale"/>
<rule ref="category/java/errorprone.xml/SingleMethodSingleton"/>
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/>
<rule ref="category/java/errorprone.xml/StaticEJBFieldShouldBeFinal"/>
<rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar"/>
<rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName"/>
<rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName"/>
<rule ref="category/java/errorprone.xml/SuspiciousOctalEscape"/>
<rule ref="category/java/errorprone.xml/TestClassWithoutTestCases"/>
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/>
<rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion"/>
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/>
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
<rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging"/>
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
<rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions"/>
<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
<properties>
<property name="allowExceptionNameRegex">
<value>^ignore$</value>
</property>
</properties>
</rule>
<rule ref="category/java/errorprone.xml/EmptyFinalizer"/>
<rule ref="category/java/errorprone.xml/EmptyFinallyBlock"/>
<rule ref="category/java/errorprone.xml/EmptyIfStmt"/>
<rule ref="category/java/errorprone.xml/EmptyInitializer"/>
<rule ref="category/java/errorprone.xml/EmptyStatementBlock"/>
<rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop"/>
<rule ref="category/java/errorprone.xml/EmptySwitchStatements"/>
<rule ref="category/java/errorprone.xml/EmptySynchronizedBlock"/>
<rule ref="category/java/errorprone.xml/EmptyTryBlock"/>
<rule ref="category/java/errorprone.xml/EmptyWhileStmt"/>
<!-- MULTITHREADING -->
<rule ref="category/java/multithreading.xml/AvoidSynchronizedAtMethodLevel"/>
<rule ref="category/java/multithreading.xml/AvoidThreadGroup"/>
<rule ref="category/java/multithreading.xml/AvoidUsingVolatile"/>
<rule ref="category/java/multithreading.xml/DontCallThreadRun"/>
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/>
<rule ref="category/java/multithreading.xml/NonThreadSafeSingleton"/>
<rule ref="category/java/multithreading.xml/UseConcurrentHashMap"/>
<rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify"/>
<!-- PERFORMANCE -->
<rule ref="category/java/performance.xml/AddEmptyString"/>
<rule ref="category/java/performance.xml/AppendCharacterWithChar"/>
<rule ref="category/java/performance.xml/AvoidArrayLoops"/>
<rule ref="category/java/performance.xml/AvoidFileStream"/>
<rule ref="category/java/performance.xml/AvoidInstantiatingObjectsInLoops"/>
<rule ref="category/java/performance.xml/AvoidUsingShortType"/>
<rule ref="category/java/performance.xml/BigIntegerInstantiation"/>
<rule ref="category/java/performance.xml/BooleanInstantiation"/>
<rule ref="category/java/performance.xml/ByteInstantiation"/>
<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse"/>
<rule ref="category/java/performance.xml/ConsecutiveLiteralAppends"/>
<rule ref="category/java/performance.xml/InefficientEmptyStringCheck"/>
<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
<rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration"/>
<rule ref="category/java/performance.xml/IntegerInstantiation"/>
<rule ref="category/java/performance.xml/LongInstantiation"/>
<rule ref="category/java/performance.xml/OptimizableToArrayCall"/>
<rule ref="category/java/performance.xml/RedundantFieldInitializer"/>
<rule ref="category/java/performance.xml/SimplifyStartsWith"/>
<rule ref="category/java/performance.xml/ShortInstantiation"/>
<rule ref="category/java/performance.xml/StringInstantiation"/>
<rule ref="category/java/performance.xml/StringToString"/>
<rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement"/>
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
<rule ref="category/java/performance.xml/UseArrayListInsteadOfVector"/>
<rule ref="category/java/performance.xml/UseArraysAsList"/>
<rule ref="category/java/performance.xml/UseIndexOfChar"/>
<rule ref="category/java/performance.xml/UselessStringValueOf"/>
<rule ref="category/java/performance.xml/UseStringBufferForStringAppends"/>
<rule ref="category/java/performance.xml/UseStringBufferLength"/>
<!-- SECURITY -->
<rule ref="category/java/security.xml/HardCodedCryptoKey"/>
<rule ref="category/java/security.xml/InsecureCryptoIv"/>
</ruleset>

View file

@ -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'
}

View file

@ -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}}";
/**

View file

@ -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

View file

@ -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

View file

@ -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.");
}
}

View file

@ -6,15 +6,23 @@ package com.example;
import java.util.Date;
/**
* Provides semantic version information.
*
* @author <a href="https://github.com/ethauvin/semver">Semantic Version Annotation Processor</a>
*/
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.

View file

@ -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("-----------------------------------------------------");
}
}

View file

@ -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("-----------------------------------------------------");
}
}

View file

@ -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

View file

@ -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
}

View file

@ -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}}"
}

View file

@ -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

View file

@ -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

View file

@ -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 ----------------------------------------");

View file

@ -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("-------------------------------------------------------");
}
}

View file

@ -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<String>) {
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("-----------------------------------------------------")

View file

@ -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<String>) {
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US)
println("-------------------------------------------------------")
println(" ${ExampleVersion.PROJECT} ${ExampleVersion.VERSION} ("
+ sdf.format(ExampleVersion.BUILDDATE) + ')')
println("-------------------------------------------------------")
}
}
}

View file

@ -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

View file

@ -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

View file

@ -8,8 +8,8 @@ ext=".java"
java8=true
# e.g: <example directory> <gradle args...>
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

View file

@ -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();

View file

@ -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<? extends TypeElement> 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)

View file

@ -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)");

View file

@ -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