ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Programmatically invoking Ant libraries to sign jar files - Example
Date Fri, 24 Jul 2009 08:20:11 GMT
On 2009-07-23, Daniele Development-ML <daniele.dml@googlemail.com> wrote:

> 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.

Thank you for sharing.

I don't think you need the target at all, you could probably get away
with creating project and task instances, wire them up and
invoke execute() on the task instance.

Something like (untested)

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

    Project project = new Project();
    SignJar sj = new SignJar();
    sj.setProject(project);
    // probably not needed fo SignJar, but it is part of Ant's lifecycle
    sj.init();

    sj.setKeystore(sigFile);
    sj.setAlias("alias");
    sj.setKeypass("password");
    sj.setStorepass("keyStorePassword");
    sj.setVerbose(true);
    sj.setJar(file);

    sj.execute();
}

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message