Updated README.
This commit is contained in:
parent
3074f1eb67
commit
5adaec419e
3 changed files with 160 additions and 130 deletions
12
README.md
12
README.md
|
@ -41,7 +41,7 @@ version.prerelease=beta
|
||||||
|
|
||||||
## Template
|
## 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](https://mustache.github.io/) 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 use your own template, simply create a `version.mustache` file in the project's root directory. The processor will automatically look for it.
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ example.meta=
|
||||||
|
|
||||||
### 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
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -200,11 +200,11 @@ compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${proje
|
||||||
|
|
||||||
The `GeneratedVersion.java` file will now be located in `src/generated`.
|
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.
|
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/examples/java) module directory for a sample.
|
||||||
|
|
||||||
### Kobalt
|
### Kobalt
|
||||||
|
|
||||||
To install and run from [Kobalt](http://beust.com/kobalt/), add the following to the `Build.kt` file:
|
To install and run from [Kobalt](https://beust.com/kobalt/), add the following to the `Build.kt` file:
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -213,7 +213,7 @@ dependencies {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
Please look at the [Build.kt](https://github.com/ethauvin/semver/blob/master/examples/java/kobalt/src/Build.kt) file in the [Java example](https://github.com/ethauvin/semver/tree/master/examples/java) module directory for a sample.
|
||||||
|
|
||||||
### Kotlin
|
### Kotlin
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ 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).
|
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 [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/java/kobalt/src/Build.kt)).
|
||||||
|
|
||||||
|
|
||||||
## Auto-Increment
|
## Auto-Increment
|
||||||
|
|
|
@ -167,8 +167,9 @@ task release(dependsOn: ['wrapper', 'clean', 'publishToMavenLocal']) {
|
||||||
|
|
||||||
task pandoc(type: Exec) {
|
task pandoc(type: Exec) {
|
||||||
group = 'Documentation'
|
group = 'Documentation'
|
||||||
def pandoc_args = ['--from', 'markdown_github',
|
def pandoc_args = ['--from', 'gfm',
|
||||||
'--to', 'html5',
|
'--to', 'html5',
|
||||||
|
'--metadata', "pagetitle=$mavenDescription",
|
||||||
'-s',
|
'-s',
|
||||||
'-c', 'github-pandoc.css',
|
'-c', 'github-pandoc.css',
|
||||||
'-o', 'docs/README.html',
|
'-o', 'docs/README.html',
|
||||||
|
|
273
docs/README.html
273
docs/README.html
|
@ -1,49 +1,80 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<meta name="generator" content="pandoc">
|
<meta name="generator" content="pandoc" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||||
<title></title>
|
<title>Semantic Version Annotation Processor</title>
|
||||||
<style type="text/css">code{white-space: pre;}</style>
|
<style>
|
||||||
<style type="text/css">
|
code{white-space: pre-wrap;}
|
||||||
div.sourceCode { overflow-x: auto; }
|
span.smallcaps{font-variant: small-caps;}
|
||||||
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
|
span.underline{text-decoration: underline;}
|
||||||
margin: 0; padding: 0; vertical-align: baseline; border: none; }
|
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||||
table.sourceCode { width: 100%; line-height: 100%; }
|
|
||||||
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
|
|
||||||
td.sourceCode { padding-left: 5px; }
|
|
||||||
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
|
||||||
code > span.dt { color: #902000; } /* DataType */
|
|
||||||
code > span.dv { color: #40a070; } /* DecVal */
|
|
||||||
code > span.bn { color: #40a070; } /* BaseN */
|
|
||||||
code > span.fl { color: #40a070; } /* Float */
|
|
||||||
code > span.ch { color: #4070a0; } /* Char */
|
|
||||||
code > span.st { color: #4070a0; } /* String */
|
|
||||||
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
|
||||||
code > span.ot { color: #007020; } /* Other */
|
|
||||||
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
|
||||||
code > span.fu { color: #06287e; } /* Function */
|
|
||||||
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
|
|
||||||
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
|
||||||
code > span.cn { color: #880000; } /* Constant */
|
|
||||||
code > span.sc { color: #4070a0; } /* SpecialChar */
|
|
||||||
code > span.vs { color: #4070a0; } /* VerbatimString */
|
|
||||||
code > span.ss { color: #bb6688; } /* SpecialString */
|
|
||||||
code > span.im { } /* Import */
|
|
||||||
code > span.va { color: #19177c; } /* Variable */
|
|
||||||
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
|
||||||
code > span.op { color: #666666; } /* Operator */
|
|
||||||
code > span.bu { } /* BuiltIn */
|
|
||||||
code > span.ex { } /* Extension */
|
|
||||||
code > span.pp { color: #bc7a00; } /* Preprocessor */
|
|
||||||
code > span.at { color: #7d9029; } /* Attribute */
|
|
||||||
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
|
||||||
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
|
||||||
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
|
||||||
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
|
||||||
</style>
|
</style>
|
||||||
<link rel="stylesheet" href="github-pandoc.css">
|
<style>
|
||||||
|
a.sourceLine { display: inline-block; line-height: 1.25; }
|
||||||
|
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
|
||||||
|
a.sourceLine:empty { height: 1.2em; }
|
||||||
|
.sourceCode { overflow: visible; }
|
||||||
|
code.sourceCode { white-space: pre; position: relative; }
|
||||||
|
div.sourceCode { margin: 1em 0; }
|
||||||
|
pre.sourceCode { margin: 0; }
|
||||||
|
@media screen {
|
||||||
|
div.sourceCode { overflow: auto; }
|
||||||
|
}
|
||||||
|
@media print {
|
||||||
|
code.sourceCode { white-space: pre-wrap; }
|
||||||
|
a.sourceLine { text-indent: -1em; padding-left: 1em; }
|
||||||
|
}
|
||||||
|
pre.numberSource a.sourceLine
|
||||||
|
{ position: relative; left: -4em; }
|
||||||
|
pre.numberSource a.sourceLine::before
|
||||||
|
{ content: attr(title);
|
||||||
|
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
||||||
|
border: none; pointer-events: all; display: inline-block;
|
||||||
|
-webkit-touch-callout: none; -webkit-user-select: none;
|
||||||
|
-khtml-user-select: none; -moz-user-select: none;
|
||||||
|
-ms-user-select: none; user-select: none;
|
||||||
|
padding: 0 4px; width: 4em;
|
||||||
|
color: #aaaaaa;
|
||||||
|
}
|
||||||
|
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
||||||
|
div.sourceCode
|
||||||
|
{ }
|
||||||
|
@media screen {
|
||||||
|
a.sourceLine::before { text-decoration: underline; }
|
||||||
|
}
|
||||||
|
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
||||||
|
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
||||||
|
code span.at { color: #7d9029; } /* Attribute */
|
||||||
|
code span.bn { color: #40a070; } /* BaseN */
|
||||||
|
code span.bu { } /* BuiltIn */
|
||||||
|
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
||||||
|
code span.ch { color: #4070a0; } /* Char */
|
||||||
|
code span.cn { color: #880000; } /* Constant */
|
||||||
|
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
||||||
|
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
||||||
|
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
||||||
|
code span.dt { color: #902000; } /* DataType */
|
||||||
|
code span.dv { color: #40a070; } /* DecVal */
|
||||||
|
code span.er { color: #ff0000; font-weight: bold; } /* Error */
|
||||||
|
code span.ex { } /* Extension */
|
||||||
|
code span.fl { color: #40a070; } /* Float */
|
||||||
|
code span.fu { color: #06287e; } /* Function */
|
||||||
|
code span.im { } /* Import */
|
||||||
|
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
||||||
|
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
||||||
|
code span.op { color: #666666; } /* Operator */
|
||||||
|
code span.ot { color: #007020; } /* Other */
|
||||||
|
code span.pp { color: #bc7a00; } /* Preprocessor */
|
||||||
|
code span.sc { color: #4070a0; } /* SpecialChar */
|
||||||
|
code span.ss { color: #bb6688; } /* SpecialString */
|
||||||
|
code span.st { color: #4070a0; } /* String */
|
||||||
|
code span.va { color: #19177c; } /* Variable */
|
||||||
|
code span.vs { color: #4070a0; } /* VerbatimString */
|
||||||
|
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
||||||
|
</style>
|
||||||
|
<link rel="stylesheet" href="github-pandoc.css" />
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -58,32 +89,32 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
|
||||||
<ul>
|
<ul>
|
||||||
<li>Using annotation elements:</li>
|
<li>Using annotation elements:</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="sourceCode"><pre class="sourceCode java"><code class="sourceCode java"><span class="kw">import net.thauvin.erik.semver.Version;</span>
|
<div class="sourceCode" id="cb1"><pre class="sourceCode java"><code class="sourceCode java"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span><span class="im"> net.thauvin.erik.semver.Version;</span></a>
|
||||||
|
<a class="sourceLine" id="cb1-2" title="2"></a>
|
||||||
<span class="fu">@Version</span>(major = <span class="dv">1</span>, minor = <span class="dv">0</span>, patch = <span class="dv">0</span>, preRelease = <span class="st">"beta"</span>)
|
<a class="sourceLine" id="cb1-3" title="3"><span class="at">@Version</span>(major = <span class="dv">1</span>, minor = <span class="dv">0</span>, patch = <span class="dv">0</span>, preRelease = <span class="st">"beta"</span>)</a>
|
||||||
<span class="kw">public</span> <span class="kw">class</span> A {
|
<a class="sourceLine" id="cb1-4" title="4"><span class="kw">public</span> <span class="kw">class</span> A {</a>
|
||||||
<span class="co">// ...</span></code></pre></div>
|
<a class="sourceLine" id="cb1-5" title="5"><span class="co">// ...</span></a></code></pre></div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Or using a <a href="https://docs.oracle.com/javase/tutorial/essential/environment/properties.html">properties</a> file:</li>
|
<li>Or using a <a href="https://docs.oracle.com/javase/tutorial/essential/environment/properties.html">properties</a> file:</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="sourceCode"><pre class="sourceCode java"><code class="sourceCode java"><span class="kw">import net.thauvin.erik.semver.Version;</span>
|
<div class="sourceCode" id="cb2"><pre class="sourceCode java"><code class="sourceCode java"><a class="sourceLine" id="cb2-1" title="1"><span class="kw">import</span><span class="im"> net.thauvin.erik.semver.Version;</span></a>
|
||||||
|
<a class="sourceLine" id="cb2-2" title="2"></a>
|
||||||
<span class="fu">@Version</span>(properties = <span class="st">"version.properties"</span>)
|
<a class="sourceLine" id="cb2-3" title="3"><span class="at">@Version</span>(properties = <span class="st">"version.properties"</span>)</a>
|
||||||
<span class="kw">public</span> <span class="kw">class</span> A {
|
<a class="sourceLine" id="cb2-4" title="4"><span class="kw">public</span> <span class="kw">class</span> A {</a>
|
||||||
<span class="co">// ...</span></code></pre></div>
|
<a class="sourceLine" id="cb2-5" title="5"><span class="co">// ...</span></a></code></pre></div>
|
||||||
<div class="sourceCode"><pre class="sourceCode ini"><code class="sourceCode ini"><span class="co"># version.properties</span>
|
<div class="sourceCode" id="cb3"><pre class="sourceCode ini"><code class="sourceCode ini"><a class="sourceLine" id="cb3-1" title="1"><span class="co"># version.properties</span></a>
|
||||||
<span class="dt">version.major</span><span class="ot">=</span><span class="dv">1</span>
|
<a class="sourceLine" id="cb3-2" title="2"><span class="dt">version.major</span><span class="ot">=</span><span class="dv">1</span></a>
|
||||||
<span class="dt">version.minor</span><span class="ot">=</span><span class="dv">0</span>
|
<a class="sourceLine" id="cb3-3" title="3"><span class="dt">version.minor</span><span class="ot">=</span><span class="dv">0</span></a>
|
||||||
<span class="dt">version.patch</span><span class="ot">=</span><span class="dv">0</span>
|
<a class="sourceLine" id="cb3-4" title="4"><span class="dt">version.patch</span><span class="ot">=</span><span class="dv">0</span></a>
|
||||||
<span class="dt">version.prerelease</span><span class="ot">=</span><span class="st">beta</span></code></pre></div>
|
<a class="sourceLine" id="cb3-5" title="5"><span class="dt">version.prerelease</span><span class="ot">=</span><span class="st">beta</span></a></code></pre></div>
|
||||||
<p><a href="https://github.com/ethauvin/semver/tree/master/examples">View Example</a></p>
|
<p><a href="https://github.com/ethauvin/semver/tree/master/examples">View Example</a></p>
|
||||||
<h2 id="template">Template</h2>
|
<h2 id="template">Template</h2>
|
||||||
<p>Upon running the annotation processor, a source file <a href="https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/net/thauvin/erik/semver/examples/java/GeneratedVersion.java"><code>GeneratedVersion.java</code></a> is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable <a href="https://mustache.github.io/">Mustache</a> template.</p>
|
<p>Upon running the annotation processor, a source file <a href="https://github.com/ethauvin/semver/blob/master/examples/java/src/generated/java/com/example/GeneratedVersion.java"><code>GeneratedVersion.java</code></a> is automatically generated with static methods to access the semantic version data. The source is based on a fully customizable <a href="https://mustache.github.io/">Mustache</a> template.</p>
|
||||||
<p>To use your own template, simply create a <code>version.mustache</code> file in the project's root directory. The processor will automatically look for it.</p>
|
<p>To use your own template, simply create a <code>version.mustache</code> file in the project's root directory. The processor will automatically look for it.</p>
|
||||||
<p>To specify your own template name, use:</p>
|
<p>To specify your own template name, use:</p>
|
||||||
<div class="sourceCode"><pre class="sourceCode java"><code class="sourceCode java"><span class="fu">@Version</span>(template = <span class="st">"version.mustache"</span>)
|
<div class="sourceCode" id="cb4"><pre class="sourceCode java"><code class="sourceCode java"><a class="sourceLine" id="cb4-1" title="1"><span class="at">@Version</span>(template = <span class="st">"version.mustache"</span>)</a>
|
||||||
<span class="kw">public</span> <span class="kw">class</span> A {
|
<a class="sourceLine" id="cb4-2" title="2"><span class="kw">public</span> <span class="kw">class</span> A {</a>
|
||||||
<span class="co">// ...</span></code></pre></div>
|
<a class="sourceLine" id="cb4-3" title="3"><span class="co">// ...</span></a></code></pre></div>
|
||||||
<h3 id="default-template">Default Template</h3>
|
<h3 id="default-template">Default Template</h3>
|
||||||
<p>The <a href="https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache">default template</a> implements the following static fields:</p>
|
<p>The <a href="https://github.com/ethauvin/semver/blob/master/src/main/resources/semver.mustache">default template</a> implements the following static fields:</p>
|
||||||
<table>
|
<table>
|
||||||
|
@ -138,12 +169,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>And the following methods/functions:</p>
|
<p>And the following methods/functions:</p>
|
||||||
<table style="width:100%;">
|
<table>
|
||||||
<colgroup>
|
|
||||||
<col style="width: 27%" />
|
|
||||||
<col style="width: 62%" />
|
|
||||||
<col style="width: 10%" />
|
|
||||||
</colgroup>
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="header">
|
<tr class="header">
|
||||||
<th style="text-align: left;">Method</th>
|
<th style="text-align: left;">Method</th>
|
||||||
|
@ -166,20 +192,20 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
|
||||||
</table>
|
</table>
|
||||||
<h3 id="custom-template">Custom Template</h3>
|
<h3 id="custom-template">Custom Template</h3>
|
||||||
<p>A very simple custom template might look something like:</p>
|
<p>A very simple custom template might look something like:</p>
|
||||||
<div class="sourceCode"><pre class="sourceCode java"><code class="sourceCode java"><span class="co">/* version.mustache */</span>
|
<div class="sourceCode" id="cb5"><pre class="sourceCode java"><code class="sourceCode java"><a class="sourceLine" id="cb5-1" title="1"><span class="co">/* version.mustache */</span></a>
|
||||||
<span class="kw">package</span> {{packageName}}
|
<a class="sourceLine" id="cb5-2" title="2"><span class="kw">package</span> {{packageName}}</a>
|
||||||
|
<a class="sourceLine" id="cb5-3" title="3"></a>
|
||||||
<span class="kw">import java.util.Date;</span>
|
<a class="sourceLine" id="cb5-4" title="4"><span class="kw">import</span><span class="im"> java.util.Date;</span></a>
|
||||||
|
<a class="sourceLine" id="cb5-5" title="5"></a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="kw">class</span> {{className}} {
|
<a class="sourceLine" id="cb5-6" title="6"><span class="kw">public</span> <span class="dt">final</span> <span class="kw">class</span> {{className}} {</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> String PROJECT = <span class="st">"{{project}}"</span>;
|
<a class="sourceLine" id="cb5-7" title="7"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="bu">String</span> PROJECT = <span class="st">"{{project}}"</span>;</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> Date DATE = <span class="kw">new</span> Date({{epoch}}L);
|
<a class="sourceLine" id="cb5-8" title="8"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="bu">Date</span> DATE = <span class="kw">new</span> <span class="bu">Date</span>({{epoch}}L);</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="dt">int</span> MAJOR = {{major}};
|
<a class="sourceLine" id="cb5-9" title="9"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="dt">int</span> MAJOR = {{major}};</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="dt">int</span> MINOR = {{minor}};
|
<a class="sourceLine" id="cb5-10" title="10"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="dt">int</span> MINOR = {{minor}};</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="dt">int</span> PATCH = {{patch}};
|
<a class="sourceLine" id="cb5-11" title="11"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="dt">int</span> PATCH = {{patch}};</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> String PRERELEASE = <span class="st">"{{preRelease}}"</span>;
|
<a class="sourceLine" id="cb5-12" title="12"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="bu">String</span> PRERELEASE = <span class="st">"{{preRelease}}"</span>;</a>
|
||||||
<span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> String BUILDMETA = <span class="st">"{{buildMeta}}"</span>;
|
<a class="sourceLine" id="cb5-13" title="13"> <span class="kw">public</span> <span class="dt">final</span> <span class="dt">static</span> <span class="bu">String</span> BUILDMETA = <span class="st">"{{buildMeta}}"</span>;</a>
|
||||||
}</code></pre></div>
|
<a class="sourceLine" id="cb5-14" title="14">}</a></code></pre></div>
|
||||||
<p>The mustache variables automatically filled in by the processor are:</p>
|
<p>The mustache variables automatically filled in by the processor are:</p>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -238,7 +264,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>Please also look at this <a href="https://github.com/ethauvin/mobibot/blob/master/version.mustache">example</a> using <a href="https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html"><code>java.time</code></a></p>
|
<p>Please also look at this <a href="https://github.com/ethauvin/mobibot/blob/master/version.mustache">example</a> using <a href="https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html"><code>java.time</code></a></p>
|
||||||
<h2 id="elements-properties">Elements & Properties</h2>
|
<h2 id="elements--properties">Elements & Properties</h2>
|
||||||
<p>The following annotation elements and properties are available:</p>
|
<p>The following annotation elements and properties are available:</p>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -325,68 +351,71 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>In order to easily incorporate with existing projects, the property keys may be assigned custom values:</p>
|
<p>In order to easily incorporate with existing projects, the property keys may be assigned custom values:</p>
|
||||||
<div class="sourceCode"><pre class="sourceCode java"><code class="sourceCode java"><span class="fu">@Version</span>(
|
<div class="sourceCode" id="cb6"><pre class="sourceCode java"><code class="sourceCode java"><a class="sourceLine" id="cb6-1" title="1"><span class="at">@Version</span>(</a>
|
||||||
properties = <span class="st">"example.properties"</span>,
|
<a class="sourceLine" id="cb6-2" title="2"> properties = <span class="st">"example.properties"</span>,</a>
|
||||||
keysPrefix = <span class="st">"example."</span>
|
<a class="sourceLine" id="cb6-3" title="3"> keysPrefix = <span class="st">"example."</span></a>
|
||||||
majorKey = <span class="st">"maj"</span>,
|
<a class="sourceLine" id="cb6-4" title="4"> majorKey = <span class="st">"maj"</span>,</a>
|
||||||
minorKey = <span class="st">"min"</span>,
|
<a class="sourceLine" id="cb6-5" title="5"> minorKey = <span class="st">"min"</span>,</a>
|
||||||
patchKey = <span class="st">"build"</span>,
|
<a class="sourceLine" id="cb6-6" title="6"> patchKey = <span class="st">"build"</span>,</a>
|
||||||
preReleaseKey = <span class="st">"rel"</span>,
|
<a class="sourceLine" id="cb6-7" title="7"> preReleaseKey = <span class="st">"rel"</span>,</a>
|
||||||
buildMetaKey = <span class="st">"meta"</span>,
|
<a class="sourceLine" id="cb6-8" title="8"> buildMetaKey = <span class="st">"meta"</span>,</a>
|
||||||
projectKey = <span class="st">"project"</span>
|
<a class="sourceLine" id="cb6-9" title="9"> projectKey = <span class="st">"project"</span></a>
|
||||||
)
|
<a class="sourceLine" id="cb6-10" title="10">)</a>
|
||||||
<span class="kw">public</span> <span class="kw">class</span> Example {
|
<a class="sourceLine" id="cb6-11" title="11"><span class="kw">public</span> <span class="kw">class</span> Example {</a>
|
||||||
<span class="co">// ...</span></code></pre></div>
|
<a class="sourceLine" id="cb6-12" title="12"><span class="co">// ...</span></a></code></pre></div>
|
||||||
<div class="sourceCode"><pre class="sourceCode ini"><code class="sourceCode ini"><span class="co"># example.properties</span>
|
<div class="sourceCode" id="cb7"><pre class="sourceCode ini"><code class="sourceCode ini"><a class="sourceLine" id="cb7-1" title="1"><span class="co"># example.properties</span></a>
|
||||||
<span class="dt">example.project</span><span class="ot">=</span><span class="st">Example</span>
|
<a class="sourceLine" id="cb7-2" title="2"><span class="dt">example.project</span><span class="ot">=</span><span class="st">Example</span></a>
|
||||||
<span class="dt">example.maj</span><span class="ot">=</span><span class="dv">1</span>
|
<a class="sourceLine" id="cb7-3" title="3"><span class="dt">example.maj</span><span class="ot">=</span><span class="dv">1</span></a>
|
||||||
<span class="dt">example.min</span><span class="ot">=</span><span class="dv">0</span>
|
<a class="sourceLine" id="cb7-4" title="4"><span class="dt">example.min</span><span class="ot">=</span><span class="dv">0</span></a>
|
||||||
<span class="dt">example.build</span><span class="ot">=</span><span class="dv">0</span>
|
<a class="sourceLine" id="cb7-5" title="5"><span class="dt">example.build</span><span class="ot">=</span><span class="dv">0</span></a>
|
||||||
<span class="dt">example.rel</span><span class="ot">=</span><span class="st">beta</span>
|
<a class="sourceLine" id="cb7-6" title="6"><span class="dt">example.rel</span><span class="ot">=</span><span class="st">beta</span></a>
|
||||||
<span class="dt">example.meta</span><span class="ot">=</span>
|
<a class="sourceLine" id="cb7-7" title="7"><span class="dt">example.meta</span><span class="ot">=</span></a>
|
||||||
<span class="co"># ...</span></code></pre></div>
|
<a class="sourceLine" id="cb7-8" title="8"><span class="co"># ...</span></a></code></pre></div>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>⚠️ <code>keysPrefix</code> is a new element staring in <code>1.1.0</code> and may break older versions when using custom property keys.<br />
|
<p><span class="emoji" data-emoji="warning">⚠️</span> <code>keysPrefix</code> is a new element staring in <code>1.1.0</code> and may break older versions when using custom property keys.<br />
|
||||||
⚡ A quick fix is to include <code>keysPrefix=""</code> in the annotation to remove the default <code>version.</code> prefix.</p>
|
<span class="emoji" data-emoji="zap">⚡</span> A quick fix is to include <code>keysPrefix=""</code> in the annotation to remove the default <code>version.</code> prefix.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h2 id="usage-with-maven-grail-kobalt-and-kotlin">Usage with Maven, Grail, Kobalt and Kotlin</h2>
|
<h2 id="usage-with-maven-grail-kobalt-and-kotlin">Usage with Maven, Grail, Kobalt and Kotlin</h2>
|
||||||
<h3 id="maven">Maven</h3>
|
<h3 id="maven">Maven</h3>
|
||||||
<p>To install and run from <a href="http://maven.apache.org/">Maven</a>, configure an artifact as follows:</p>
|
<p>To install and run from <a href="http://maven.apache.org/">Maven</a>, configure an artifact as follows:</p>
|
||||||
<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"><span class="kw"><dependency></span>
|
<div class="sourceCode" id="cb8"><pre class="sourceCode xml"><code class="sourceCode xml"><a class="sourceLine" id="cb8-1" title="1"><span class="kw"><dependency></span></a>
|
||||||
<span class="kw"><groupId></span>net.thauvin.erik<span class="kw"></groupId></span>
|
<a class="sourceLine" id="cb8-2" title="2"> <span class="kw"><groupId></span>net.thauvin.erik<span class="kw"></groupId></span></a>
|
||||||
<span class="kw"><artifactId></span>semver<span class="kw"></artifactId></span>
|
<a class="sourceLine" id="cb8-3" title="3"> <span class="kw"><artifactId></span>semver<span class="kw"></artifactId></span></a>
|
||||||
<span class="kw"><version></span>1.1.1<span class="kw"></version></span>
|
<a class="sourceLine" id="cb8-4" title="4"> <span class="kw"><version></span>1.1.1<span class="kw"></version></span></a>
|
||||||
<span class="kw"></dependency></span></code></pre></div>
|
<a class="sourceLine" id="cb8-5" title="5"><span class="kw"></dependency></span></a></code></pre></div>
|
||||||
<h3 id="gradle">Gradle</h3>
|
<h3 id="gradle">Gradle</h3>
|
||||||
<h4 id="class-generation">Class Generation</h4>
|
<h4 id="class-generation">Class Generation</h4>
|
||||||
<p>To install and run from <a href="https://gradle.org/">Gradle</a>, add the following to the <code>build.gradle</code> file:</p>
|
<p>To install and run from <a href="https://gradle.org/">Gradle</a>, add the following to the <code>build.gradle</code> file:</p>
|
||||||
<pre class="gradle"><code>dependencies {
|
<pre class="gradle"><code>dependencies {
|
||||||
annotationProcessor 'net.thauvin.erik:semver:1.1.1'
|
annotationProcessor 'net.thauvin.erik:semver:1.1.1'
|
||||||
compileOnly 'net.thauvin.erik:semver:1.1.1'
|
compileOnly 'net.thauvin.erik:semver:1.1.1'
|
||||||
}</code></pre>
|
}
|
||||||
|
</code></pre>
|
||||||
<p>The <code>GeneratedVersion</code> class will be automatically created in the <code>build/generated</code> directory upon compiling.</p>
|
<p>The <code>GeneratedVersion</code> class will be automatically created in the <code>build/generated</code> directory upon compiling.</p>
|
||||||
<h4 id="class-source-generation">Class & Source Generation</h4>
|
<h4 id="class--source-generation">Class & Source Generation</h4>
|
||||||
<p>In order to also incorporate the generated source code into the <code>source tree</code>, add the following to the very top of the <code>build.gradle</code> file:</p>
|
<p>In order to also incorporate the generated source code into the <code>source tree</code>, add the following to the very top of the <code>build.gradle</code> file:</p>
|
||||||
<pre class="gradle"><code>compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")</code></pre>
|
<pre class="gradle"><code>compileJava.options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
|
||||||
|
</code></pre>
|
||||||
<p>The <code>GeneratedVersion.java</code> file will now be located in <code>src/generated</code>.</p>
|
<p>The <code>GeneratedVersion.java</code> file will now be located in <code>src/generated</code>.</p>
|
||||||
<p>Please look at the <a href="https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle">build.gradle</a> file in the <a href="https://github.com/ethauvin/semver/tree/master/example/java">Java example</a> module directory for a sample.</p>
|
<p>Please look at the <a href="https://github.com/ethauvin/semver/blob/master/examples/java/build.gradle">build.gradle</a> file in the <a href="https://github.com/ethauvin/semver/tree/master/examples/java">Java example</a> module directory for a sample.</p>
|
||||||
<h3 id="kobalt">Kobalt</h3>
|
<h3 id="kobalt">Kobalt</h3>
|
||||||
<p>To install and run from <a href="http://beust.com/kobalt/">Kobalt</a>, add the following to the <code>Build.kt</code> file:</p>
|
<p>To install and run from <a href="http://beust.com/kobalt/">Kobalt</a>, add the following to the <code>Build.kt</code> file:</p>
|
||||||
<pre class="gradle"><code>dependencies {
|
<pre class="gradle"><code>dependencies {
|
||||||
apt("net.thauvin.erik:semver:1.1.1")
|
apt("net.thauvin.erik:semver:1.1.1")
|
||||||
compileOnly("net.thauvin.erik:semver:1.1.1")
|
compileOnly("net.thauvin.erik:semver:1.1.1")
|
||||||
}</code></pre>
|
}
|
||||||
<p>Please look at the <a href="https://github.com/ethauvin/semver/blob/master/examples/kotlin/kobalt/src/Build.kt">Build.kt</a> file in the <a href="https://github.com/ethauvin/semver/tree/master/examples/kotlin">Kotlin example</a> module directory for a sample.</p>
|
</code></pre>
|
||||||
|
<p>Please look at the <a href="https://github.com/ethauvin/semver/blob/master/examples/java/kobalt/src/Build.kt">Build.kt</a> file in the <a href="https://github.com/ethauvin/semver/tree/master/examples/java">Java example</a> module directory for a sample.</p>
|
||||||
<h3 id="kotlin">Kotlin</h3>
|
<h3 id="kotlin">Kotlin</h3>
|
||||||
<p>The annotation processor also supports <a href="https://kotlinlang.org/">Kotlin</a>.</p>
|
<p>The annotation processor also supports <a href="https://kotlinlang.org/">Kotlin</a>.</p>
|
||||||
<p>To generate a Kotlin version file, simply specify the <code>type</code> as follows:</p>
|
<p>To generate a Kotlin version file, simply specify the <code>type</code> as follows:</p>
|
||||||
<div class="sourceCode"><pre class="sourceCode kotlin"><code class="sourceCode kotlin"><span class="kw">import</span> net.<span class="fu">thauvin</span>.<span class="fu">erik</span>.<span class="fu">semver</span>.<span class="fu">Version</span>
|
<div class="sourceCode" id="cb12"><pre class="sourceCode kotlin"><code class="sourceCode kotlin"><a class="sourceLine" id="cb12-1" title="1"><span class="kw">import</span> <span class="im">net.thauvin.erik.semver.Version</span></a>
|
||||||
|
<a class="sourceLine" id="cb12-2" title="2"></a>
|
||||||
@<span class="fu">Version</span>(properties = <span class="st">"version.properties"</span>, type=<span class="st">"kt"</span>)
|
<a class="sourceLine" id="cb12-3" title="3"><span class="at">@Version</span>(properties = <span class="st">"version.properties"</span>, type=<span class="st">"kt"</span>)</a>
|
||||||
<span class="kw">open</span> <span class="kw">class</span> Main {
|
<a class="sourceLine" id="cb12-4" title="4"><span class="kw">open</span> <span class="kw">class</span> Main {</a>
|
||||||
<span class="co">// ...</span></code></pre></div>
|
<a class="sourceLine" id="cb12-5" title="5"><span class="co">// ...</span></a></code></pre></div>
|
||||||
<p>The <a href="https://github.com/ethauvin/semver/blob/master/src/main/resources/semver-kt.mustache">Kotlin default template</a> implements the same static fields and functions as the <a href="#default-template">Java template</a>.</p>
|
<p>The <a href="https://github.com/ethauvin/semver/blob/master/src/main/resources/semver-kt.mustache">Kotlin default template</a> implements the same static fields and functions as the <a href="#default-template">Java template</a>.</p>
|
||||||
<p>Please look at the <a href="https://github.com/ethauvin/semver/tree/master/examples/kotlin">Kotlin example</a> project for samples on using Gradle (<a href="https://github.com/ethauvin/semver/blob/master/examples/kotlin/build.gradle.kts">build.gradle.kts</a>) and Kobalt (<a href="https://github.com/ethauvin/semver/blob/master/examples/kotlin/kobalt/src/Build.kt">Build.kt</a>).</p>
|
<p>Please look at the <a href="https://github.com/ethauvin/semver/tree/master/examples/kotlin">Kotlin example</a> project for samples on using Gradle (<a href="https://github.com/ethauvin/semver/blob/master/examples/kotlin/build.gradle.kts">build.gradle.kts</a>) and Kobalt (<a href="https://github.com/ethauvin/semver/blob/master/examples/java/kobalt/src/Build.kt">Build.kt</a>).</p>
|
||||||
<h2 id="auto-increment">Auto-Increment</h2>
|
<h2 id="auto-increment">Auto-Increment</h2>
|
||||||
<p>Incrementing the version is best left to your favorite build system. For a solution using Gradle, please have a look at the <a href="https://github.com/ethauvin/semver-gradle"><strong>Semver Version Plugin for Gradle</strong></a>.</p>
|
<p>Incrementing the version is best left to your favorite build system. For a solution using Gradle, please have a look at the <a href="https://github.com/ethauvin/semver-gradle"><strong>Semver Version Plugin for Gradle</strong></a>.</p>
|
||||||
<p>There are also full <a href="https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor">examples</a> in both <a href="https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/java">Java</a> and <a href="https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/kotlin">Kotlin</a> showing how to use both the plugin and annotation processor concurrently.</p>
|
<p>There are also full <a href="https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor">examples</a> in both <a href="https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/java">Java</a> and <a href="https://github.com/ethauvin/semver-gradle/tree/master/examples/annotation-processor/kotlin">Kotlin</a> showing how to use both the plugin and annotation processor concurrently.</p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue