Maven: manifest generation fixes - use ApplicationNamesInfo#getFullProductName for "Created-By" attribute value, redundant code removed

This commit is contained in:
Vladislav.Soroka
2014-06-05 14:48:25 +04:00
parent d2752f16d9
commit 5c41c762da
2 changed files with 8 additions and 21 deletions
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.maven.utils;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -158,7 +159,7 @@ public class ManifestBuilder {
@NotNull
private Manifest getDefaultManifest(@NotNull Map<String, String> entries) throws ManifestException {
Manifest finalManifest = new Manifest();
addManifestAttribute(finalManifest, entries, "Created-By", "IntelliJ IDEA");
addManifestAttribute(finalManifest, entries, "Created-By", ApplicationNamesInfo.getInstance().getFullProductName());
addManifestAttribute(finalManifest, entries, "Built-By", System.getProperty("user.name"));
if (!StringUtil.isEmpty(myJdkVersion)) {
addManifestAttribute(finalManifest, entries, "Build-Jdk", myJdkVersion);
@@ -182,21 +183,6 @@ public class ManifestBuilder {
}
}
}
Set<String> keys = entries.keySet();
for (String key : keys) {
String value = entries.get(key);
Attribute attr = manifest.getMainSection().getAttribute(key);
if (key.equals("Class-Path") && attr != null) {
// Merge the user-supplied Class-Path value with the programmatically
// generated Class-Path. Note that the user-supplied value goes first
// so that resources there will override any in the standard Class-Path.
attr.setValue(value + " " + attr.getValue());
}
else {
addManifestAttribute(manifest, key, value);
}
}
}
@Nullable
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.maven.compiler;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootManager;
@@ -38,7 +39,7 @@ public class ManifestGenerationTest extends MavenCompilingTestCase {
"Manifest-Version: 1.0\n" +
"Build-Jdk: " + extractJdkVersion(getModule("project")) + "\n" +
"Built-By: " + System.getProperty("user.name") + "\n" +
"Created-By: IntelliJ IDEA");
"Created-By: " + ApplicationNamesInfo.getInstance().getFullProductName());
}
public void testClasspathEntry() throws Exception {
@@ -78,7 +79,7 @@ public class ManifestGenerationTest extends MavenCompilingTestCase {
"Class-Path: lib/other-project-1.jar\n" +
"Build-Jdk: " + extractJdkVersion(getModule("project")) + "\n" +
"Built-By: " + System.getProperty("user.name") + "\n" +
"Created-By: IntelliJ IDEA\n");
"Created-By: " + ApplicationNamesInfo.getInstance().getFullProductName());
}
public void testDefaultEntries() throws Exception {
@@ -119,7 +120,7 @@ public class ManifestGenerationTest extends MavenCompilingTestCase {
"Implementation-Vendor-Id: test\n" +
"Build-Jdk: " + extractJdkVersion(getModule("project")) + "\n" +
"Built-By: " + System.getProperty("user.name") + "\n" +
"Created-By: IntelliJ IDEA\n" +
"Created-By: " + ApplicationNamesInfo.getInstance().getFullProductName() + "\n" +
"Specification-Version: 1");
}
@@ -154,7 +155,7 @@ public class ManifestGenerationTest extends MavenCompilingTestCase {
"Dependencies: some.package\n" +
"Build-Jdk: " + extractJdkVersion(getModule("project")) + "\n" +
"Built-By: " + System.getProperty("user.name") + "\n" +
"Created-By: IntelliJ IDEA");
"Created-By: " + ApplicationNamesInfo.getInstance().getFullProductName());
}
public void testManifestSections() throws Exception {
@@ -195,7 +196,7 @@ public class ManifestGenerationTest extends MavenCompilingTestCase {
"Manifest-Version: 1.0\n" +
"Build-Jdk: " + extractJdkVersion(getModule("project")) + "\n" +
"Built-By: " + System.getProperty("user.name") + "\n" +
"Created-By: IntelliJ IDEA\n" +
"Created-By: " + ApplicationNamesInfo.getInstance().getFullProductName() + "\n" +
"\n" +
"Name: org/test/SomeOther.class\n" +
"Java-Bean: true\n" +