in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/AbstractNbmMojo.java [162:262]
static List<ModuleWrapper> getModuleDependencyArtifacts(DependencyNode treeRoot, NetBeansModule module,
Dependency[] customDependencies, MavenProject project,
Map<Artifact, ExamineManifest> examinerCache,
List<Artifact> libraryArtifacts, Log log,
boolean useOsgiDependencies)
throws MojoExecutionException {
List<Dependency> deps = new ArrayList<>();
if (customDependencies != null) {
deps.addAll(Arrays.asList(customDependencies));
}
if (module != null && !module.getDependencies().isEmpty()) {
log.warn("dependencies in module descriptor are deprecated, use the plugin's parameter moduleDependencies");
//we need to make sure a dependency is not twice there, module deps override the config
//(as is the case with other configurations)
for (Dependency d : module.getDependencies()) {
Dependency found = null;
for (Dependency d2 : deps) {
if (d2.getId().equals(d.getId())) {
found = d2;
break;
}
}
if (found != null) {
deps.remove(found);
}
deps.add(d);
}
}
List<ModuleWrapper> include = new ArrayList<ModuleWrapper>();
@SuppressWarnings("unchecked")
List<Artifact> artifacts = project.getCompileArtifacts();
for (Artifact artifact : artifacts) {
if (libraryArtifacts.contains(artifact)) {
continue;
}
ExamineManifest depExaminator = examinerCache.get(artifact);
if (depExaminator == null) {
depExaminator = new ExamineManifest(log);
depExaminator.setArtifactFile(artifact.getFile());
depExaminator.checkFile();
examinerCache.put(artifact, depExaminator);
}
Dependency dep = resolveNetBeansDependency(artifact, deps, depExaminator, log);
if (dep != null) {
ModuleWrapper wr = new ModuleWrapper();
wr.dependency = dep;
wr.artifact = artifact;
wr.transitive = false;
//only direct deps matter to us..
if (depExaminator.isNetBeansModule() && artifact.getDependencyTrail().size() > 2) {
log.debug(
artifact.getId()
+ " omitted as NetBeans module dependency, not a direct one. "
+ "Declare it in the pom for inclusion.");
wr.transitive = true;
}
include.add(wr);
} else {
if (useOsgiDependencies && depExaminator.isOsgiBundle()) {
ModuleWrapper wr = new ModuleWrapper();
wr.osgi = true;
String id = artifact.getGroupId() + ":" + artifact.getArtifactId();
for (Dependency depe : deps) {
if (id.equals(depe.getId())) {
wr.dependency = depe;
}
}
boolean print = false;
if (wr.dependency == null) {
Dependency depe = new Dependency();
depe.setId(id);
depe.setType("spec");
wr.dependency = depe;
print = true;
}
wr.artifact = artifact;
wr.transitive = false;
//only direct deps matter to us..
if (artifact.getDependencyTrail().size() > 2) {
log.debug(
artifact.getId()
+ " omitted as NetBeans module OSGi dependency, not a direct one. "
+ "Declare it in the pom for inclusion.");
wr.transitive = true;
} else {
if (print) {
log.info("Adding OSGi bundle dependency - " + id);
}
}
include.add(wr);
}
}
}
return include;
}