Search in sources :

Example 31 with Artifact

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

the class ArtifactCompileScope method getArtifactsToBuild.

public static Set<Artifact> getArtifactsToBuild(final Project project, final CompileScope compileScope, final boolean addIncludedArtifactsWithOutputPathsOnly) {
    final Artifact[] artifactsFromScope = getArtifacts(compileScope);
    final ArtifactManager artifactManager = ArtifactManager.getInstance(project);
    PackagingElementResolvingContext context = artifactManager.getResolvingContext();
    if (artifactsFromScope != null) {
        return addIncludedArtifacts(Arrays.asList(artifactsFromScope), context, addIncludedArtifactsWithOutputPathsOnly);
    }
    final Set<Artifact> cached = compileScope.getUserData(CACHED_ARTIFACTS_KEY);
    if (cached != null) {
        return cached;
    }
    Set<Artifact> artifacts = new HashSet<>();
    final Set<Module> modules = new HashSet<>(Arrays.asList(compileScope.getAffectedModules()));
    final List<Module> allModules = Arrays.asList(ModuleManager.getInstance(project).getModules());
    for (Artifact artifact : artifactManager.getArtifacts()) {
        if (artifact.isBuildOnMake()) {
            if (modules.containsAll(allModules) || containsModuleOutput(artifact, modules, context)) {
                artifacts.add(artifact);
            }
        }
    }
    Set<Artifact> result = addIncludedArtifacts(artifacts, context, addIncludedArtifactsWithOutputPathsOnly);
    compileScope.putUserData(CACHED_ARTIFACTS_KEY, result);
    return result;
}
Also used : ArtifactManager(com.intellij.packaging.artifacts.ArtifactManager) PackagingElementResolvingContext(com.intellij.packaging.elements.PackagingElementResolvingContext) Module(com.intellij.openapi.module.Module) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 32 with Artifact

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

the class ArtifactCompilerUtil method createOutputToArtifactMap.

public static MultiMap<String, Artifact> createOutputToArtifactMap(final Project project) {
    final MultiMap<String, Artifact> result = MultiMap.create(FileUtil.PATH_HASHING_STRATEGY);
    new ReadAction() {

        protected void run(@NotNull final Result r) {
            for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
                String outputPath = artifact.getOutputFilePath();
                if (!StringUtil.isEmpty(outputPath)) {
                    result.putValue(outputPath, artifact);
                }
            }
        }
    }.execute();
    return result;
}
Also used : ReadAction(com.intellij.openapi.application.ReadAction) Artifact(com.intellij.packaging.artifacts.Artifact) Result(com.intellij.openapi.application.Result)

Example 33 with Artifact

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

the class ArtifactsWorkspaceSettings method getArtifactsToBuild.

public List<Artifact> getArtifactsToBuild() {
    final List<Artifact> result = new ArrayList<>();
    final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
    for (String name : myState.myArtifactsToBuild) {
        ContainerUtil.addIfNotNull(result, artifactManager.findArtifact(name));
    }
    return result;
}
Also used : ArtifactManager(com.intellij.packaging.artifacts.ArtifactManager) ArrayList(java.util.ArrayList) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 34 with Artifact

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

the class ArtifactElementType method chooseAndCreate.

@NotNull
public List<? extends ArtifactPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
    final Project project = context.getProject();
    List<Artifact> artifacts = context.chooseArtifacts(getAvailableArtifacts(context, artifact, false), CompilerBundle.message("dialog.title.choose.artifacts"));
    final List<ArtifactPackagingElement> elements = new ArrayList<>();
    for (Artifact selected : artifacts) {
        elements.add(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(selected, context.getArtifactModel())));
    }
    return elements;
}
Also used : Project(com.intellij.openapi.project.Project) Artifact(com.intellij.packaging.artifacts.Artifact) NotNull(org.jetbrains.annotations.NotNull)

Example 35 with Artifact

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

the class ArtifactPackagingElement method getSubstitution.

public List<? extends PackagingElement<?>> getSubstitution(@NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType) {
    final Artifact artifact = findArtifact(context);
    if (artifact != null) {
        final ArtifactType type = artifact.getArtifactType();
        List<? extends PackagingElement<?>> substitution = type.getSubstitution(artifact, context, artifactType);
        if (substitution != null) {
            return substitution;
        }
        final List<PackagingElement<?>> elements = new ArrayList<>();
        final CompositePackagingElement<?> rootElement = artifact.getRootElement();
        if (rootElement instanceof ArtifactRootElement<?>) {
            elements.addAll(rootElement.getChildren());
        } else {
            elements.add(rootElement);
        }
        return elements;
    }
    return null;
}
Also used : ArtifactType(com.intellij.packaging.artifacts.ArtifactType) 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