Skip to content

Commit c675ddb

Browse files
committed
update readme to reflect current version
1 parent 3b1b7fc commit c675ddb

File tree

1 file changed

+70
-97
lines changed

1 file changed

+70
-97
lines changed

README.md

+70-97
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,28 @@ In order to find the latest version published of [gradle-jgitver-plugin](https:/
1010

1111
see the project [build.gradle.kts](build.gradle.kts) to see how the project is using itself to manage its own versions.
1212

13-
Find latest version of the plugin: [click here](https://plugins.gradle.org/plugin/fr.brouillard.oss.gradle.jgitver)
14-
15-
### Usage for modern gradle versions _(>= 2.1)_
13+
### Add the plugin
1614

1715
```
1816
plugins {
1917
id "fr.brouillard.oss.gradle.jgitver" version "0.9.1"
2018
}
2119
```
2220

23-
### Usage for all gradle versions _(including < 2.1)_
24-
```
25-
buildscript {
26-
repositories {
27-
maven {
28-
url "https://plugins.gradle.org/m2/"
29-
}
30-
}
31-
dependencies {
32-
classpath "gradle.plugin.fr.brouillard.oss.gradle:gradle-jgitver-plugin:0.9.1"
33-
}
34-
}
21+
### Use it
22+
23+
Besides calculating a version automatically when running any gradle task, like `gradle build`, the plugin registers a
24+
task `version` which you can call to print out the calculated version of your project:
3525

36-
apply plugin: 'fr.brouillard.oss.gradle.jgitver'
3726
```
27+
$ ./gradlew version
3828
29+
> Task :version
30+
Version: 0.10.1-rc03-2-dirty
31+
32+
BUILD SUCCESSFUL in 1s
33+
1 actionable task: 1 executed
34+
```
3935

4036
## Documentation
4137

@@ -47,49 +43,11 @@ Finally have a look at the [configuration](#configuration) paragraph to have ful
4743

4844
![Gradle Example](src/doc/images/gradle-example.gif?raw=true "Gradle Example")
4945

50-
### Tasks
51-
52-
#### Version
53-
54-
Since 0.2.0 the plugin automatically registers a task `version` which you can call to print out the calculated version of your project:
55-
56-
```
57-
$ ./gradlew version
58-
:version
59-
Version: 0.0.2-4
60-
61-
BUILD SUCCESSFUL
62-
63-
Total time: 5.769 secs
64-
```
65-
66-
Before 0.2.0, in order to know the current version of your project, just print out the version in a task looking like the following:
67-
68-
```
69-
task version {
70-
doLast {
71-
println 'Version: ' + version
72-
}
73-
}
74-
```
75-
76-
then just call the task
77-
78-
```
79-
$ ./gradlew version
80-
:version
81-
Version: 0.0.2-4
82-
83-
BUILD SUCCESSFUL
84-
85-
Total time: 5.769 secs
86-
```
87-
8846
### Configuration
8947

90-
#### version >= 0.2.0
48+
#### build.gradle
9149

92-
Starting from `0.2.0` it is possible to configure the plugin inside the `build.gradle`.
50+
Optionally, configure the plugin inside the `build.gradle`.
9351

9452
~~~~
9553
jgitver {
@@ -104,10 +62,10 @@ jgitver {
10462
useGitCommitTimestamp true/false
10563
useGitCommitID true/false
10664
gitCommitIDLength integer
107-
maxDepth integer ( >= 0.7.0)
65+
maxDepth integer
10866
nonQualifierBranches string (comma separated list of branches)
109-
versionPattern string (only for PATTERN strategy, >= 0.6.0)
110-
tagVersionPattern string (only for PATTERN strategy >= 0.6.0)
67+
versionPattern string (only for PATTERN strategy)
68+
tagVersionPattern string (only for PATTERN strategy)
11169
policy { repeatable closure
11270
pattern string (regexp with capturing group)
11371
transformations array (array of string)
@@ -117,6 +75,37 @@ jgitver {
11775
11876
~~~~
11977

78+
#### build.gradle.kts
79+
80+
Optionally, configure the plugin inside the `build.gradle.kts`.
81+
82+
~~~~
83+
jgitver {
84+
strategy = fr.brouillard.oss.jgitver.Strategies.PATTERN | MAVEN | CONFIGURABLE
85+
mavenLike = true/false (deprecated, use strategy instead)
86+
policy = fr.brouillard.oss.jgitver.LookupPolicy.MAX | LATEST | NEAREST
87+
autoIncrementPatch = true/false
88+
useDistance = true/false
89+
useDirty = true/false
90+
useSnapshot = true/false
91+
failIfDirty = true/false
92+
useGitCommitTimestamp = true/false
93+
useGitCommitID = true/false
94+
gitCommitIDLength = integer
95+
maxDepth = integer
96+
nonQualifierBranches = "string" (comma separated list of branches)
97+
versionPattern = "string" (only for PATTERN strategy)
98+
tagVersionPattern = "string" (only for PATTERN strategy)
99+
policy { repeatable closure
100+
pattern = "string" (regexp with capturing group)
101+
transformations array (array of string)
102+
}
103+
distanceCalculatorKind = fr.brouillard.oss.jgitver.impl.DistanceCalculator.CalculatorKind.FIRST_PARENT | LOG | DEPTH
104+
}
105+
106+
~~~~
107+
108+
#### Defaults
120109
If you do not provide such a configuration (or fill only partial configuration) the following defaults will be used
121110
- _strategy_: `CONFIGURABLE`
122111
- _mavenLike_: `false`
@@ -138,20 +127,7 @@ If you do not provide such a configuration (or fill only partial configuration)
138127
- the pattern must be a regular Java [Pattern](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html) string with one matching group
139128
- distanceCalculatorKind: `FIRST_PARENT`
140129

141-
#### version < 0.2.0
142-
143-
Before `0.2.0` no configuration was possible.
144-
The plugin used [jgitver](https://github.com/McFoggy/jgitver) with the following settings:
145-
146-
- _mavenLike_: `false`
147-
- _autoIncrementPatch_: `true`
148-
- _nonQualifierBranches_: `'master'`
149-
- _useDistance_: `true`
150-
- _useGitCommitId_: `false`
151-
152-
#### Configuration examples
153-
154-
##### provide specific branch policies
130+
#### Example to provide specific branch policies
155131

156132
Given the following configuration
157133
```
@@ -176,9 +152,9 @@ $ gradlew version
176152
Version: 1.0.1-3-LOGINPAGE
177153
```
178154

179-
### Metadatas
155+
#### Add metadata
180156

181-
Since `0.3.0`, jgitver [Metadatas](https://github.com/jgitver/jgitver/blob/master/src/main/java/fr/brouillard/oss/jgitver/metadata/Metadatas.java#L25) are exposed via gradle extension properties using the Metadata name in lower case.
157+
Jgitver [Metadatas](https://github.com/jgitver/jgitver/blob/master/src/main/java/fr/brouillard/oss/jgitver/metadata/Metadatas.java#L25) are exposed via gradle extension properties using the Metadata name in lower case.
182158

183159
For example, one could enhance it's jar Manifest with the git commit id using:
184160

@@ -195,10 +171,10 @@ jar {
195171
}
196172
```
197173

198-
### Building on detached HEAD
174+
#### Building on detached HEAD
199175

200176
When working on a __detached HEAD__, as often on CI environments behind a SCM webhook, no branch information exists anymore from git.
201-
Since `0.4.1` it now possible to provide externally the branch information via a system property or an environment variable.
177+
It is possible to provide externally the branch information via a system property or an environment variable.
202178

203179
- all operating systems/shells: `gradlew version -Djgitver.branch=mybranch`
204180
- bash only (_zsh?_) one line: `JGITVER_BRANCH=mybranch && gradlew version`
@@ -212,32 +188,26 @@ Since `0.4.1` it now possible to provide externally the branch information via a
212188
## Local build & sample test project
213189

214190
- `$ ./gradlew install version` will install the current version inside the local maven repository and will print the published version
215-
- minimal test project `build.gradle` file
191+
- minimal test project `build.gradle.kts` file
216192
````gradle
217-
buildscript {
218-
repositories {
193+
plugins {
194+
id("fr.brouillard.oss.gradle.jgitver") version "0.9.1"
195+
}
196+
repositories {
219197
mavenLocal()
220-
}
221-
dependencies {
222-
classpath "fr.brouillard.oss.gradle:gradle-jgitver-plugin:0.3.2"
223-
}
224198
}
225-
apply plugin: 'fr.brouillard.oss.gradle.jgitver'
226199
````
227-
- test project `build.gradle` file with Maven like versioning
200+
- test project `build.gradle.kts` file with Maven like versioning
228201
````gradle
229-
buildscript {
230-
repositories {
202+
plugins {
203+
id("fr.brouillard.oss.gradle.jgitver") version "0.9.1"
204+
}
205+
repositories {
231206
mavenLocal()
232-
}
233-
dependencies {
234-
classpath "fr.brouillard.oss.gradle:gradle-jgitver-plugin:0.3.2"
235-
}
236207
}
237-
apply plugin: 'fr.brouillard.oss.gradle.jgitver'
238208
239209
jgitver {
240-
mavenLike true
210+
strategy = fr.brouillard.oss.jgitver.Strategies.MAVEN
241211
}
242212
````
243213

@@ -246,10 +216,13 @@ Since `0.4.1` it now possible to provide externally the branch information via a
246216
Some integration tests are available to make some manual trials/verifications of the plugin.
247217

248218
````
219+
# first install it into the local maven repo, then read the current version into a variable,
220+
# afterwards call it using the following schema:
221+
# bash src/test/integration/test/build.sh CONTEXT JGITVER_GRADLE_VERSION EXPECTED_COMPUTED_VERSION
249222
./gradlew install version
250-
cd src/test/integration/test
251-
./build.sh CONTEXT JGITVER_GRADLE_VERSION EXPECTED_COMPUTED_VERSION
252-
# example ./build.sh tag-regexp 0.5.1-2 2.0.1-1
223+
GRADLE_JGIT_VERSION=`gradle version | grep "Version" | awk '{print $2}'`
224+
echo GRADLE_JGIT_VERSION
225+
./src/test/integration/test/build.sh tag-regexp ${GRADLE_JGIT_VERSION} 2.0.1-1
253226
````
254227

255228
## Linux environment for windows users

0 commit comments

Comments
 (0)