Search in sources :

Example 36 with Artifact

use of com.intellij.packaging.artifacts.Artifact 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 37 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.

the class ArtifactProblemsHolderImpl method registerProblem.

private void registerProblem(@NotNull String message, @Nullable List<PackagingElement<?>> pathToPlace, final ProjectStructureProblemType problemType, @NotNull ArtifactProblemQuickFix... quickFixes) {
    String parentPath;
    PackagingElement<?> element;
    if (pathToPlace != null && !pathToPlace.isEmpty()) {
        parentPath = PackagingElementPath.createPath(pathToPlace.subList(1, pathToPlace.size() - 1)).getPathString();
        element = pathToPlace.get(pathToPlace.size() - 1);
    } else {
        parentPath = null;
        element = null;
    }
    final Artifact artifact = myContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
    final PlaceInArtifact place = new PlaceInArtifact(artifact, myContext, parentPath, element);
    myProblemsHolder.registerProblem(new ArtifactProblemDescription(message, problemType, pathToPlace, place, convertQuickFixes(quickFixes)));
}
Also used : Artifact(com.intellij.packaging.artifacts.Artifact)

Example 38 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.

the class ArtifactProjectStructureElement method getUsagesInElement.

@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
    final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
    final List<ProjectStructureElementUsage> usages = new ArrayList<>();
    final CompositePackagingElement<?> rootElement = myArtifactsStructureContext.getRootElement(artifact);
    ArtifactUtil.processPackagingElements(rootElement, null, new PackagingElementProcessor<PackagingElement<?>>() {

        @Override
        public boolean process(@NotNull PackagingElement<?> packagingElement, @NotNull PackagingElementPath path) {
            ProjectStructureElement element = getProjectStructureElementFor(packagingElement, ArtifactProjectStructureElement.this.myContext, ArtifactProjectStructureElement.this.myArtifactsStructureContext);
            if (element != null) {
                usages.add(createUsage(packagingElement, element, path.getPathStringFrom("/", rootElement)));
            }
            return true;
        }
    }, myArtifactsStructureContext, false, artifact.getArtifactType());
    return usages;
}
Also used : PackagingElementPath(com.intellij.packaging.impl.artifacts.PackagingElementPath) ArrayList(java.util.ArrayList) ArtifactPackagingElement(com.intellij.packaging.impl.elements.ArtifactPackagingElement) LibraryPackagingElement(com.intellij.packaging.impl.elements.LibraryPackagingElement) FacetBasedPackagingElement(com.intellij.packaging.impl.elements.FacetBasedPackagingElement) PackagingElement(com.intellij.packaging.elements.PackagingElement) CompositePackagingElement(com.intellij.packaging.elements.CompositePackagingElement) ModuleOutputPackagingElement(com.intellij.packaging.impl.elements.ModuleOutputPackagingElement) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 39 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.

the class UiDesignerExternalBuildTest method testCopyFormsRuntimeToArtifact.

//IDEA-94779
public void testCopyFormsRuntimeToArtifact() throws IOException {
    VirtualFile file = createFile("src/A.java", "class A{}");
    VirtualFile srcRoot = file.getParent();
    Module module = addModule("a", srcRoot);
    Artifact a = addArtifact(root().module(module));
    make(a);
    assertOutput(a, fs().file("A.class"));
    File dir = PathManagerEx.findFileUnderCommunityHome("plugins/ui-designer/testData/build/copyFormsRuntimeToArtifact");
    FileUtil.copyDir(dir, VfsUtilCore.virtualToIoFile(srcRoot));
    srcRoot.refresh(false, false);
    make(a);
    File outputDir = VfsUtilCore.virtualToIoFile(getOutputDir(a));
    assertTrue(new File(outputDir, "A.class").exists());
    assertTrue(new File(outputDir, "B.class").exists());
    assertTrue(new File(outputDir, AbstractLayout.class.getName().replace('.', '/') + ".class").exists());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Module(com.intellij.openapi.module.Module) AbstractLayout(com.intellij.uiDesigner.core.AbstractLayout) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 40 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.

the class AppEngineUtil method collectAppEngineArtifacts.

public static List<Artifact> collectAppEngineArtifacts(@NotNull Project project, final boolean withAppEngineFacetOnly) {
    final List<Artifact> artifacts = new ArrayList<>();
    if (project.isDefault())
        return artifacts;
    for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
        if (AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactTypes().contains(artifact.getArtifactType()) && (!withAppEngineFacetOnly || findAppEngineFacet(project, artifact) != null)) {
            artifacts.add(artifact);
        }
    }
    Collections.sort(artifacts, ArtifactManager.ARTIFACT_COMPARATOR);
    return artifacts;
}
Also used : ArrayList(java.util.ArrayList) Artifact(com.intellij.packaging.artifacts.Artifact)

Aggregations

Artifact (com.intellij.packaging.artifacts.Artifact)52 ArrayList (java.util.ArrayList)13 Project (com.intellij.openapi.project.Project)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Module (com.intellij.openapi.module.Module)7 NotNull (org.jetbrains.annotations.NotNull)6 ArtifactManager (com.intellij.packaging.artifacts.ArtifactManager)5 File (java.io.File)5 PackagingElement (com.intellij.packaging.elements.PackagingElement)4 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)4 ArtifactPackagingElement (com.intellij.packaging.impl.elements.ArtifactPackagingElement)4 Nullable (org.jetbrains.annotations.Nullable)4 ArtifactType (com.intellij.packaging.artifacts.ArtifactType)3 PackagingElementPath (com.intellij.packaging.impl.artifacts.PackagingElementPath)3 ReadAction (com.intellij.openapi.application.ReadAction)2 Result (com.intellij.openapi.application.Result)2 Pair (com.intellij.openapi.util.Pair)2 ModifiableArtifactModel (com.intellij.packaging.artifacts.ModifiableArtifactModel)2 CompositePackagingElement (com.intellij.packaging.elements.CompositePackagingElement)2 PackagingElementFactory (com.intellij.packaging.elements.PackagingElementFactory)2