use of com.intellij.openapi.roots.libraries.Library in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStepTest method assertJarIsLibrary.
private void assertJarIsLibrary(@NotNull File jarFilePath) {
LibraryTable libraryTable = ProjectLibraryTable.getInstance(getProject());
Library[] libraries = libraryTable.getLibraries();
assertThat(libraries).hasLength(1);
Library library = libraries[0];
String libraryName = library.getName();
assertNotNull(libraryName);
assertEquals(createLibraryName(jarFilePath), libraryName);
String[] urls = library.getUrls(CLASSES);
assertThat(urls).hasLength(1);
assertEquals(pathToUrl(jarFilePath.getPath()), urls[0]);
assertAbout(libraryDependencies()).that(getModule()).contains(libraryName);
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-plugins by JetBrains.
the class DartProjectComponent method removeGlobalDartSdkLib.
private void removeGlobalDartSdkLib() {
for (final Library library : ApplicationLibraryTable.getApplicationTable().getLibraries()) {
if (DartSdk.DART_SDK_LIB_NAME.equals(library.getName())) {
final DartSdk oldGlobalSdk = DartSdk.getSdkByLibrary(library);
if (oldGlobalSdk != null) {
DartSdkUtil.updateKnownSdkPaths(myProject, oldGlobalSdk.getHomePath());
}
ApplicationManager.getApplication().runWriteAction(() -> ApplicationLibraryTable.getApplicationTable().removeLibrary(library));
return;
}
}
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-plugins by JetBrains.
the class DartSdkLibUtil method createDartSdkLib.
private static void createDartSdkLib(@NotNull final Project project, @NotNull final LibraryTable.ModifiableModel libraryTableModel, @NotNull final String sdkHomePath) {
final Library existingLib = libraryTableModel.getLibraryByName(DartSdk.DART_SDK_LIB_NAME);
if (existingLib != null) {
setupDartSdkRoots(project, existingLib, sdkHomePath);
} else {
final Library library = libraryTableModel.createLibrary(DartSdk.DART_SDK_LIB_NAME);
setupDartSdkRoots(project, library, sdkHomePath);
}
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-plugins by JetBrains.
the class DartSdkLibUtil method ensureDartSdkConfigured.
public static void ensureDartSdkConfigured(@NotNull final Project project, @NotNull final String sdkHomePath) {
final LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
final Library library = libraryTable.getLibraryByName(DartSdk.DART_SDK_LIB_NAME);
if (library == null) {
final LibraryTable.ModifiableModel model = libraryTable.getModifiableModel();
createDartSdkLib(project, model, sdkHomePath);
model.commit();
} else {
final DartSdk sdk = DartSdk.getSdkByLibrary(library);
if (sdk == null || !sdkHomePath.equals(sdk.getHomePath())) {
setupDartSdkRoots(project, library, sdkHomePath);
}
}
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-plugins by JetBrains.
the class CucumberConfigUtil method getCucumberCoreVersionImpl.
@Nullable
private static String getCucumberCoreVersionImpl(Module module) {
for (OrderEntry orderEntry : ModuleRootManager.getInstance(module).getOrderEntries()) {
if (orderEntry instanceof LibraryOrderEntry) {
final String libraryName = ((LibraryOrderEntry) orderEntry).getLibraryName();
final Library library = ((LibraryOrderEntry) orderEntry).getLibrary();
//libraryName is null for simple jar entries
if ((libraryName == null || libraryName.toLowerCase().contains("cucumber")) && library != null) {
final VirtualFile[] files = library.getFiles(OrderRootType.CLASSES);
for (VirtualFile file : files) {
final String version = getVersionByFile(file);
if (version != null)
return version;
}
}
}
}
return getSimpleVersionFromMainClass(module);
}
Aggregations