Search in sources :

Example 1 with ManifestFileConfiguration

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ManifestFileConfiguration(com.intellij.packaging.ui.ManifestFileConfiguration)

Example 2 with ManifestFileConfiguration

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());
}
Also used : ArrayList(java.util.ArrayList) ManifestFileConfiguration(com.intellij.packaging.ui.ManifestFileConfiguration) Manifest(java.util.jar.Manifest) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ManifestFileConfiguration

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ManifestFileConfiguration(com.intellij.packaging.ui.ManifestFileConfiguration)

Example 4 with ManifestFileConfiguration

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ManifestFileConfiguration(com.intellij.packaging.ui.ManifestFileConfiguration) HashMap(java.util.HashMap) Map(java.util.Map) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 5 with ManifestFileConfiguration

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ManifestFileConfiguration(com.intellij.packaging.ui.ManifestFileConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ManifestFileConfiguration (com.intellij.packaging.ui.ManifestFileConfiguration)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Manifest (java.util.jar.Manifest)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1