Using gradle in an existing (Java) Project as an buildtool

As you can see from the Title / Headline / Topic, I want to use Gradle as a BuildTool in my existing (Java) Project.

FIrst of all, No, I don’t want to execute some Gradle tasks in my commandline / terminal to build this project.

My existing Java Project should download (via GIT), build (via Gradle) and finally launch theses Projects (via Classpath). For GIT I use a API called ‘JGIT’ and the launch part is also included in my project, so I was wondering if there is a API for Gradle to build (and manage …) Gradle Projects without using an commandline / terminal or launch a Gradle(w) script via
Runtime.getRuntime().exec("./gradlew"); or an ProcessBuilder.

I just haven’t find any related information about this topic, but if was too stupid to search I apologize for everything in advance.

Thanks in advance
Lukas

Hi Lukas,

yes such an API exists, it is called the Tooling API.

Cheers,
Stefan

1 Like

Hey Stefan,

First of all thanks for your fast answer, but sadly i do not think that my problem is solved.
My Application should be able to run on nearly every PC that can install java on it.

If I get it right, you must have Gradle installed locally and the deamon service must be active, otherwise it won’t work. How should I deal with that? :sweat_smile:

Currently I “ship” the Gradle wrapper file with the repository and execute the task via ProcessBuilder.

Thanks in advance,
Lukas

The Tooling API does not need a Gradle installation. Everything that you need to kick off Gradle (including downloading a distribution if required) is included in the tooling-api jar. Your application just needs to include that single jar. Please just give it a try and you’ll see :slight_smile:

1 Like

I just tried the tooling api and was impressed.
It was a bit hard to “find into it” but now … truly impressed.

In addition I was a bit confused by the wiki article. It says down at 13.2 “The Tooling API uses the daemon all the time. In fact, you cannot officially use the Tooling API without the daemon.”, which maid me think, that you’ll need to have gradle.

Thanks for your fast support ^-^

1 Like