use of com.intellij.packaging.ui.ManifestFileConfiguration in project intellij-community by JetBrains.
the class DefaultManifestFileProvider method getClasspathFromManifest.
@Override
public List<String> getClasspathFromManifest(@NotNull CompositePackagingElement<?> archiveRoot, @NotNull ArtifactType artifactType) {
final VirtualFile manifestFile = ManifestFileUtil.findManifestFile(archiveRoot, myContext, artifactType);
if (manifestFile == null) {
return null;
}
ManifestFileConfiguration configuration = ManifestFileUtil.createManifestFileConfiguration(manifestFile);
return configuration.getClasspath();
}
use of com.intellij.packaging.ui.ManifestFileConfiguration in project intellij-community by JetBrains.
the class ManifestFileUtil method createManifestFileConfiguration.
@NotNull
public static ManifestFileConfiguration createManifestFileConfiguration(@NotNull VirtualFile manifestFile) {
final String path = manifestFile.getPath();
Manifest manifest = readManifest(manifestFile);
String mainClass = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
final String classpathText = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
final List<String> classpath = new ArrayList<>();
if (classpathText != null) {
classpath.addAll(StringUtil.split(classpathText, " "));
}
return new ManifestFileConfiguration(path, classpath, mainClass, manifestFile.isWritable());
}
use of com.intellij.packaging.ui.ManifestFileConfiguration in project intellij-community by JetBrains.
the class ArtifactEditorImpl method addToClasspath.
@Override
public void addToClasspath(final CompositePackagingElement<?> element, List<String> classpath) {
myLayoutTreeComponent.saveElementProperties();
ManifestFileConfiguration manifest = myContext.getManifestFile(element, getArtifact().getArtifactType());
if (manifest == null) {
final VirtualFile file = ManifestFileUtil.showDialogAndCreateManifest(myContext, element);
if (file == null) {
return;
}
ManifestFileUtil.addManifestFileToLayout(file.getPath(), myContext, element);
manifest = myContext.getManifestFile(element, getArtifact().getArtifactType());
}
if (manifest != null) {
manifest.addToClasspath(classpath);
}
myLayoutTreeComponent.resetElementProperties();
}
use of com.intellij.packaging.ui.ManifestFileConfiguration in project intellij-community by JetBrains.
the class ManifestFilesInfo method saveManifestFiles.
public void saveManifestFiles() {
for (Map.Entry<VirtualFile, ManifestFileConfiguration> entry : myManifestFiles.entrySet()) {
final ManifestFileConfiguration configuration = entry.getValue();
final String path = configuration.getManifestFilePath();
if (path == null)
continue;
final ManifestFileConfiguration original = myOriginalManifestFiles.get(entry.getKey());
if (original != null && original.equals(configuration)) {
continue;
}
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
if (file == null) {
final File ioFile = new File(FileUtil.toSystemDependentName(path));
FileUtil.createIfDoesntExist(ioFile);
file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
if (file == null) {
//todo[nik] improve
LOG.error("cannot create file: " + ioFile);
}
}
ManifestFileUtil.updateManifest(file, configuration.getMainClass(), configuration.getClasspath(), true);
}
}
use of com.intellij.packaging.ui.ManifestFileConfiguration in project intellij-community by JetBrains.
the class ManifestFilesInfo method getManifestFile.
@Nullable
public ManifestFileConfiguration getManifestFile(CompositePackagingElement<?> element, ArtifactType artifactType, final PackagingElementResolvingContext context) {
final VirtualFile manifestFile = ManifestFileUtil.findManifestFile(element, context, artifactType);
if (manifestFile == null) {
return null;
}
ManifestFileConfiguration configuration = myManifestFiles.get(manifestFile);
if (configuration == null) {
configuration = ManifestFileUtil.createManifestFileConfiguration(manifestFile);
myOriginalManifestFiles.put(manifestFile, new ManifestFileConfiguration(configuration));
myManifestFiles.put(manifestFile, configuration);
}
return configuration;
}
Aggregations