Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>dev.morphia.core</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>test-jar</id>
Expand Down
52 changes: 52 additions & 0 deletions core/src/test/java/dev/morphia/test/ModuleMetadataTest.java
Original file line number Diff line number Diff line change
@@ -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> 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);
}
}
17 changes: 16 additions & 1 deletion kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@

<artifactId>morphia-kotlin</artifactId>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>dev.morphia.kotlin</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>dev.morphia.morphia</groupId>
Expand Down Expand Up @@ -47,4 +63,3 @@
</dependency>
</dependencies>
</project>

7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>org.revapi</groupId>
Expand Down