use of com.intellij.packaging.elements.PackagingElement 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.PackagingElement 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());
}
}
use of com.intellij.packaging.elements.PackagingElement in project intellij-plugins by JetBrains.
the class FlashBCOutputSourceItem method createElements.
@NotNull
public List<? extends PackagingElement<?>> createElements(@NotNull final ArtifactEditorContext context) {
final String outputFilePath = myBc.getActualOutputFilePath();
final String outputFolderPath = PathUtil.getParentPath(outputFilePath);
switch(myType) {
case OutputFile:
return Collections.singletonList(new FileCopyPackagingElement(outputFilePath));
case OutputFileAndHtmlWrapper:
final List<PackagingElement<?>> result = new ArrayList<>();
result.add(new FileCopyPackagingElement(outputFilePath));
result.add(new FileCopyPackagingElement(outputFolderPath + "/" + BCUtils.getWrapperFileName(myBc)));
final VirtualFile wrapperDir = LocalFileSystem.getInstance().findFileByPath(myBc.getWrapperTemplatePath());
if (wrapperDir != null && wrapperDir.isDirectory()) {
for (VirtualFile file : wrapperDir.getChildren()) {
if (!FlexCommonUtils.HTML_WRAPPER_TEMPLATE_FILE_NAME.equals(file.getName())) {
if (file.isDirectory()) {
final DirectoryCopyPackagingElement packagingElement = new DirectoryCopyPackagingElement(outputFolderPath + "/" + file.getName());
result.add(PackagingElementFactory.getInstance().createParentDirectories(file.getName(), packagingElement));
} else {
result.add(new FileCopyPackagingElement(outputFolderPath + "/" + file.getName()));
}
}
}
}
return result;
case OutputFolderContents:
return Collections.singletonList(new DirectoryCopyPackagingElement(outputFolderPath));
default:
assert false;
return Collections.emptyList();
}
}
Aggregations