use of com.intellij.openapi.roots.libraries.Library in project intellij-community by JetBrains.
the class JarFromModulesTemplate method addLibraries.
private void addLibraries(Set<Library> libraries, ArtifactRootElement<?> root, CompositePackagingElement<?> archive, List<String> classpath) {
PackagingElementFactory factory = PackagingElementFactory.getInstance();
for (Library library : libraries) {
if (LibraryPackagingElement.getKindForLibrary(library).containsDirectoriesWithClasses()) {
for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) {
if (classesRoot.isInLocalFileSystem()) {
archive.addOrFindChild(factory.createDirectoryCopyWithParentDirectories(classesRoot.getPath(), "/"));
} else {
final PackagingElement<?> child = factory.createFileCopyWithParentDirectories(PathUtil.getLocalFile(classesRoot).getPath(), "/");
root.addOrFindChild(child);
classpath.addAll(ManifestFileUtil.getClasspathForElements(Collections.singletonList(child), myContext, PlainArtifactType.getInstance()));
}
}
} else {
final List<? extends PackagingElement<?>> children = factory.createLibraryElements(library);
classpath.addAll(ManifestFileUtil.getClasspathForElements(children, myContext, PlainArtifactType.getInstance()));
root.addOrFindChildren(children);
}
}
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-community by JetBrains.
the class LibraryElementType method chooseAndCreate.
@NotNull
public List<? extends LibraryPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
final List<Library> selected = context.chooseLibraries(ProjectBundle.message("dialog.title.packaging.choose.library"));
final List<LibraryPackagingElement> elements = new ArrayList<>();
for (Library library : selected) {
elements.add(new LibraryPackagingElement(library.getTable().getTableLevel(), library.getName(), null));
}
return elements;
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-community by JetBrains.
the class LibraryPackagingElement method getSubstitution.
public List<? extends PackagingElement<?>> getSubstitution(@NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType) {
final Library library = findLibrary(context);
if (library != null) {
final VirtualFile[] files = library.getFiles(OrderRootType.CLASSES);
final List<PackagingElement<?>> elements = new ArrayList<>();
for (VirtualFile file : files) {
String localPath = PathUtil.getLocalPath(file);
if (localPath != null) {
final String path = FileUtil.toSystemIndependentName(localPath);
elements.add(file.isDirectory() && file.isInLocalFileSystem() ? new DirectoryCopyPackagingElement(path) : new FileCopyPackagingElement(path));
}
}
return elements;
}
return null;
}
use of com.intellij.openapi.roots.libraries.Library in project intellij-community by JetBrains.
the class LibraryDefinitionsGeneratorFactory method create.
/**
* Create a generator for the specified libary type. It generates a list of library definitions.
*
* @param libraryTable a library table to examine
* @param baseDir base directory for ant build script
* @param comment a comment to use for the library
* @return the created generator or null if there is a nothing to generate
*/
@Nullable
public Generator create(LibraryTable libraryTable, File baseDir, final String comment) {
final Library[] libraries = libraryTable.getLibraries();
if (libraries.length == 0) {
return null;
}
final CompositeGenerator gen = new CompositeGenerator();
gen.add(new Comment(comment), 1);
// sort libraries to ensure stable order of them.
TreeMap<String, Library> sortedLibs = new TreeMap<>();
for (final Library library : libraries) {
final String libraryName = library.getName();
if (!myUsedLibraries.contains(libraryName)) {
continue;
}
sortedLibs.put(BuildProperties.getLibraryPathId(libraryName), library);
}
for (final Library library : sortedLibs.values()) {
final String libraryName = library.getName();
final Path libraryPath = new Path(BuildProperties.getLibraryPathId(libraryName));
genLibraryContent(myProject, myGenOptions, library, baseDir, libraryPath);
gen.add(libraryPath, 1);
}
return gen.getGeneratorCount() > 0 ? gen : null;
}
use of com.intellij.openapi.roots.libraries.Library in project azure-tools-for-java by Microsoft.
the class SparkLibraryOptionsPanel method calculateSuitableLibraries.
private List<Library> calculateSuitableLibraries() {
ArrayList suitableLibraries = new ArrayList();
Library[] libraries = this.librariesContainer.getAllLibraries();
for (int i = 0; i < libraries.length; ++i) {
Library library = libraries[i];
PersistentLibraryKind type = ((LibraryEx) library).getKind();
if (type != null && type instanceof SparkLibraryKind) {
suitableLibraries.add(library);
}
}
return suitableLibraries;
}
Aggregations