use of com.intellij.openapi.roots.LibraryOrderEntry in project kotlin by JetBrains.
the class FrameworksCompatibilityUtils method suggestRemoveIncompatibleFramework.
public static void suggestRemoveIncompatibleFramework(@NotNull ModifiableRootModel rootModel, @NotNull Set<? extends LibraryKind> frameworkLibraryKinds, @NotNull FrameworkType frameworkType) {
List<OrderEntry> existingEntries = new ArrayList<OrderEntry>();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (!(entry instanceof LibraryOrderEntry))
continue;
Library library = ((LibraryOrderEntry) entry).getLibrary();
if (library == null)
continue;
for (LibraryKind kind : frameworkLibraryKinds) {
if (LibraryPresentationManager.getInstance().isLibraryOfKind(Arrays.asList(library.getFiles(OrderRootType.CLASSES)), kind)) {
existingEntries.add(entry);
}
}
}
removeWithConfirm(rootModel, existingEntries, String.format("Current module is already configured with '%s' framework.\nDo you want to remove it?", frameworkType.getPresentableName()), "Framework Conflict");
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project kotlin by JetBrains.
the class FrameworksCompatibilityUtils method suggestRemoveOldJsLibrary.
public static void suggestRemoveOldJsLibrary(@NotNull ModifiableRootModel rootModel) {
List<OrderEntry> oldJsLibraries = new ArrayList<OrderEntry>();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (!(entry instanceof LibraryOrderEntry))
continue;
Library library = ((LibraryOrderEntry) entry).getLibrary();
if (library == null)
continue;
if (JSLibraryStdPresentationProvider.detectOld(library)) {
oldJsLibraries.add(entry);
}
}
removeWithConfirm(rootModel, oldJsLibraries, "Current module is configured with old js library.\nDo you want to remove it?", "Old JS Library");
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project android by JetBrains.
the class AndroidMavenUtil method isMavenAarDependency.
public static boolean isMavenAarDependency(@NotNull Module module, @NotNull OrderEntry entry) {
if (ApplicationManager.getApplication().isUnitTestMode() && entry.getPresentableName().equals("maven_aar_dependency")) {
return true;
}
if (!(entry instanceof LibraryOrderEntry) || !isMavenizedModule(module)) {
return false;
}
final Library library = ((LibraryOrderEntry) entry).getLibrary();
if (library == null) {
return false;
}
final MavenProject mavenProject = MavenProjectsManager.getInstance(module.getProject()).findProject(module);
if (mavenProject == null) {
return false;
}
final MavenArtifact artifact = MavenRootModelAdapter.findArtifact(mavenProject, library);
return artifact != null && AAR_DEPENDENCY_AND_PACKAGING_TYPE.equals(artifact.getType());
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project android by JetBrains.
the class ModuleDependenciesSetup method addLibraryAsDependency.
protected void addLibraryAsDependency(@NotNull Library library, @NotNull String libraryName, @NotNull DependencyScope scope, @NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider) {
for (OrderEntry orderEntry : modelsProvider.getModifiableRootModel(module).getOrderEntries()) {
if (orderEntry instanceof LibraryOrderEntry) {
Library entryLibrary = ((LibraryOrderEntry) orderEntry).getLibrary();
if (entryLibrary != null && libraryName.equals(entryLibrary.getName())) {
// Dependency already set up.
return;
}
}
}
LibraryOrderEntry orderEntry = modelsProvider.getModifiableRootModel(module).addLibraryEntry(library);
orderEntry.setScope(scope);
orderEntry.setExported(true);
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
for (Map.Entry<String, Set<File>> entry : javaModuleModel.getArtifactsByConfiguration().entrySet()) {
Set<File> artifacts = entry.getValue();
if (artifacts != null && !artifacts.isEmpty()) {
for (File artifact : artifacts) {
if (!artifact.isFile() || !endsWithIgnoreCase(artifact.getName(), DOT_JAR)) {
// We only expose artifacts that are jar files.
continue;
}
File buildFolderPath = javaModuleModel.getBuildFolderPath();
String artifactName = getNameWithoutExtension(artifact);
if (buildFolderPath != null && buildFolderPath.isDirectory() && isAncestor(buildFolderPath, artifact, true) && module.getName().equals(artifactName)) {
// This is the jar obtained by compiling the module, no need to add it as dependency.
continue;
}
String libraryName = module.getName() + "." + artifactName;
Library library = ideModelsProvider.getLibraryByName(libraryName);
if (library == null) {
// Create library.
library = ideModelsProvider.createLibrary(libraryName);
Library.ModifiableModel libraryModel = ideModelsProvider.getModifiableLibraryModel(library);
String url = pathToIdeaUrl(artifact);
libraryModel.addRoot(url, CLASSES);
} else {
SyncLibraryRegistry.getInstance(module.getProject()).markAsUsed(library, artifact);
}
LibraryOrderEntry orderEntry = moduleModel.addLibraryEntry(library);
orderEntry.setScope(COMPILE);
orderEntry.setExported(true);
}
}
}
}
Aggregations