use of com.intellij.packaging.elements.CompositePackagingElement in project azure-tools-for-java by Microsoft.
the class HDInsightModuleBuilder method createDefaultArtifact.
private void createDefaultArtifact(final Module module) {
final Project project = module.getProject();
final JarArtifactType type = new JarArtifactType();
final PackagingElementFactory factory = PackagingElementFactory.getInstance();
CompositePackagingElement root = factory.createArchive("default_artifact.jar");
root.addOrFindChild(factory.createModuleOutput(module));
ArtifactManager.getInstance(project).addArtifact(module.getName() + "_DefaultArtifact", type, root);
}
use of com.intellij.packaging.elements.CompositePackagingElement in project intellij-community by JetBrains.
the class ExtractedDirectoryElementType method chooseAndCreate.
@NotNull
public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, true, false, true, true) {
@Override
public boolean isFileSelectable(VirtualFile file) {
if (file.isInLocalFileSystem() && file.isDirectory())
return false;
return super.isFileSelectable(file);
}
};
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, context.getProject(), null);
final List<PackagingElement<?>> list = new ArrayList<>();
final PackagingElementFactory factory = PackagingElementFactory.getInstance();
for (VirtualFile file : files) {
list.add(factory.createExtractedDirectory(file));
}
return list;
}
use of com.intellij.packaging.elements.CompositePackagingElement in project intellij-community by JetBrains.
the class PackageFileWorker method copyFile.
private void copyFile(String outputPath, List<CompositePackagingElement<?>> parents) throws IOException {
if (parents.isEmpty()) {
final String fullOutputPath = DeploymentUtil.appendToPath(outputPath, myRelativeOutputPath);
File target = new File(fullOutputPath);
if (FileUtil.filesEqual(myFile, target)) {
LOG.debug(" skipping copying file to itself");
} else {
LOG.debug(" copying to " + fullOutputPath);
FileUtil.copy(myFile, target);
}
return;
}
final CompositePackagingElement<?> element = parents.get(0);
final String nextOutputPath = outputPath + "/" + element.getName();
final List<CompositePackagingElement<?>> parentsTrail = parents.subList(1, parents.size());
if (element instanceof ArchivePackagingElement) {
if (myPackIntoArchives) {
packFile(nextOutputPath, "", parentsTrail);
}
} else {
copyFile(nextOutputPath, parentsTrail);
}
}
use of com.intellij.packaging.elements.CompositePackagingElement in project intellij-community by JetBrains.
the class PackageFileWorker method packFile.
private void packFile(String archivePath, String pathInArchive, List<CompositePackagingElement<?>> parents) throws IOException {
final File archiveFile = new File(archivePath);
if (parents.isEmpty()) {
LOG.debug(" adding to archive " + archivePath);
JBZipFile file = getOrCreateZipFile(archiveFile);
try {
final String fullPathInArchive = DeploymentUtil.trimForwardSlashes(DeploymentUtil.appendToPath(pathInArchive, myRelativeOutputPath));
final JBZipEntry entry = file.getOrCreateEntry(fullPathInArchive);
entry.setData(FileUtil.loadFileBytes(myFile));
} finally {
file.close();
}
return;
}
final CompositePackagingElement<?> element = parents.get(0);
final String nextPathInArchive = DeploymentUtil.trimForwardSlashes(DeploymentUtil.appendToPath(pathInArchive, element.getName()));
final List<CompositePackagingElement<?>> parentsTrail = parents.subList(1, parents.size());
if (element instanceof ArchivePackagingElement) {
JBZipFile zipFile = getOrCreateZipFile(archiveFile);
try {
final JBZipEntry entry = zipFile.getOrCreateEntry(nextPathInArchive);
LOG.debug(" extracting to temp file: " + nextPathInArchive + " from " + archivePath);
final File tempFile = FileUtil.createTempFile("packageFile" + FileUtil.sanitizeFileName(nextPathInArchive), FileUtilRt.getExtension(PathUtil.getFileName(nextPathInArchive)));
if (entry.getSize() != -1) {
FileUtil.writeToFile(tempFile, entry.getData());
}
packFile(FileUtil.toSystemIndependentName(tempFile.getAbsolutePath()), "", parentsTrail);
entry.setData(FileUtil.loadFileBytes(tempFile));
FileUtil.delete(tempFile);
} finally {
zipFile.close();
}
} else {
packFile(archivePath, nextPathInArchive, parentsTrail);
}
}
use of com.intellij.packaging.elements.CompositePackagingElement in project intellij-community by JetBrains.
the class ModuleOutputElementTypeBase method chooseAndCreate.
@NotNull
public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
List<Module> suitableModules = getSuitableModules(context);
List<Module> selected = context.chooseModules(suitableModules, ProjectBundle.message("dialog.title.packaging.choose.module"));
final List<PackagingElement<?>> elements = new ArrayList<>();
final ModulePointerManager pointerManager = ModulePointerManager.getInstance(context.getProject());
for (Module module : selected) {
elements.add(createElement(context.getProject(), pointerManager.create(module)));
}
return elements;
}
Aggregations