-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23147 from glefloch/fix/manifest-add-attr
Add the ability to specify main MANIFEST.MF attributes from configuration
- Loading branch information
Showing
6 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...tion-tests/packaging/src/test/java/io/quarkus/maven/CustomManifestEntriesThinJarTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.maven; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import java.util.jar.JarInputStream; | ||
import java.util.jar.Manifest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class CustomManifestEntriesThinJarTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withEmptyApplication() | ||
.setApplicationName("Custom-Manifest-Thin") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("projects/custom-manifest-section/custom-entries-thin.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void testManifestEntries() throws Exception { | ||
assertThat(prodModeTestResults.getResults()).hasSize(1); | ||
Path jarPath = prodModeTestResults.getResults().get(0).getPath(); | ||
|
||
try (InputStream fileInputStream = new FileInputStream(jarPath.toFile())) { | ||
try (JarInputStream stream = new JarInputStream(fileInputStream)) { | ||
Manifest manifest = stream.getManifest(); | ||
assertThat(manifest).isNotNull(); | ||
|
||
String customAttribute = manifest.getMainAttributes().getValue("Built-By"); | ||
assertThat(customAttribute).isNotNull(); | ||
assertThat(customAttribute).isEqualTo("Quarkus Plugin"); | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...tion-tests/packaging/src/test/java/io/quarkus/maven/CustomManifestEntriesUberJarTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.maven; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import java.util.jar.JarInputStream; | ||
import java.util.jar.Manifest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class CustomManifestEntriesUberJarTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withEmptyApplication() | ||
.setApplicationName("Custom-Manifest-Uber") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("projects/custom-manifest-section/custom-entries-uber.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void testManifestEntries() throws Exception { | ||
assertThat(prodModeTestResults.getResults()).hasSize(1); | ||
Path jarPath = prodModeTestResults.getResults().get(0).getPath(); | ||
|
||
try (InputStream fileInputStream = new FileInputStream(jarPath.toFile())) { | ||
try (JarInputStream stream = new JarInputStream(fileInputStream)) { | ||
Manifest manifest = stream.getManifest(); | ||
assertThat(manifest).isNotNull(); | ||
|
||
String customAttribute = manifest.getMainAttributes().getValue("Built-By"); | ||
assertThat(customAttribute).isNotNull(); | ||
assertThat(customAttribute).isEqualTo("Quarkus Plugin"); | ||
} | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...kaging/src/test/resources/projects/custom-manifest-section/custom-entries-thin.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkus.package.type=jar | ||
quarkus.package.manifest.attributes."Built-By"=Quarkus Plugin |
2 changes: 2 additions & 0 deletions
2
...kaging/src/test/resources/projects/custom-manifest-section/custom-entries-uber.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkus.package.type=uber-jar | ||
quarkus.package.manifest.attributes."Built-By"=Quarkus Plugin |