The goal of this task is to provide a way to merge property files and write the result in a new file
One of the motivation to create this was a webapplication for different customers and with different configurations. Unfortunatly in the property file contains sometimes things like text resources and installation specific properties.
With this task you can store the common properties in a file and the specific properties in a different file and merge them whithin the build process to the necessary one for the runtime configuration.
One of the easiest way is simple copy the jar jugbbant-*.jar into the ANT runtime lib directory
The disadvantage of this method is, you collect a lot of different libs (over the time) into your ANT runtime and if you decided to change your ANT version you have to move all of them. The next problem is, especially in larger projects, all of the involved developer have to do that.
A fare better approach is to store the jugbbant-*.jar file into your project and reference it from your build script.
Class: org.jugbb.ant.propertymerge.PropertyMergeTask
A propertymerge task has seven attributes:
Attribute | Description | Required |
inputPropertyFile | path to the main property file | Yes |
inputPropertyFileEncoding | encoding of the file. It is strongly recommended to set this attribute! | No default=UTF-8 |
mergePropertyFile | path to the property file which contains only the properties which are different or have different values from the input properties | Yes |
mergePropertyFileEncoding | encoding of the file. | No default={inputPropertyFileEncoding} |
ignoreMissingMergeFile | Ignores if merge property file does not exists. Task ends without failure. | No default=true |
outputPropertyFile | path to the property file which contains the merge from input and merge properties. | Yes |
outpuPropertyFileEncoding | encoding of the file. This value will be ignored if native2ascii=true |
No default={inputPropertyFileEncoding} |
native2ascii | true= the output will be converted into an ASCII file with unicode literals.
The output file will be encoded as ASCII file |
No |
This examples shows a typical usage. The encoding of the main property file describes also the encoding of al other files. After the merge the output file will be converted into an ASCII file with unicode literals. That avoids a necessary call to the native2ascii task
The necessary lib for this merge task is located within the current project.
<target name="mergetest"> <taskdef name="propertymerge" classname="org.jugbb.ant.propertymerge.PropertyMergeTask"> <classpath> <pathelement path="build/jugbbant-1.7.jar"/> </classpath> </taskdef> <propertymerge inputpropertyfile="files/basic.properties" inputpropertyfileencoding="ISO-8859-1" mergepropertyfile="files/to_merge_into.properties" outputpropertyfile="files/result.properties" native2ascii="true"/> </target>
Binary: jugbbant-1.7.jar
Sources: jugbbant-1.7-src.zip