Search in sources :

Example 1 with ManifestImporter

use of org.jetbrains.idea.maven.importing.ManifestImporter in project intellij-community by JetBrains.

the class ManifestBuilder method getConfiguredManifest.

@NotNull
private static Manifest getConfiguredManifest(@NotNull MavenProject mavenProject, @Nullable Element manifestConfiguration, @NotNull Map<String, String> entries) throws ManifestException {
    final Manifest manifest = new Manifest();
    boolean isAddDefaultSpecificationEntries = Boolean.valueOf(MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "addDefaultSpecificationEntries", "false"));
    if (isAddDefaultSpecificationEntries) {
        addManifestAttribute(manifest, entries, "Specification-Title", mavenProject.getName());
        addManifestAttribute(manifest, entries, "Specification-Version", mavenProject.getMavenId().getVersion());
    }
    boolean isAddDefaultImplementationEntries = Boolean.valueOf(MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "addDefaultImplementationEntries", "false"));
    if (isAddDefaultImplementationEntries) {
        addManifestAttribute(manifest, entries, "Implementation-Title", mavenProject.getName());
        addManifestAttribute(manifest, entries, "Implementation-Version", mavenProject.getMavenId().getVersion());
        addManifestAttribute(manifest, entries, "Implementation-Vendor-Id", mavenProject.getMavenId().getGroupId());
    }
    String packageName = MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "packageName");
    if (packageName != null) {
        addManifestAttribute(manifest, entries, "Package", packageName);
    }
    String mainClass = MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "mainClass");
    if (!StringUtil.isEmpty(mainClass)) {
        addManifestAttribute(manifest, entries, "Main-Class", mainClass);
    }
    boolean isAddClasspath = Boolean.valueOf(MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "addClasspath", "false"));
    if (isAddClasspath) {
        final ManifestImporter manifestImporter = ManifestImporter.getManifestImporter(mavenProject.getPackaging());
        String classpath = manifestImporter.getClasspath(mavenProject, manifestConfiguration);
        if (!classpath.isEmpty()) {
            addManifestAttribute(manifest, "Class-Path", classpath);
        }
    }
    return manifest;
}
Also used : Manifest(org.codehaus.plexus.archiver.jar.Manifest) ManifestImporter(org.jetbrains.idea.maven.importing.ManifestImporter) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ManifestImporter

use of org.jetbrains.idea.maven.importing.ManifestImporter in project intellij-community by JetBrains.

the class ManifestBuilder method getClasspath.

@NotNull
public static String getClasspath(@NotNull MavenProject mavenProject) {
    Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(mavenProject);
    final Element mavenArchiveConfiguration = mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null;
    final Element manifestConfiguration = mavenArchiveConfiguration != null ? mavenArchiveConfiguration.getChild("manifest") : null;
    final ManifestImporter manifestImporter = ManifestImporter.getManifestImporter(mavenProject.getPackaging());
    return manifestImporter.getClasspath(mavenProject, manifestConfiguration);
}
Also used : Element(org.jdom.Element) ManifestImporter(org.jetbrains.idea.maven.importing.ManifestImporter) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)2 ManifestImporter (org.jetbrains.idea.maven.importing.ManifestImporter)2 Manifest (org.codehaus.plexus.archiver.jar.Manifest)1 Element (org.jdom.Element)1