Search in sources :

Example 16 with CompositePackagingElement

use of com.intellij.packaging.elements.CompositePackagingElement in project intellij-community by JetBrains.

the class ManifestFileUtil method suggestManifestFileDirectory.

@Nullable
public static VirtualFile suggestManifestFileDirectory(@NotNull CompositePackagingElement<?> root, PackagingElementResolvingContext context, ArtifactType artifactType) {
    final VirtualFile metaInfDir = ArtifactUtil.findSourceFileByOutputPath(root, MANIFEST_DIR_NAME, context, artifactType);
    if (metaInfDir != null) {
        return metaInfDir;
    }
    final Ref<VirtualFile> sourceDir = Ref.create(null);
    final Ref<VirtualFile> sourceFile = Ref.create(null);
    ArtifactUtil.processElementsWithSubstitutions(root.getChildren(), context, artifactType, PackagingElementPath.EMPTY, new PackagingElementProcessor<PackagingElement<?>>() {

        @Override
        public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
            if (element instanceof FileCopyPackagingElement) {
                final VirtualFile file = ((FileCopyPackagingElement) element).findFile();
                if (file != null) {
                    sourceFile.set(file);
                }
            } else if (element instanceof DirectoryCopyPackagingElement) {
                final VirtualFile file = ((DirectoryCopyPackagingElement) element).findFile();
                if (file != null) {
                    sourceDir.set(file);
                    return false;
                }
            }
            return true;
        }
    });
    if (!sourceDir.isNull()) {
        return sourceDir.get();
    }
    final Project project = context.getProject();
    return suggestBaseDir(project, sourceFile.get());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) PackagingElementPath(com.intellij.packaging.impl.artifacts.PackagingElementPath) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with CompositePackagingElement

use of com.intellij.packaging.elements.CompositePackagingElement in project intellij-community by JetBrains.

the class ArtifactExternalDependenciesImporterImpl method applyChanges.

@Override
public void applyChanges(ModifiableArtifactModel artifactModel, final PackagingElementResolvingContext context) {
    myManifestFiles.saveManifestFiles();
    final List<Pair<? extends CompositePackagingElement<?>, List<PackagingElement<?>>>> elementsToInclude = new ArrayList<>();
    for (Artifact artifact : artifactModel.getArtifacts()) {
        ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.ARTIFACT_ELEMENT_TYPE, new PackagingElementProcessor<ArtifactPackagingElement>() {

            @Override
            public boolean process(@NotNull ArtifactPackagingElement artifactPackagingElement, @NotNull PackagingElementPath path) {
                final Artifact included = artifactPackagingElement.findArtifact(context);
                final CompositePackagingElement<?> parent = path.getLastParent();
                if (parent != null && included != null) {
                    final List<PackagingElement<?>> elements = myExternalDependencies.get(included);
                    if (elements != null) {
                        elementsToInclude.add(Pair.create(parent, elements));
                    }
                }
                return true;
            }
        }, context, false);
    }
    for (Pair<? extends CompositePackagingElement<?>, List<PackagingElement<?>>> pair : elementsToInclude) {
        pair.getFirst().addOrFindChildren(pair.getSecond());
    }
}
Also used : ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) PackagingElementPath(com.intellij.packaging.impl.artifacts.PackagingElementPath) ArrayList(java.util.ArrayList) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) ArrayList(java.util.ArrayList) List(java.util.List) Artifact(com.intellij.packaging.artifacts.Artifact) Pair(com.intellij.openapi.util.Pair)

Aggregations

CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)17 PackagingElement (com.intellij.packaging.elements.PackagingElement)13 ArrayList (java.util.ArrayList)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 DirectoryPackagingElement (com.intellij.packaging.impl.elements.DirectoryPackagingElement)4 Project (com.intellij.openapi.project.Project)3 PackagingElementPath (com.intellij.packaging.impl.artifacts.PackagingElementPath)3 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)3 LayoutTreeComponent (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeComponent)2 LayoutTreeSelection (com.intellij.openapi.roots.ui.configuration.artifacts.LayoutTreeSelection)2 CompositePackagingElementNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.CompositePackagingElementNode)2 PackagingElementNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode)2 Artifact (com.intellij.packaging.artifacts.Artifact)2 PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)2 ArchivePackagingElement (com.intellij.packaging.impl.elements.ArchivePackagingElement)2 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)2 JBZipFile (com.intellij.util.io.zip.JBZipFile)2 File (java.io.File)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 NotNull (org.jetbrains.annotations.NotNull)2