use of com.android.tools.idea.templates.SupportLibrary in project android by JetBrains.
the class MavenDependencyLookupDialog method isKnownLocalLibrary.
private static boolean isKnownLocalLibrary(@NotNull String text) {
String group = getGroup(text);
String artifact = getArtifact(text);
if (group == null || artifact == null) {
return false;
}
SupportLibrary library = SupportLibrary.find(group, artifact);
return library != null;
}
use of com.android.tools.idea.templates.SupportLibrary in project android by JetBrains.
the class ModuleDependenciesPanel method installRepositoryIfNeeded.
private String installRepositoryIfNeeded(String coordinateText) {
GradleCoordinate gradleCoordinate = GradleCoordinate.parseCoordinateString(coordinateText);
// Only allowed to click ok when the string is valid.
assert gradleCoordinate != null;
SupportLibrary supportLibrary = SupportLibrary.forGradleCoordinate(gradleCoordinate);
if (!REVISION_ANY.equals(gradleCoordinate.getRevision()) || supportLibrary == null) {
// No installation needed, or it's not a local repository.
return coordinateText;
}
String message = "Library " + gradleCoordinate.getArtifactId() + " is not installed. Install repository?";
if (Messages.showYesNoDialog(myProject, message, "Install Repository", Messages.getQuestionIcon()) != Messages.YES) {
// User cancelled installation.
return null;
}
List<String> requested = Lists.newArrayList();
SdkMavenRepository repository;
if (coordinateText.startsWith("com.android.support")) {
repository = SdkMavenRepository.ANDROID;
} else if (coordinateText.startsWith("com.google.android")) {
repository = SdkMavenRepository.GOOGLE;
} else {
// EXTRAS_REPOSITORY.containsKey() should have returned false.
assert false;
return coordinateText + ':' + REVISION_ANY;
}
requested.add(repository.getPackageId());
ModelWizardDialog dialog = SdkQuickfixUtils.createDialogForPaths(myProject, requested);
if (dialog != null) {
dialog.setTitle("Install Missing Components");
if (dialog.showAndGet()) {
return RepositoryUrlManager.get().getLibraryStringCoordinate(supportLibrary, true);
}
}
// Installation wizard didn't complete - skip adding the dependency.
return null;
}
use of com.android.tools.idea.templates.SupportLibrary in project android by JetBrains.
the class AndroidAddLibraryDependencyAction method findAllDependencies.
/**
* Finds all the "extras repository" dependencies that haven't been already added to the project.
*/
@NotNull
private static ImmutableCollection<String> findAllDependencies(@NotNull GradleBuildModel buildModel) {
HashSet<String> existingDependencies = Sets.newHashSet();
for (ArtifactDependencyModel dependency : buildModel.dependencies().artifacts()) {
existingDependencies.add(dependency.group().value() + ":" + dependency.name().value());
}
ImmutableList.Builder<String> dependenciesBuilder = ImmutableList.builder();
RepositoryUrlManager repositoryUrlManager = RepositoryUrlManager.get();
for (SupportLibrary library : SupportLibrary.values()) {
// Coordinate for any version available
GradleCoordinate libraryCoordinate = library.getGradleCoordinate("+");
// Get from the library coordinate only the group and artifactId to check if we have already added it
if (!existingDependencies.contains(libraryCoordinate.getId())) {
GradleCoordinate coordinate = repositoryUrlManager.resolveDynamicCoordinate(libraryCoordinate, buildModel.getProject());
if (coordinate != null) {
dependenciesBuilder.add(coordinate.toString());
}
}
}
return dependenciesBuilder.build();
}
Aggregations