Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to parse a build.gradle file into someother data form

Tags:

android

gradle

Gradle is DSL. I want to know if any means to parse a 'build.gradle' script into someother data form? for example, to a JSON, so I could modify it with codes.

And further, how to parse reversely? (JSON back to build.gradle).

Sorry for the nonsense, I recently have to do some dynamic 'build.gradle' modification work with some kind of script, which includes modifying some existing task in that 'build.gradle' script.

Any help would be good.

like image 255
user1425353 Avatar asked Aug 24 '15 04:08

user1425353


2 Answers

There is currently no reliable way to do this. For simple build scripts this might be possible to be implemented by yourself, but the build.gradle file reflecting the DSL describing the project build model is quite deep and complex including the project model, different tasks + different tasks types, build listeners and other kind of hooks.

With the new configuration model the gradle team is currently working on, the bridging to different presentations of the model will be easier I think (see https://docs.gradle.org/current/userguide/new_model.html for details).

like image 176
Rene Groeschke Avatar answered Nov 08 '22 22:11

Rene Groeschke


Are you able to explain the actual problem you are trying to solve?

A possible solution might be for build.gradle to read a json file and configure the project model based on the json values. You could then generate the json file with some other process.

like image 30
lance-java Avatar answered Nov 08 '22 22:11

lance-java