diff --git a/annotations/pom.xml b/annotations/pom.xml index bfcaf2d17ab..e1d0d1311c3 100644 --- a/annotations/pom.xml +++ b/annotations/pom.xml @@ -13,6 +13,22 @@ morphia-annotations Morphia Annotations + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dev.morphia.annotations + + + + + + + org.mongodb diff --git a/core/pom.xml b/core/pom.xml index 6fe11ea950d..06371f4587e 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -18,7 +18,13 @@ org.apache.maven.plugins maven-jar-plugin - 3.5.0 + + + + dev.morphia.core + + + test-jar diff --git a/core/src/test/java/dev/morphia/test/ModuleMetadataTest.java b/core/src/test/java/dev/morphia/test/ModuleMetadataTest.java new file mode 100644 index 00000000000..d3bb0581466 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/ModuleMetadataTest.java @@ -0,0 +1,72 @@ +package dev.morphia.test; + +import java.io.File; +import java.io.FileReader; +import java.util.Optional; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.junit.jupiter.api.Test; + +import static dev.morphia.test.TestBase.GIT_ROOT; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ModuleMetadataTest { + @Test + public void coreJarDefinesAutomaticModuleName() throws Exception { + assertAutomaticModuleName("core/pom.xml", "dev.morphia.core"); + } + + @Test + public void kotlinJarDefinesAutomaticModuleName() throws Exception { + assertAutomaticModuleName("kotlin/pom.xml", "dev.morphia.kotlin"); + } + + @Test + public void annotationsJarDefinesAutomaticModuleName() throws Exception { + assertAutomaticModuleName("annotations/pom.xml", "dev.morphia.annotations"); + } + + @Test + public void validationJarDefinesAutomaticModuleName() throws Exception { + assertAutomaticModuleName("validation/pom.xml", "dev.morphia.validation"); + } + + @Test + public void rewriteJarDefinesAutomaticModuleName() throws Exception { + assertAutomaticModuleName("rewrite/pom.xml", "dev.morphia.rewrite"); + } + + @Test + public void critterMavenJarDefinesAutomaticModuleName() throws Exception { + assertAutomaticModuleName("critter/critter-maven/pom.xml", "dev.morphia.critter.maven"); + } + + private static void assertAutomaticModuleName(String path, String expectedValue) throws Exception { + MavenXpp3Reader reader = new MavenXpp3Reader(); + Model model; + try (FileReader fileReader = new FileReader(new File(GIT_ROOT, path).getAbsoluteFile())) { + model = reader.read(fileReader); + } + + Optional plugin = model.getBuild().getPlugins().stream() + .filter(p -> "maven-jar-plugin".equals(p.getArtifactId())) + .findFirst(); + + assertTrue(plugin.isPresent(), "Expected maven-jar-plugin in " + path); + + Xpp3Dom configuration = (Xpp3Dom) plugin.get().getConfiguration(); + assertNotNull(configuration, "Expected maven-jar-plugin configuration in " + path); + Xpp3Dom archive = configuration.getChild("archive"); + assertNotNull(archive, "Expected archive configuration in " + path); + Xpp3Dom manifestEntries = archive.getChild("manifestEntries"); + assertNotNull(manifestEntries, "Expected manifestEntries configuration in " + path); + Xpp3Dom automaticModuleName = manifestEntries.getChild("Automatic-Module-Name"); + assertNotNull(automaticModuleName, "Expected Automatic-Module-Name entry in " + path); + assertEquals(automaticModuleName.getValue(), expectedValue); + } +} diff --git a/critter/critter-maven/pom.xml b/critter/critter-maven/pom.xml index 70cb029f28b..d876f8ec844 100644 --- a/critter/critter-maven/pom.xml +++ b/critter/critter-maven/pom.xml @@ -17,6 +17,17 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + dev.morphia.critter.maven + + + + org.jetbrains.kotlin kotlin-maven-plugin diff --git a/kotlin/pom.xml b/kotlin/pom.xml index e523bbb77ad..12a4fcd4c28 100644 --- a/kotlin/pom.xml +++ b/kotlin/pom.xml @@ -13,6 +13,22 @@ morphia-kotlin Morphia Kotlin + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dev.morphia.kotlin + + + + + + + dev.morphia.morphia @@ -48,4 +64,3 @@ - diff --git a/pom.xml b/pom.xml index f686eb99a3f..c92ce74ae52 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,12 @@ -parameters - + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 org.revapi diff --git a/rewrite/pom.xml b/rewrite/pom.xml index e77da8aee2f..813b7cce6a5 100644 --- a/rewrite/pom.xml +++ b/rewrite/pom.xml @@ -34,6 +34,17 @@ + + org.apache.maven.plugins + maven-jar-plugin + + + + dev.morphia.rewrite + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/validation/pom.xml b/validation/pom.xml index ee1164b7d17..e566f39cc69 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -13,6 +13,22 @@ morphia-validation Morphia Validation + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dev.morphia.validation + + + + + + + dev.morphia.morphia