More cleanup.
This commit is contained in:
parent
34fd91a682
commit
639f43893e
3 changed files with 29 additions and 24 deletions
46
README.md
46
README.md
|
@ -1,6 +1,6 @@
|
||||||
# PropertyFile plug-in for [Kobalt](http://beust.com/kobalt/home/index.html)
|
# PropertyFile plug-in for [Kobalt](http://beust.com/kobalt/home/index.html)
|
||||||
|
|
||||||
[](http://opensource.org/licenses/BSD-3-Clause) [](https://travis-ci.org/ethauvin/kobalt-property-file)
|
[](http://opensource.org/licenses/BSD-3-Clause) [](https://travis-ci.org/ethauvin/kobalt-property-file)
|
||||||
|
|
||||||
The PropertyFile plug-in provides an optional task for editing [property files](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html). It is inspired by the [ant PropertyFile task](https://ant.apache.org/manual/Tasks/propertyfile.html).
|
The PropertyFile plug-in provides an optional task for editing [property files](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html). It is inspired by the [ant PropertyFile task](https://ant.apache.org/manual/Tasks/propertyfile.html).
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ val p = project {
|
||||||
propertyFile {
|
propertyFile {
|
||||||
file = "version.properties"
|
file = "version.properties"
|
||||||
comment = "##Generated file - do not modify!"
|
comment = "##Generated file - do not modify!"
|
||||||
entry(key = "product.build.major", type = Types.INT, value = "3")
|
entry(key = "product.build.major", value = "3")
|
||||||
entry(key = "product.build.minor", type = Types.INT, operation = Operations.ADD)
|
entry(key = "product.build.minor", type = Types.INT, operation = Operations.ADD)
|
||||||
entry(key = "product.build.patch", type = Types.INT, value = "0")
|
entry(key = "product.build.patch", value = "0")
|
||||||
entry(key = "product.build.date" , type = Types.DATE, value = "now")
|
entry(key = "product.build.date" , type = Types.DATE, value = "now")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,19 @@ Attribute | Description | Required
|
||||||
|
|
||||||
## Entry
|
## Entry
|
||||||
|
|
||||||
The `entry` function is used to specify modifications to be made to the property file.
|
The `entry` function is used to specify edits to be made to the property file.
|
||||||
|
|
||||||
Attribute | Description | Required
|
Attribute | Description
|
||||||
:-----------|:----------------------------------------------------------------------------------------------------------------- |:----------------------------------------------
|
:-----------|:-----------------------------------------------------------------------------------------------------------------
|
||||||
`key` | The name of the property name/value pair. | Yes, unless `operation` is `Operations.DELETE`
|
`key` | The name of the property name/value pair.
|
||||||
`value` | The value of the property. | Yes, unless `operation` is `Operations.DELETE`
|
`value` | The value of the property.
|
||||||
`default` | The initial value to set for the property if not already defined. For `Type.DATE`, the `now` keyword can be used. | Yes, unless `operation` is `Operations.DELETE`
|
`default` | The initial value to set for the property if not already defined. For `Type.DATE`, the `now` keyword can be used.
|
||||||
`type` | Tread the value as `Types.INT`, `Types.DATE`, or `Types.STRING` (default). | No
|
`type` | Tread the value as `Types.INT`, `Types.DATE`, or `Types.STRING`. If none specified, `Types.STRING` is assumed.
|
||||||
`operation` | See [operations](#operations). | No
|
`operation` | See [operations](#operations).
|
||||||
`pattern` | For `Types.INT` and `Types.DATE` only. If present, will parse the value as [DecimalFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html) or [SimpleDateFormat](https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) patterns, respectively. | No
|
`pattern` | For `Types.INT` and `Types.DATE` only. If present, will parse the value as [DecimalFormat](https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html) or [SimpleDateFormat](https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) patterns, respectively.
|
||||||
`unit` | The unit value to be applied to `Operations.ADD` and `Operations.SUBTRACT` for `Types.DATE`. See [Units](#units). | No
|
`unit` | The unit value to be applied to `Operations.ADD` and `Operations.SUBTRACT` for `Types.DATE`. See [Units](#units).
|
||||||
|
|
||||||
|
`key` is required. `value` or `default` are required unless the `operation` is `Operations.DELETE`.
|
||||||
|
|
||||||
## Operations
|
## Operations
|
||||||
|
|
||||||
|
@ -61,21 +63,21 @@ Operation | Description
|
||||||
:---------------------|:-------------------------------------------------------------------------
|
:---------------------|:-------------------------------------------------------------------------
|
||||||
`Operations.ADD` | Adds a value to an entry.
|
`Operations.ADD` | Adds a value to an entry.
|
||||||
`Operations.DELETE` | Deletes an entry.
|
`Operations.DELETE` | Deletes an entry.
|
||||||
`Operations.SET` | Sets the entry value. This is the default.
|
`Operations.SET` | Sets the entry value. This is the default operation.
|
||||||
`Operations.SUBTRACT` | Subtracts a value from the entry. For `Types.INT` and `Types.DATE` only.
|
`Operations.SUBTRACT` | Subtracts a value from the entry. For `Types.INT` and `Types.DATE` only.
|
||||||
|
|
||||||
## Units
|
## Units
|
||||||
|
|
||||||
The following units are available for `Types.DATE` with `Operations.ADD` and `Operations.SUBTRACT`:
|
The following units are available for `Types.DATE` with `Operations.ADD` and `Operations.SUBTRACT`:
|
||||||
|
|
||||||
* Units.MILLISECOND
|
* `Units.MILLISECOND`
|
||||||
* Units.SECOND
|
* `Units.SECOND`
|
||||||
* Units.MINUTE
|
* `Units.MINUTE`
|
||||||
* Units.HOUR
|
* `Units.HOUR`
|
||||||
* Units.DAY
|
* `Units.DAY`
|
||||||
* Units.WEEK
|
* `Units.WEEK`
|
||||||
* Units.MONTH
|
* `Units.MONTH`
|
||||||
* Units.YEAR
|
* `Units.YEAR`
|
||||||
|
|
||||||
## Rules
|
## Rules
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.beust.kobalt.plugin.application.*
|
||||||
import com.beust.kobalt.plugin.kotlin.*
|
import com.beust.kobalt.plugin.kotlin.*
|
||||||
import net.thauvin.erik.kobalt.plugin.propertyfile.*
|
import net.thauvin.erik.kobalt.plugin.propertyfile.*
|
||||||
|
|
||||||
|
// ./kobaltw propertyFile
|
||||||
|
|
||||||
val bs = buildScript {
|
val bs = buildScript {
|
||||||
plugins(file("../libs/kobalt-property-file-0.1.0.jar"))
|
plugins(file("../libs/kobalt-property-file-0.1.0.jar"))
|
||||||
}
|
}
|
||||||
|
@ -39,6 +41,8 @@ val p = project {
|
||||||
entry(key = "version.dateISO", value = "now", type = Types.DATE, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
entry(key = "version.dateISO", value = "now", type = Types.DATE, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
entry(key = "date.nextMonth", value = "now", type = Types.DATE)
|
entry(key = "date.nextMonth", value = "now", type = Types.DATE)
|
||||||
entry(key = "date.nextMonth", value = "0", type = Types.DATE, unit = Units.MONTH, operation = Operations.ADD)
|
entry(key = "date.nextMonth", value = "0", type = Types.DATE, unit = Units.MONTH, operation = Operations.ADD)
|
||||||
|
|
||||||
|
// examples from: https://ant.apache.org/manual/Tasks/propertyfile.html
|
||||||
entry(key = "akey", value = "avalue")
|
entry(key = "akey", value = "avalue")
|
||||||
entry(key = "adate", type = Types.DATE, value = "now")
|
entry(key = "adate", type = Types.DATE, value = "now")
|
||||||
entry(key = "anint", type = Types.INT, default = "0", operation = Operations.ADD)
|
entry(key = "anint", type = Types.INT, default = "0", operation = Operations.ADD)
|
||||||
|
@ -48,6 +52,6 @@ val p = project {
|
||||||
operation = Operations.SUBTRACT, value = "1")
|
operation = Operations.SUBTRACT, value = "1")
|
||||||
entry(key = "formated.tomorrow", type = Types.DATE, default = "now", pattern = "DDD",
|
entry(key = "formated.tomorrow", type = Types.DATE, default = "now", pattern = "DDD",
|
||||||
operation = Operations.ADD, value = "1")
|
operation = Operations.ADD, value = "1")
|
||||||
entry(key = "progress", default = "", operation = Operations.ADD, value = "1")
|
entry(key = "progress", default = "", operation = Operations.ADD, value = ".")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,6 @@ enum class Operations {
|
||||||
ADD, DELETE, SET, SUBTRACT
|
ADD, DELETE, SET, SUBTRACT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum class Units {
|
enum class Units {
|
||||||
MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
|
MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue