use of com.android.tools.idea.gradle.dsl.parser.android.AndroidDslElement in project android by JetBrains.
the class GradleBuildModel method android.
/**
* Returns {@link AndroidModel} to read and update android block contents in the build.gradle file.
*
* <p>Returns {@code null} when experimental plugin is used as reading and updating android section is not supported for the
* experimental dsl.</p>
*/
@Nullable
public AndroidModel android() {
AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.find(myGradleDslFile.getProject());
if (androidPluginInfo != null && androidPluginInfo.isExperimental()) {
// Reading or updating Android block contents is not supported when experimental plugin is used.
return null;
}
AndroidDslElement androidDslElement = myGradleDslFile.getPropertyElement(ANDROID_BLOCK_NAME, AndroidDslElement.class);
if (androidDslElement == null) {
androidDslElement = new AndroidDslElement(myGradleDslFile);
myGradleDslFile.setNewElement(ANDROID_BLOCK_NAME, androidDslElement);
}
return new AndroidModel(androidDslElement);
}
Aggregations