}
Set<EarModule> earModules = new LinkedHashSet<EarModule>(artifacts.size());
String defaultBundleDir = getDefaultBundleDirectory();
IProjectFacetVersion javaEEVersion = getEarFacetVersion();
EarModuleFactory earModuleFactory = EarModuleFactory.createEarModuleFactory(getArtifactTypeMappingService(),
getFileNameMapping(), getMainArtifactId(), artifacts);
//Resolve Ear modules from plugin config
earModules.addAll(getEarModulesFromConfig(earModuleFactory, defaultBundleDir, javaEEVersion));
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
//next, add remaining modules from maven project dependencies
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())) { //$NON-NLS-1$
continue;
}
boolean isIncludedInApplicationXml = isIncludeLibInApplicationXml();
// Artifact is not yet registered and it has neither test, nor a
// provided scope, nor is it optional
if(!isArtifactRegistered(artifact, earModules) && filter.include(artifact) && !artifact.isOptional()) {
EarModule module = earModuleFactory.newEarModule(artifact, defaultBundleDir, javaEEVersion, isIncludedInApplicationXml);
if(module != null) {
earModules.add(module);
}
}
}