I’m using gradle tooling and using
projectConnection I’m able to get connected to gradle from java. And by using the
ModelBuilder I’m able to get the project object also in my java class.
ModelBuilder gradleBuilder = connection.model(GradleProject.class);
project object has accessibility to Tasks only. (i.e)
project.getTasks() is available. But not
project.getExtensions(). How to access these extensions?? Is there any other way to access the gradle
Extensions from Java?
Edit after your response :
When I run a gradle task it will read the closures in the given file and update the values read in a static java class (
deployGradleReaderExtension.java). Now I’m trying to read the value from extensions by
deployGradleReaderExtension ext = (deployGradleReaderExtension) buildResult.getGradle().getRootProject().getExtensions().getByName("serviceConf");
Now I’m getting the casting exception. Because gradle and java are using diff
Is there any way to overcome this?
It’s possible to access extensions from, say, a plugin written in Java, but not from the tooling API. To achieve strong forward and backwards compatibility, the tooling API only offers a simplified view on the Gradle object model, designed to meet the needs of integrators like IDEs.