From 5c41c762dac9a381bd274c549280cdb9a4db01ef Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Thu, 5 Jun 2014 14:46:43 +0400 Subject: [PATCH] Maven: manifest generation fixes - use ApplicationNamesInfo#getFullProductName for "Created-By" attribute value, redundant code removed --- .../idea/maven/utils/ManifestBuilder.java | 18 ++---------------- .../maven/compiler/ManifestGenerationTest.java | 11 ++++++----- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java index eaeacedf72b0..356946b3c63f 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/ManifestBuilder.java @@ -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 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 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 diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java index 7d1b5cd82ff3..6bc55921b1b3 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ManifestGenerationTest.java @@ -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" +