use of com.android.tools.idea.gradle.structure.model.android.dependency.PsNewDependencyScopes in project android by JetBrains.
the class PsAndroidModule method addLibraryDependency.
public void addLibraryDependency(@NotNull String library, @NotNull PsNewDependencyScopes newScopes, @NotNull List<String> scopesNames) {
// Update/reset the "parsed" model.
addLibraryDependencyToParsedModel(scopesNames, library);
// Reset dependencies.
myDependencyCollection = null;
PsAndroidDependencyCollection dependencyCollection = getOrCreateDependencyCollection();
List<PsAndroidArtifact> targetArtifacts = Lists.newArrayList();
forEachVariant(variant -> variant.forEachArtifact(artifact -> {
if (newScopes.contains(artifact)) {
targetArtifacts.add(artifact);
}
}));
assert !targetArtifacts.isEmpty();
PsArtifactDependencySpec spec = PsArtifactDependencySpec.create(library);
assert spec != null;
PsParsedDependencies parsedDependencies = getParsedDependencies();
for (PsAndroidArtifact artifact : targetArtifacts) {
List<ArtifactDependencyModel> matchingParsedDependencies = parsedDependencies.findLibraryDependencies(spec, artifact::contains);
for (ArtifactDependencyModel parsedDependency : matchingParsedDependencies) {
dependencyCollection.addLibraryDependency(spec, artifact, parsedDependency);
}
}
fireLibraryDependencyAddedEvent(spec);
setModified(true);
}
use of com.android.tools.idea.gradle.structure.model.android.dependency.PsNewDependencyScopes in project android by JetBrains.
the class AddLibraryDependencyDialog method addNewDependencies.
@Override
public void addNewDependencies() {
String library = myLibraryDependenciesForm.getSelectedLibrary();
assert library != null;
AbstractDependencyScopesPanel scopesPanel = getScopesPanel();
List<String> scopesNames = scopesPanel.getSelectedScopeNames();
PsModule module = getModule();
if (module instanceof PsAndroidModule) {
PsNewDependencyScopes newScopes = ((AndroidDependencyScopesPanel) scopesPanel).getNewScopes();
assert newScopes != null;
((PsAndroidModule) module).addLibraryDependency(library, newScopes, scopesNames);
} else if (module instanceof PsJavaModule) {
((PsJavaModule) module).addLibraryDependency(library, scopesNames);
}
}
Aggregations