diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index c119f25..e7a8308 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](http://opensource.org/licenses/BSD-3-Clause) [![GitHub CI](https://github.com/rife2/bld-property-file/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-property-file/actions/workflows/bld.yml) - An extension for creating or modifying [property files](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) with [bld](https://github.com/rife2/rife2/wiki/What-Is-Bld). It is inspired by the [ant PropertyFile task](https://ant.apache.org/manual/Tasks/propertyfile.html). ```java @@ -18,34 +17,54 @@ public void updateMajor() throws Exception { } ``` +Assuming the following `version.properties` file: -To invoke the `updateMajor` command: - -```sh -./bld updateMajor +```ini +# version.properties +version.major=1 +version.minor=0 +version.patch=1 ``` -## PropertyFileOperation +Invoking the `updateMajor` command: -Attribute | Description | Required -:---------------|:----------------------------------------------------------|:-------- -`file` | The location of the properties files to modify. | Yes -`comment` | Comment to be inserted at the top of the properties file. | No -`failOnWarning` | If set to `true`, will fail on any warnings. | No +```sh +./bld updateMajor ... +``` + +would update the properties to: + +```ini +# version.properties +version.major=2 +version.minor=0 +version.patch=0 +``` +- [View Examples](https://github.com/rife2/bld-property-file/tree/master/examples) + +## Property File + +The `PropertyFileOperation` class is used to configure the [properties file](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) location, etc. + +Attribute | Description | Required +:---------------|:-----------------------------------------------------------------|:-------- +`file` | The location of the properties files to modify. | Yes +`comment` | Comment to be inserted at the top of the properties file. | No +`failOnWarning` | If set to `true`, will cause executiion to fail on any warnings. | No ## Entry -The `entry` function is used to specify edits to be made to the properties file. +The `Entry` class is used to specify modifications to be made to the [properties file](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html). -Attribute | Description -:-----------|:----------------------------------------------------------------------------------------------------------------- -`key` | The name of the property name/value pair. -`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. -`type` | Tread the value as `Types.INT`, `Types.DATE`, or `Types.STRING`. If none specified, `Types.STRING` is assumed. -`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. -`unit` | The unit value to be applied to `Operations.ADD` and `Operations.SUBTRACT` for `Types.DATE`. See [Units](#units). +Attribute | Description +:--------------|:----------------------------------------------------------------------------------------------------------------- +`key` | The name of the property name/value pair. +`value` | The value of the property. +`defaultVlaue` | 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`. If none specified, `Types.STRING` is assumed. +`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. +`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`. @@ -78,10 +97,10 @@ The following units are available for `Types.DATE` with `Operations.ADD` and `Op The rules used when setting a property value are: * If only `value` is specified, the property is set to it regardless of its previous value. -* If only `default` is specified and the property previously existed, it is unchanged. -* If only `default` is specified and the property did not exist, the property is set to `default`. -* If `value` and `default` are both specified and the property previously existed, the property is set to `value`. -* If `value` and `default` are both specified and the property did not exist, the property is set to `default`. +* If only `defaultValue` is specified and the property previously existed, it is unchanged. +* If only `defaultValue` is specified and the property did not exist, the property is set to `defaultValue`. +* If `value` and `defaultValue` are both specified and the property previously existed, the property is set to `value`. +* If `value` and `defaultValue` are both specified and the property did not exist, the property is set to `defaultValue`. Operations occur after the rules are evaluated. @@ -89,4 +108,4 @@ Operations occur after the rules are evaluated. * The comments and layout of the original property file will not be preserved. * The `jdkproperties` parameter is not implemented. -* The default `Entry.Types.DATE` pattern is `yyyy-MM-dd HH:mm` and not `yyyy/MM/dd HH:mm`. \ No newline at end of file +* The default `Types.DATE` pattern is `yyyy-MM-dd HH:mm` and not `yyyy/MM/dd HH:mm`. \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index cce7e7f..cf9d2eb 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,10 +2,10 @@ ## Compile -First make sure the project is compiled, by issuing the following command: +First make sure the project up-to-date and compiled: ```shell -./bld compile +./bld download compile ``` ## Run