Search in sources :

Example 1 with Artifact

use of com.intellij.packaging.artifacts.Artifact in project azure-tools-for-java by Microsoft.

the class SparkSubmitModel method action.

public void action(@NotNull SparkSubmissionParameter submissionParameter) {
    HDInsightUtil.getJobStatusManager(project).setJobRunningState(true);
    setSubmissionParameters(submissionParameter);
    postEventAction();
    if (isLocalArtifact()) {
        submit();
    } else {
        final List<Artifact> artifacts = new ArrayList<>();
        final Artifact artifact = artifactHashMap.get(submissionParameter.getArtifactName());
        artifacts.add(artifact);
        ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(artifacts);
        ApplicationManager.getApplication().invokeAndWait(new Runnable() {

            @Override
            public void run() {
                final CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts, true);
                CompilerManager.getInstance(project).make(scope, new CompileStatusNotification() {

                    @Override
                    public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
                        if (aborted || errors != 0) {
                            showCompilerErrorMessage(compileContext);
                            HDInsightUtil.getJobStatusManager(project).setJobRunningState(false);
                        } else {
                            postEventProperty.put("IsSubmitSucceed", "true");
                            postEventProperty.put("SubmitFailedReason", "CompileSuccess");
                            AppInsightsClient.create(HDInsightBundle.message("SparkProjectCompileSuccess"), null, postEventProperty);
                            HDInsightUtil.showInfoOnSubmissionMessageWindow(project, String.format("Info : Build %s successfully.", artifact.getOutputFile()));
                            submit();
                        }
                    }
                });
            }
        }, ModalityState.defaultModalityState());
    }
}
Also used : ArtifactCompileScope(com.intellij.packaging.impl.compiler.ArtifactCompileScope) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 2 with Artifact

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

the class ArtifactBySourceFileFinderImpl method computeFileToArtifactsMap.

private MultiValuesMap<VirtualFile, Artifact> computeFileToArtifactsMap() {
    final MultiValuesMap<VirtualFile, Artifact> result = new MultiValuesMap<>();
    final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
    for (final Artifact artifact : artifactManager.getArtifacts()) {
        final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
        ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {

            @Override
            public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
                if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
                    final VirtualFile root = ((FileOrDirectoryCopyPackagingElement) element).findFile();
                    if (root != null) {
                        result.put(root, artifact);
                    }
                } else if (element instanceof ModuleOutputPackagingElement) {
                    for (VirtualFile sourceRoot : ((ModuleOutputPackagingElement) element).getSourceRoots(context)) {
                        result.put(sourceRoot, artifact);
                    }
                }
                return true;
            }
        }, context, true);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiValuesMap(com.intellij.openapi.util.MultiValuesMap) PackagingElementResolvingContext(com.intellij.packaging.elements.PackagingElementResolvingContext) PackagingElement(com.intellij.packaging.elements.PackagingElement) FileOrDirectoryCopyPackagingElement(com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement) ModuleOutputPackagingElement(com.intellij.packaging.impl.elements.ModuleOutputPackagingElement) Artifact(com.intellij.packaging.artifacts.Artifact) ArtifactManager(com.intellij.packaging.artifacts.ArtifactManager) ModuleOutputPackagingElement(com.intellij.packaging.impl.elements.ModuleOutputPackagingElement)

Example 3 with Artifact

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

the class ArtifactsTestUtil method findArtifact.

public static Artifact findArtifact(Project project, String artifactName) {
    final ArtifactManager manager = ArtifactManager.getInstance(project);
    final Artifact artifact = manager.findArtifact(artifactName);
    assertNotNull("'" + artifactName + "' artifact not found", artifact);
    return artifact;
}
Also used : ArtifactManager(com.intellij.packaging.artifacts.ArtifactManager) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 4 with Artifact

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

the class ArtifactsWorkspaceSettings method setArtifactsToBuild.

public void setArtifactsToBuild(@NotNull Collection<? extends Artifact> artifacts) {
    myState.myArtifactsToBuild.clear();
    for (Artifact artifact : artifacts) {
        myState.myArtifactsToBuild.add(artifact.getName());
    }
    Collections.sort(myState.myArtifactsToBuild);
}
Also used : Artifact(com.intellij.packaging.artifacts.Artifact)

Example 5 with Artifact

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

the class ArtifactElementType method getAvailableArtifacts.

@NotNull
public static List<? extends Artifact> getAvailableArtifacts(@NotNull final ArtifactEditorContext context, @NotNull final Artifact artifact, final boolean notIncludedOnly) {
    final Set<Artifact> result = new HashSet<>(Arrays.asList(context.getArtifactModel().getArtifacts()));
    if (notIncludedOnly) {
        ArtifactUtil.processPackagingElements(artifact, ARTIFACT_ELEMENT_TYPE, artifactPackagingElement -> {
            result.remove(artifactPackagingElement.findArtifact(context));
            return true;
        }, context, true);
    }
    result.remove(artifact);
    final Iterator<Artifact> iterator = result.iterator();
    while (iterator.hasNext()) {
        Artifact another = iterator.next();
        final boolean notContainThis = ArtifactUtil.processPackagingElements(another, ARTIFACT_ELEMENT_TYPE, element -> !artifact.getName().equals(element.getArtifactName()), context, true);
        if (!notContainThis) {
            iterator.remove();
        }
    }
    final ArrayList<Artifact> list = new ArrayList<>(result);
    Collections.sort(list, ArtifactManager.ARTIFACT_COMPARATOR);
    return list;
}
Also used : Artifact(com.intellij.packaging.artifacts.Artifact) NotNull(org.jetbrains.annotations.NotNull)

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