The command attribute in the exec task is deprecated and has been since Ant 1.5 when I first started using Ant. I suspect that it will remain obsolete for quite some time. There is no problem besides the warning, but you can also use the execute attribute, which replaces it.
The only problem is that the execute attribute (as opposed to the command attribute) assumes that the command names can contain spaces, so you cannot just insert the whole command into the execute attribute. Instead, you should use subtesk <arg> to pass parameters to the command:
<exec executable="keytool"> <arg line="-genkey -alias test -keyalg DSA -keysize 1024 -keystore keyst.ks -keypass pass -storepass pass -dname "CN=Duke, OU=MyUnit, O=MyOrg, C=US"" </exec>
This last -dname parameter may be a problem. However, you can use the subtask <arg value="> to get around this problem:
<exec executable="keytool"> <arg value="-genkey"/> <arg value="-alias"/> <arg value="test"/> <arg value="-keyalg"/> <arg value="DSA"/> <arg value="-keysize"/> <arg value="1024"/> <arg value="-keystore"/> <arg value="keyst.ks"/> <arg value="-keypass"/> <arg value="pass"/> <arg value="-storepass"/> <arg value="pass"/> <arg value="-dname"/> <arg value="CN=Duke, OU=MyUnit, O=MyOrg, C=US"/> </exec>
Note that the parameter for the -dname field no longer needs " Around him. <arg value> understands that this is the only value despite spaces.
You can combine the line and value types of the <arg> subtask:
<exec executable="keytool"> <arg line="-genkey -alias test -keyalg DSA -keysize 1024"/> <arg line="-keystore keyst.ks -keypass pass123 -storepass pass123 -dname"/> <arg value="CN=Duke, OU=MyUnit, O=MyOrg, C=US"/> </exec>
At least I have done this without any problems before.
source share