use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.
the class ArtifactTypeMappingServiceTest method testIsMappedToTypeForUnknownType.
public void testIsMappedToTypeForUnknownType() {
ArtifactTypeMappingService service = getDefaultService();
assertFalse(service.isMappedToType("rar", "MyKoolCustomType"));
}
use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.
the class ArtifactTypeMappingServiceTest method testGetStandardTypeForKnownType.
public void testGetStandardTypeForKnownType() {
try {
ArtifactTypeMappingService service = getServiceWithRarMappingToMyRar();
assertEquals("rar", service.getStandardType("MyRar"));
} catch (UnknownArtifactTypeException e) {
fail("Should not have failed to retrieve a knwon custom type " + e.getMessage());
}
}
use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.
the class AbstractEarMojo method execute.
/** {@inheritDoc} */
public void execute() throws MojoExecutionException, MojoFailureException {
final JavaEEVersion javaEEVersion = JavaEEVersion.getJavaEEVersion(version);
getLog().debug("Resolving artifact type mappings ...");
ArtifactTypeMappingService typeMappingService;
try {
typeMappingService = new ArtifactTypeMappingService();
typeMappingService.configure(artifactTypeMappings);
} catch (EarPluginException e) {
throw new MojoExecutionException("Failed to initialize artifact type mappings", e);
} catch (PlexusConfigurationException e) {
throw new MojoExecutionException("Invalid artifact type mappings configuration", e);
}
getLog().debug("Initializing JBoss configuration if necessary ...");
try {
initializeJbossConfiguration();
} catch (EarPluginException e) {
throw new MojoExecutionException("Failed to initialize JBoss configuration", e);
}
getLog().debug("Initializing ear execution context");
EarExecutionContext earExecutionContext = new EarExecutionContext(project, mainArtifactId, defaultLibBundleDir, jbossConfiguration, fileNameMapping, typeMappingService);
if (useBaseVersion != null) {
earExecutionContext.getFileNameMapping().setUseBaseVersion(useBaseVersion);
}
getLog().debug("Resolving ear modules ...");
List<EarModule> allModules = new ArrayList<EarModule>();
try {
if (modules != null && modules.length > 0) {
// Let's validate user-defined modules
EarModule module;
for (EarModule module1 : modules) {
module = module1;
getLog().debug("Resolving ear module[" + module + "]");
module.setEarExecutionContext(earExecutionContext);
module.resolveArtifact(project.getArtifacts());
allModules.add(module);
}
}
// Let's add other modules
Set<Artifact> artifacts = project.getArtifacts();
for (Artifact artifact : artifacts) {
// since it's used for transitive deps only.
if ("pom".equals(artifact.getType())) {
continue;
}
// Artifact is not yet registered and it has not test scope, nor is it optional
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_COMPILE_PLUS_RUNTIME);
if (!isArtifactRegistered(artifact, allModules) && !artifact.isOptional() && filter.include(artifact)) {
EarModule module = EarModuleFactory.newEarModule(artifact, javaEEVersion, defaultLibBundleDir, includeLibInApplicationXml, typeMappingService);
module.setEarExecutionContext(earExecutionContext);
allModules.add(module);
}
}
} catch (EarPluginException e) {
throw new MojoExecutionException("Failed to initialize ear modules", e);
}
// Now we have everything let's built modules which have not been excluded
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
allJarModules = new ArrayList<JarModule>();
earModules = new ArrayList<EarModule>();
for (EarModule earModule : allModules) {
if (earModule.isExcluded()) {
getLog().debug("Skipping ear module[" + earModule + "]");
} else {
if (earModule instanceof JarModule) {
allJarModules.add((JarModule) earModule);
}
if (filter.include(earModule.getArtifact())) {
earModules.add(earModule);
}
}
}
}
use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.
the class ArtifactRepositoryTest method testRepositoryWithMultipleClassifiedArtifacts.
@Test
public void testRepositoryWithMultipleClassifiedArtifacts() {
ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact", "myartifact", "myartifact" }, null, null, new String[] { "class1", "class2", "class3" }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class1"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class2"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class3"));
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "wrong"));
}
use of org.apache.maven.plugins.ear.util.ArtifactTypeMappingService in project maven-plugins by apache.
the class ArtifactRepositoryTest method testRepositoryWithMultipleClassifiedArtifactsAndMainArtifact.
@Test
public void testRepositoryWithMultipleClassifiedArtifactsAndMainArtifact() throws PlexusConfigurationException, EarPluginException {
ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService();
ArtifactRepository repo = new ArtifactRepository(createArtifacts(new String[] { "myartifact", "myartifact", "myartifact" }, null, null, new String[] { "class1", "class2", null }), MAIN_ARTIFACT_ID, artifactTypeMappingService);
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class1"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "class2"));
assertNotNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", MAIN_ARTIFACT_ID));
assertNull(repo.getUniqueArtifact(DEFAULT_GROUPID, "myartifact", "jar", "wrong"));
}
Aggregations