diff --git a/core/pom.xml b/core/pom.xml index 7fbd1d7130c..b24f6420d2d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -17,7 +17,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..cb0231c3d11 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/ModuleMetadataTest.java @@ -0,0 +1,52 @@ +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.testng.annotations.Test; + +import static dev.morphia.test.TestBase.GIT_ROOT; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.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"); + } + + 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/kotlin/pom.xml b/kotlin/pom.xml index 1554fef890b..9123058f7c3 100644 --- a/kotlin/pom.xml +++ b/kotlin/pom.xml @@ -12,6 +12,22 @@ morphia-kotlin + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dev.morphia.kotlin + + + + + + + dev.morphia.morphia @@ -47,4 +63,3 @@ - diff --git a/pom.xml b/pom.xml index ac8c7710da6..907ae8f36b6 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,12 @@ -parameters - + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 org.revapi