I'm trying to use Java system properties to take values from Command line as follows in my build.xml file -
<target name="endPoint depends="standard-release">
<java classname="callPath.sampleClass" classpath="${bp:run.classpath}" fork="true">
<sysproperty key="commandType" value="${commandType}"/>
<sysproperty key="commandName" value="${Name}"/>
<sysproperty key="valueType" value="${valueType}"/>
<sysproperty key="valueName" value="${valueName}"/>
</java>
</target>
In my main method for sampleClass I'm retrieving the values passed using system properties and storing them in corresponding variables as follows -
public final class sampleClass {
public static void main(String[] args) throws Exception {
final String commandType = System.getProperty("commandType");
final String commandName = System.getProperty("commandName");
final String valueType = System.getProperty("valueType");
final String valueName = System.getProperty("valueName");
....
.....
}
}
However, I want to default the values of commandType
& valueType
to TYPE0
when the user doesn't provide with any value from CLI.
But I can't do that as the default value would be commandType
& valueType
itself as mentioned in the build.xml file.
When user tries to provide a value they can use -DcommandType=
& -DvalueType=
need to store that in the variables.
But when the user doesn't provide with any value then the values of both the variables should be TYPE0
How can I achieve this?