I want to show a password input dialog from ant script. Here's my code from build.xml:
<target name="sign" unless="isUpToDate">
<script language="javascript">
importClass(javax.swing.JPasswordField);
importClass(javax.swing.JOptionPane);
var pf = new JPasswordField();
var okCxl = JOptionPane.showConfirmDialog(null, pf, "Enter Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (okCxl == JOptionPane.OK_OPTION) {
project.setNewProperty("keypass", pf.getPassword());
} else {
throw "Password is required";
}
</script>
<echo message="${keypass}"></echo>
...
</target>
This code hangs forever. What's wrong?
Update: I'm testing in Mac OS X 10.8.2 and Oracle JDK 7u13
It works well in Eclipse Juno Release Build id: 20120614-1722 and JDK 7 under Windows XP:
And it works well from Run.bat :
But getPassword() returns char[] not String, this is because the echo is not human readable.
As an alternative, put the
storepass
required by<signjar />
in an invisible file, e.g..deployconf
, having user-only access: e.g.400
or600
. Load the password inant
, and use as required:This works well with
<signjar />
, although some effort may be required to keep linefeeds out of.deployconf
.