in src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java [158:250]
public void execute() throws MojoExecutionException, MojoFailureException {
if (fileNameMapping != null) {
getLog().error("fileNameMapping has been removed with version 3.0.0. You are still using it.");
getLog().error("Use outputFileNameMapping instead.");
throw new MojoExecutionException(
"fileNameMapping has been removed with version 3.0.0 " + "but you are still using it.");
}
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,
outputFileNameMapping,
typeMappingService);
getLog().debug("Resolving ear modules ...");
List<EarModule> allModules = new ArrayList<>();
try {
if (modules != null) {
// Let's validate user-defined modules
for (EarModule module : modules) {
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) {
// If the artifact's type is POM, ignore and continue
// 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 build modules which have not been excluded
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
allEarModules = new ArrayList<>();
providedEarModules = new ArrayList<>();
earModules = new ArrayList<>();
for (EarModule earModule : allModules) {
if (earModule.isExcluded()) {
getLog().debug("Skipping ear module[" + earModule + "]");
} else {
allEarModules.add(earModule);
if (filter.include(earModule.getArtifact())) {
earModules.add(earModule);
} else {
providedEarModules.add(earModule);
}
}
}
}