Search in sources :

Example 41 with Artifact

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

the class AppEngineFacetImporter method reimportFacet.

@Override
protected void reimportFacet(IdeModifiableModelsProvider modelsProvider, Module module, MavenRootModelAdapter rootModel, AppEngineFacet facet, MavenProjectsTree mavenTree, MavenProject mavenProject, MavenProjectChanges changes, Map<MavenProject, String> mavenProjectToModuleName, List<MavenProjectsProcessorTask> postTasks) {
    String version = getVersion(mavenProject);
    if (version != null) {
        String relativePath = "/com/google/appengine/appengine-java-sdk/" + version + "/appengine-java-sdk/appengine-java-sdk-" + version;
        facet.getConfiguration().setSdkHomePath(FileUtil.toSystemIndependentName(mavenProject.getLocalRepository().getPath()) + relativePath);
        AppEngineWebIntegration.getInstance().setupDevServer(facet.getSdk());
        final String artifactName = module.getName() + ":war exploded";
        final Artifact webArtifact = modelsProvider.getModifiableArtifactModel().findArtifact(artifactName);
        AppEngineWebIntegration.getInstance().setupRunConfiguration(facet.getSdk(), webArtifact, module.getProject());
    }
}
Also used : Artifact(com.intellij.packaging.artifacts.Artifact) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact)

Example 42 with Artifact

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

the class ExternalSystemTestCase method assertArtifactOutput.

protected void assertArtifactOutput(String artifactName, TestFileSystemItem fs) {
    final Artifact artifact = ArtifactsTestUtil.findArtifact(myProject, artifactName);
    final String outputFile = artifact.getOutputFilePath();
    assert outputFile != null;
    final File file = new File(outputFile);
    assert file.exists();
    fs.assertFileEqual(file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 43 with Artifact

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

the class PutSourceItemIntoParentAndLinkViaManifestAction method findParentAndGrandParent.

@Nullable
private ParentElementsInfo findParentAndGrandParent(Artifact artifact) {
    final Ref<ParentElementsInfo> result = Ref.create(null);
    ArtifactUtil.processParents(artifact, myArtifactEditor.getContext(), new ParentElementProcessor() {

        @Override
        public boolean process(@NotNull CompositePackagingElement<?> element, @NotNull List<Pair<Artifact, CompositePackagingElement<?>>> parents, @NotNull Artifact artifact) {
            if (parents.size() == 1) {
                final Pair<Artifact, CompositePackagingElement<?>> parent = parents.get(0);
                result.set(new ParentElementsInfo(parent.getFirst(), parent.getSecond(), artifact, element));
                return false;
            }
            return true;
        }
    }, 1);
    return result.get();
}
Also used : ParentElementProcessor(com.intellij.packaging.impl.artifacts.ParentElementProcessor) Artifact(com.intellij.packaging.artifacts.Artifact) Pair(com.intellij.openapi.util.Pair) Nullable(org.jetbrains.annotations.Nullable)

Example 44 with Artifact

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

the class PutSourceItemIntoParentAndLinkViaManifestAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final List<PackagingSourceItem> items = mySourceItemsTree.getSelectedItems();
    ParentElementsInfo parentsInfo = findParentAndGrandParent(myArtifactEditor.getArtifact());
    if (parentsInfo == null) {
        return;
    }
    final Artifact artifact = parentsInfo.getGrandparentArtifact();
    final ArtifactEditorContext context = myArtifactEditor.getContext();
    //todo[nik] improve
    final Runnable emptyRunnable = EmptyRunnable.getInstance();
    context.editLayout(artifact, emptyRunnable);
    context.editLayout(parentsInfo.getParentArtifact(), emptyRunnable);
    //find elements under modifiable root
    parentsInfo = findParentAndGrandParent(myArtifactEditor.getArtifact());
    if (parentsInfo == null) {
        return;
    }
    final CompositePackagingElement<?> grandParent = parentsInfo.getGrandparentElement();
    final List<String> classpath = new ArrayList<>();
    context.editLayout(artifact, () -> {
        for (PackagingSourceItem item : items) {
            final List<? extends PackagingElement<?>> elements = item.createElements(context);
            grandParent.addOrFindChildren(elements);
            classpath.addAll(ManifestFileUtil.getClasspathForElements(elements, context, artifact.getArtifactType()));
        }
    });
    final ArtifactEditor parentArtifactEditor = context.getOrCreateEditor(parentsInfo.getParentArtifact());
    parentArtifactEditor.addToClasspath(parentsInfo.getParentElement(), classpath);
    ((ArtifactEditorImpl) context.getOrCreateEditor(parentsInfo.getGrandparentArtifact())).rebuildTries();
}
Also used : PackagingSourceItem(com.intellij.packaging.ui.PackagingSourceItem) ArtifactEditor(com.intellij.packaging.ui.ArtifactEditor) ArrayList(java.util.ArrayList) Artifact(com.intellij.packaging.artifacts.Artifact) EmptyRunnable(com.intellij.openapi.util.EmptyRunnable) ArtifactEditorImpl(com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactEditorImpl) ArtifactEditorContext(com.intellij.packaging.ui.ArtifactEditorContext)

Example 45 with Artifact

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

the class ModuleSourceItemGroup method createElements.

@Override
@NotNull
public List<? extends PackagingElement<?>> createElements(@NotNull ArtifactEditorContext context) {
    final Set<Module> modules = new LinkedHashSet<>();
    collectDependentModules(myModule, modules, context);
    final Artifact artifact = context.getArtifact();
    final ArtifactType artifactType = artifact.getArtifactType();
    Set<PackagingSourceItem> items = new LinkedHashSet<>();
    for (Module module : modules) {
        for (PackagingSourceItemsProvider provider : PackagingSourceItemsProvider.EP_NAME.getExtensions()) {
            final ModuleSourceItemGroup parent = new ModuleSourceItemGroup(module);
            for (PackagingSourceItem sourceItem : provider.getSourceItems(context, artifact, parent)) {
                if (artifactType.isSuitableItem(sourceItem) && sourceItem.isProvideElements()) {
                    items.add(sourceItem);
                }
            }
        }
    }
    List<PackagingElement<?>> result = new ArrayList<>();
    final PackagingElementFactory factory = PackagingElementFactory.getInstance();
    for (PackagingSourceItem item : items) {
        final String path = artifactType.getDefaultPathFor(item.getKindOfProducedElements());
        if (path != null) {
            result.addAll(factory.createParentDirectories(path, item.createElements(context)));
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) PackagingElement(com.intellij.packaging.elements.PackagingElement) Artifact(com.intellij.packaging.artifacts.Artifact) ArtifactType(com.intellij.packaging.artifacts.ArtifactType) PackagingElementFactory(com.intellij.packaging.elements.PackagingElementFactory) Module(com.intellij.openapi.module.Module) 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