use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap in project android by JetBrains.
the class GradleBuildModel method applyPlugin.
@NotNull
public GradleBuildModel applyPlugin(@NotNull String plugin) {
if (getValues(appliedPlugins()).contains(plugin.trim())) {
return this;
}
GradleDslExpressionMap applyMap = new GradleDslExpressionMap(myGradleDslFile, APPLY_BLOCK_NAME);
applyMap.addNewLiteral(PLUGIN, plugin.trim());
myToBeAppliedPlugins.add(applyMap);
return this;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap in project android by JetBrains.
the class DependencyConfigurationModel method excludes.
@NotNull
public List<ExcludedDependencyModel> excludes() {
GradleDslElementList elementList = myConfigurationElement.getPropertyElement(EXCLUDE, GradleDslElementList.class);
if (elementList == null) {
return ImmutableList.of();
}
List<ExcludedDependencyModel> excludedDependencies = new ArrayList<>();
for (GradleDslExpressionMap excludeElement : elementList.getElements(GradleDslExpressionMap.class)) {
excludedDependencies.add(new ExcludedDependencyModel(excludeElement));
}
return excludedDependencies;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap in project android by JetBrains.
the class GradleBuildModel method appliedPlugins.
@NotNull
public List<GradleNotNullValue<String>> appliedPlugins() {
ApplyDslElement applyDslElement = myGradleDslFile.getPropertyElement(APPLY_BLOCK_NAME, ApplyDslElement.class);
if (applyDslElement == null) {
return ImmutableList.of();
}
List<GradleNotNullValue<String>> listProperty = applyDslElement.getListProperty(PLUGIN, String.class);
if (listProperty == null) {
return ImmutableList.of();
}
List<GradleNotNullValue<String>> plugins = new ArrayList<>();
Set<String> pluginValues = new HashSet<>();
for (GradleNotNullValue<String> plugin : listProperty) {
if (pluginValues.add(plugin.value())) {
// Avoid duplicate plugin entries.
plugins.add(plugin);
}
}
for (GradleDslExpressionMap toBeAppliedPlugin : myToBeAppliedPlugins) {
GradleNullableValue<String> plugin = toBeAppliedPlugin.getLiteralProperty(PLUGIN, String.class);
assert plugin instanceof GradleNotNullValue;
if (pluginValues.add(plugin.value())) {
// Avoid duplicate plugin entries.
plugins.add((GradleNotNullValue<String>) plugin);
}
}
return plugins;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap in project android by JetBrains.
the class GradleBuildModel method removePlugin.
@NotNull
public GradleBuildModel removePlugin(@NotNull String plugin) {
plugin = plugin.trim();
ApplyDslElement applyDslElement = myGradleDslFile.getPropertyElement(APPLY_BLOCK_NAME, ApplyDslElement.class);
if (applyDslElement == null) {
return this;
}
List<GradleDslExpressionMap> toBeRemovedPlugins = new ArrayList<>();
for (GradleDslExpressionMap applyMap : myToBeAppliedPlugins) {
if (plugin.equals(applyMap.getLiteralProperty(PLUGIN, String.class).value())) {
toBeRemovedPlugins.add(applyMap);
}
}
myToBeAppliedPlugins.removeAll(toBeRemovedPlugins);
while (getValues(applyDslElement.getListProperty(PLUGIN, String.class)).contains(plugin)) {
applyDslElement.removeFromExpressionList(PLUGIN, plugin);
}
return this;
}
use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionMap in project android by JetBrains.
the class GradleBuildModel method applyChanges.
@Override
public void applyChanges() {
// needs to be added.
for (GradleDslExpressionMap applyMap : myToBeAppliedPlugins) {
applyMap.create();
applyMap.applyChanges();
myGradleDslFile.addParsedElement(APPLY_BLOCK_NAME, applyMap);
}
myToBeAppliedPlugins.clear();
super.applyChanges();
}
Aggregations