forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
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 quarkusio#23332 from glefloch/fix/12889
Add manifest configuration in build mojo/task
- Loading branch information
Showing
13 changed files
with
374 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/dsl/Manifest.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,34 @@ | ||
package io.quarkus.gradle.dsl; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import org.gradle.api.java.archives.Attributes; | ||
import org.gradle.api.java.archives.internal.DefaultAttributes; | ||
|
||
public class Manifest { | ||
|
||
private Attributes attributes = new DefaultAttributes(); | ||
private Map<String, Attributes> sections = new LinkedHashMap<>(); | ||
|
||
public Attributes getAttributes() { | ||
return attributes; | ||
} | ||
|
||
public Map<String, Attributes> getSections() { | ||
return sections; | ||
} | ||
|
||
public Manifest attributes(Map<String, String> attributes) { | ||
this.attributes.putAll(attributes); | ||
return this; | ||
} | ||
|
||
public Manifest attributes(Map<String, String> attributes, String section) { | ||
if (!this.sections.containsKey(section)) { | ||
this.sections.put(section, new DefaultAttributes()); | ||
} | ||
this.sections.get(section).putAll(attributes); | ||
return this; | ||
} | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
devtools/maven/src/main/java/io/quarkus/maven/components/ManifestSection.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,27 @@ | ||
package io.quarkus.maven.components; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public class ManifestSection { | ||
|
||
private String name = null; | ||
private Map<String, String> manifestEntries = new LinkedHashMap<>(); | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setManifestEntries(Map<String, String> manifestEntries) { | ||
this.manifestEntries = manifestEntries; | ||
} | ||
|
||
public Map<String, String> getManifestEntries() { | ||
return manifestEntries; | ||
} | ||
|
||
} |
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
1 change: 1 addition & 0 deletions
1
...le/src/main/resources/custom-config-java-module/src/main/resources/application.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 @@ | ||
quarkus.package.type=uber-jar |
46 changes: 46 additions & 0 deletions
46
integration-tests/gradle/src/test/java/io/quarkus/gradle/CustomManifestArgumentsTest.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.gradle; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import java.util.jar.Attributes; | ||
import java.util.jar.JarInputStream; | ||
import java.util.jar.Manifest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class CustomManifestArgumentsTest extends QuarkusGradleWrapperTestBase { | ||
|
||
@Test | ||
public void shouldContainsSpecificManifestProperty() throws Exception { | ||
File projectDir = getProjectDir("custom-config-java-module"); | ||
|
||
runGradleWrapper(projectDir, "clean", "quarkusBuild"); | ||
|
||
Path buildDir = new File(projectDir, "build").toPath(); | ||
Path jar = buildDir.resolve("code-with-quarkus-1.0.0-SNAPSHOT-runner.jar"); | ||
|
||
assertThat(jar).exists(); | ||
try (InputStream fileInputStream = new FileInputStream(jar.toFile())) { | ||
try (JarInputStream jarStream = new JarInputStream(fileInputStream)) { | ||
Manifest manifest = jarStream.getManifest(); | ||
assertThat(manifest).isNotNull(); | ||
|
||
String customAttribute = manifest.getMainAttributes().getValue("Built-By"); | ||
assertThat(customAttribute).isNotNull(); | ||
assertThat(customAttribute).isEqualTo("quarkus-gradle-plugin"); | ||
|
||
Attributes customSection = manifest.getAttributes("org.acme"); | ||
assertThat(customSection).isNotNull(); | ||
|
||
String sectionAttribute = customSection.getValue("framework"); | ||
assertThat(sectionAttribute).isNotNull(); | ||
assertThat(sectionAttribute).isEqualTo("quarkus"); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.