Side Quest: How Gradle Is Removing Ant

In October, the Gradle team spent a week together in Istanbul, and one of those days was a hackathon. One group picked a side quest with a deceptively short description: remove Ant from the Gradle distribution. Then we looked at gradle/gradle and we counted. Ant turned out to back 58 imports across 12 different Gradle features. So “remove Ant” became a deprecation in Gradle 9.9.0, a removal planned for Gradle 10, and a long new section in our upgrade guide.


This is a companion discussion topic for the original entry at https://blog.gradle.org/side-quest-removing-ant

Two usages that come to mind are using the signjar task as last time I checked there was no stable and official Java API to call the jar signer - which can of course be mitigated like the 3rd party ant task recommendation - and building a jar or zip as part of a more complex task action where using a separate task is not feasible.

At least for the second, it would be nice to have ArchiveOperations#zip and ArchiveOperations#jar just like having FileSystemOperations#copy, FileSystemOperations#delete, and FileSystemOperations#sync even though there are dedicated tasks for them.

I wondered the same since we use the signjar task. Fortunately there seems to be an API since JDK 9: jdk.security.jarsigner.JarSigner

Ah nice, is this now stable and supported?
Afair from looking last, there was an API available, but it was not official and not under any stability guarantees.

I would say so, looks like an official module instead of internal API.

The old one was sun.security.tools.jarsigner.Main according to a discussion on the OpenJDK mailing list from 2015.

Ah, yes, that’s the ticket that added it: https://bugs.openjdk.org/browse/JDK-8056174. Forgot about it and probably have the Ant task usage from Java 8 time, or because minimum Java version for running the used Gradle version is still Java 8.

As of the last time I’ve had a look into the details the jacoco plugin did not support ant’s Dump task (loading coverage data via tcp endpoint, e.g. from a running server) in the gradle plugin, so we just created our own wrapper around it with the existing jacoco properties and dependencies.

Sure we can always just re-add the dependency, but that seem a bit weird, do you see any better options to cover this use case?

Edit:

Oh maybe this has been added in the meantime (looking at the address and output properties), I’ll take a closer look at it.