Added workaround "unspecified" version. Closes #9
This commit is contained in:
parent
3e70a53714
commit
65a38facda
1 changed files with 26 additions and 1 deletions
25
README.md
25
README.md
|
@ -250,8 +250,10 @@ The values stored in the version properties file can individually be accessed us
|
||||||
|
|
||||||
```gradle
|
```gradle
|
||||||
fooTask {
|
fooTask {
|
||||||
|
doFirst {
|
||||||
println "Build: $semver.buildMeta"
|
println "Build: $semver.buildMeta"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The semver extension properties are:
|
The semver extension properties are:
|
||||||
|
@ -269,6 +271,29 @@ Property | Description
|
||||||
`semver.buildMetaPrefix` | The build metadata prefix
|
`semver.buildMetaPrefix` | The build metadata prefix
|
||||||
`semver.separator` | The version separator.
|
`semver.separator` | The version separator.
|
||||||
|
|
||||||
|
## Version is "unspecified"
|
||||||
|
|
||||||
|
This is a common problem steaming from the configuration and build phases in Gradle.
|
||||||
|
|
||||||
|
It is always preferable to access to version during the execution stage, in a `doFirst` or `doLast` closure within your tasks:
|
||||||
|
|
||||||
|
```gradle
|
||||||
|
task foo() {
|
||||||
|
doFirst {
|
||||||
|
println project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
or if absolutely necessary, at the end of the configuration stage in a `project.afterEvaluate` block:
|
||||||
|
|
||||||
|
```gradle
|
||||||
|
foo {
|
||||||
|
project.afterEvaluate {
|
||||||
|
println project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Source Code Generation
|
## Source Code Generation
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue