Avoid generating gradle-api jar

Hello,

We set up a CI with Jenkins and Docker to build our Gradle projects. All projects use the Gradle Wrapper. I noticed that each time a Gradle build is launched in a new Docker container, a gradle-api jar is generated. this slows done the build significantly. Is there a way to avoid generating this jar at each build?

Regards,
Thomas

Are you depending on gradleApi() somewhere?
For example by applying the kotlin-dsl plugin?
Because iirc this is what uses that generated jar. So you could for example instead use Gradle plugin development but need to make sure to adapt this if you change Gradle versions.
Or you could use a Docker image where this generated Jar is already produced and present.

Thanks for your answer.

Are you depending on gradleApi() somewhere?
For example by applying the kotlin-dsl plugin?
Because iirc this is what uses that generated jar.

I don’t use gradleApi() directly but all my projects use a custom plugin which has been built with the java-gradle-plugin plugin (which adds the gradleApi() dependency if I understand correctly). I understaood it is the recommanded way to do it.

So you could for example instead use Gradle plugin development but need to make sure to adapt this if you change Gradle versions.

Defining a specific version would not generate the API jar anymore? I will do some tests.
All projects do not use the same version of Gradle, it is defined by their Gradle Wrapper settings, so it is not that simple but it is worth some tests.

Or you could use a Docker image where this generated Jar is already produced and present.

Yes, but it means updating the image each time a new Gradle version is published, not very convenient.