Search in sources :

Example 1 with EarModule

use of org.apache.maven.plugins.ear.EarModule in project maven-plugins by apache.

the class ModuleIdentifierValidator method analyze.

private void analyze() {
    final Map<String, List<EarModule>> newList = new HashMap<String, List<EarModule>>();
    for (EarModule earModule : earModules) {
        String earId = earModule.getArtifact().getArtifactId() + ":" + earModule.getArtifact().getVersion();
        if (newList.containsKey(earId)) {
            newList.get(earId).add(earModule);
        } else {
            List<EarModule> list = new ArrayList<EarModule>();
            list.add(earModule);
            newList.put(earId, list);
        }
    }
    result.clear();
    for (Map.Entry<String, List<EarModule>> item : newList.entrySet()) {
        if (item.getValue().size() > 1) {
            result.put(item.getKey(), item.getValue());
        }
    }
}
Also used : HashMap(java.util.HashMap) EarModule(org.apache.maven.plugins.ear.EarModule) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with EarModule

use of org.apache.maven.plugins.ear.EarModule in project maven-plugins by apache.

the class EarMavenArchiverTest method testSimpleJarModuleWithCustomBundleDir.

@Test
public void testSimpleJarModuleWithCustomBundleDir() {
    final List<EarModule> modules = new ArrayList<EarModule>();
    final EarModule module = new EjbModule(createArtifact("foo", "jar"));
    setUri(module, "libs/foo-1.0.jar");
    modules.add(module);
    final EarMavenArchiver archiver = new EarMavenArchiver(modules);
    assertEquals("libs/foo-1.0.jar", archiver.generateClassPathEntry(""));
}
Also used : ArrayList(java.util.ArrayList) EarModule(org.apache.maven.plugins.ear.EarModule) EjbModule(org.apache.maven.plugins.ear.EjbModule) EarMavenArchiver(org.apache.maven.plugins.ear.util.EarMavenArchiver) Test(org.junit.Test)

Example 3 with EarModule

use of org.apache.maven.plugins.ear.EarModule in project maven-plugins by apache.

the class EarMavenArchiverTest method testSimpleEjbModule.

@Test
public void testSimpleEjbModule() {
    final List<EarModule> modules = new ArrayList<EarModule>();
    final EarModule module = new EjbModule(createArtifact("foo", "ejb"));
    setUri(module, "foo-1.0.jar");
    modules.add(module);
    final EarMavenArchiver archiver = new EarMavenArchiver(modules);
    assertEquals("foo-1.0.jar", archiver.generateClassPathEntry(""));
}
Also used : ArrayList(java.util.ArrayList) EarModule(org.apache.maven.plugins.ear.EarModule) EjbModule(org.apache.maven.plugins.ear.EjbModule) EarMavenArchiver(org.apache.maven.plugins.ear.util.EarMavenArchiver) Test(org.junit.Test)

Example 4 with EarModule

use of org.apache.maven.plugins.ear.EarModule in project maven-plugins by apache.

the class ModuleIdentifierValidatorTest method before.

@Before
public void before() {
    this.earModules = new ArrayList<EarModule>();
    this.miv = new ModuleIdentifierValidator(this.earModules);
}
Also used : EarModule(org.apache.maven.plugins.ear.EarModule) ModuleIdentifierValidator(org.apache.maven.plugins.ear.util.ModuleIdentifierValidator) Before(org.junit.Before)

Example 5 with EarModule

use of org.apache.maven.plugins.ear.EarModule in project maven-plugins by apache.

the class ModuleIdentifierValidatorTest method shouldFailCauseTheArtifactIdsAreIdenticalWithDifferentGroupIds.

@Test
public void shouldFailCauseTheArtifactIdsAreIdenticalWithDifferentGroupIds() {
    EarModule earModule1 = createMockEarModule("org.apache.maven.test", "result-artifact", "1.0.0");
    EarModule earModule2 = createMockEarModule("org.apache.maven", "result-artifact", "1.0.0");
    earModules.add(earModule1);
    earModules.add(earModule2);
    miv.checkForDuplicateArtifacts();
    Map<String, List<EarModule>> result = miv.getDuplicateArtifacts();
    assertFalse(result.isEmpty());
    assertEquals(1, result.size());
    assertTrue(result.containsKey("result-artifact:1.0.0"));
    assertEquals(2, result.get("result-artifact:1.0.0").size());
}
Also used : EarModule(org.apache.maven.plugins.ear.EarModule) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

EarModule (org.apache.maven.plugins.ear.EarModule)9 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 List (java.util.List)4 EjbModule (org.apache.maven.plugins.ear.EjbModule)3 EarMavenArchiver (org.apache.maven.plugins.ear.util.EarMavenArchiver)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Artifact (org.apache.maven.artifact.Artifact)1 ModuleIdentifierValidator (org.apache.maven.plugins.ear.util.ModuleIdentifierValidator)1 Before (org.junit.Before)1