use of com.intellij.packaging.elements.CompositePackagingElement 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());
}
use of com.intellij.packaging.elements.CompositePackagingElement 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());
}
}
Aggregations