Search in sources :

Example 16 with PackagingElement

use of com.intellij.packaging.elements.PackagingElement 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 PackagingElement

use of com.intellij.packaging.elements.PackagingElement 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)

Example 18 with PackagingElement

use of com.intellij.packaging.elements.PackagingElement in project intellij-plugins by JetBrains.

the class FlashBCOutputSourceItem method createElements.

@NotNull
public List<? extends PackagingElement<?>> createElements(@NotNull final ArtifactEditorContext context) {
    final String outputFilePath = myBc.getActualOutputFilePath();
    final String outputFolderPath = PathUtil.getParentPath(outputFilePath);
    switch(myType) {
        case OutputFile:
            return Collections.singletonList(new FileCopyPackagingElement(outputFilePath));
        case OutputFileAndHtmlWrapper:
            final List<PackagingElement<?>> result = new ArrayList<>();
            result.add(new FileCopyPackagingElement(outputFilePath));
            result.add(new FileCopyPackagingElement(outputFolderPath + "/" + BCUtils.getWrapperFileName(myBc)));
            final VirtualFile wrapperDir = LocalFileSystem.getInstance().findFileByPath(myBc.getWrapperTemplatePath());
            if (wrapperDir != null && wrapperDir.isDirectory()) {
                for (VirtualFile file : wrapperDir.getChildren()) {
                    if (!FlexCommonUtils.HTML_WRAPPER_TEMPLATE_FILE_NAME.equals(file.getName())) {
                        if (file.isDirectory()) {
                            final DirectoryCopyPackagingElement packagingElement = new DirectoryCopyPackagingElement(outputFolderPath + "/" + file.getName());
                            result.add(PackagingElementFactory.getInstance().createParentDirectories(file.getName(), packagingElement));
                        } else {
                            result.add(new FileCopyPackagingElement(outputFolderPath + "/" + file.getName()));
                        }
                    }
                }
            }
            return result;
        case OutputFolderContents:
            return Collections.singletonList(new DirectoryCopyPackagingElement(outputFolderPath));
        default:
            assert false;
            return Collections.emptyList();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) FileCopyPackagingElement(com.intellij.packaging.impl.elements.FileCopyPackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) DirectoryCopyPackagingElement(com.intellij.packaging.impl.elements.DirectoryCopyPackagingElement) DirectoryCopyPackagingElement(com.intellij.packaging.impl.elements.DirectoryCopyPackagingElement) FileCopyPackagingElement(com.intellij.packaging.impl.elements.FileCopyPackagingElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PackagingElement (com.intellij.packaging.elements.PackagingElement)18 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)13 ArrayList (java.util.ArrayList)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 Artifact (com.intellij.packaging.artifacts.Artifact)4 PackagingElementPath (com.intellij.packaging.impl.artifacts.PackagingElementPath)4 DirectoryPackagingElement (com.intellij.packaging.impl.elements.DirectoryPackagingElement)4 NotNull (org.jetbrains.annotations.NotNull)4 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)3 PackagingSourceItem (com.intellij.packaging.ui.PackagingSourceItem)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 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 ArtifactType (com.intellij.packaging.artifacts.ArtifactType)2 PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)2 FileCopyPackagingElement (com.intellij.packaging.impl.elements.FileCopyPackagingElement)2 ModuleOutputPackagingElement (com.intellij.packaging.impl.elements.ModuleOutputPackagingElement)2