ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniele Development-ML <daniele....@googlemail.com>
Subject Programmatically invoking Ant libraries to sign jar files - Example
Date Thu, 23 Jul 2009 17:47:19 GMT
Hello everybody,
some time ago I emailed to ask details/examples on how
to programmatically invoke Ant libraries to sign a jar file. There were
contrasted opinion on whether Ant libraries could be invoked directly and I
was invited to post an example when (and if) I was successful in this.

With a considerable delay (apologies for this):

Please find below the code - hopefully it will be useful to somebody else.

private static void sign(File file) {
        String sigFile = System.getProperty("user.home") +
Paths.SIGNATURE_FILE_PATH;

        Project project = new Project();
        Target target = new Target();
        SignJar sj = new SignJar();
        target.addTask(sj);

        project.addTarget("sign_jar", target);

        sj.setKeystore(sigFile);
        sj.setAlias("alias");

        sj.setKeypass("password");
        sj.setStorepass("keyStorePassword");

        sj.setProject(project);
        sj.setVerbose(true);
        sj.setJar(file);

        project.executeTarget("sign_jar");
    }


Daniele

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message