use of org.kie.util.maven.support.DependencyFilter in project drools by kiegroup.
the class InJarArtifactResolver method buildPomParser.
private PomParser buildPomParser(ReleaseId releaseId) {
List<URL> url = effectivePoms.stream().filter(e -> e.getFile().endsWith(toFile(releaseId, "pom"))).collect(toList());
if (url.isEmpty()) {
return null;
}
String path = url.get(0).toExternalForm();
URL pomFile = classLoader.getResource(path);
if (pomFile == null) {
log.warn("Maven pom not found in path {}", path);
return null;
}
try (InputStream pomStream = pomFile.openStream()) {
DefaultModelReader reader = new DefaultModelReader();
Model model = reader.read(pomStream, Collections.emptyMap());
// dependencies were resolved already creating the effective pom during kjar creation
return new PomParser() {
@Override
public List<DependencyDescriptor> getPomDirectDependencies(DependencyFilter filter) {
List<DependencyDescriptor> deps = new ArrayList<DependencyDescriptor>();
for (Dependency dep : model.getDependencies()) {
DependencyDescriptor depDescr = new DependencyDescriptor(dep);
if (depDescr.isValid() && filter.accept(depDescr.getReleaseId(), depDescr.getScope())) {
deps.add(depDescr);
}
}
return deps;
}
};
} catch (Exception e) {
log.error("Could not read pom in jar {}", pomFile);
return null;
}
}
use of org.kie.util.maven.support.DependencyFilter in project drools by kiegroup.
the class KieInJarModuleMetaDataImpl method init.
private void init(ArtifactResolver artifactResolver) {
if (artifactResolver == null) {
return;
}
List<ReleaseId> releasesId = new ArrayList<>();
if (releaseId != null) {
releasesId.add(releaseId);
}
if (kieModule != null && kieModule.getPomModel() != null) {
releasesId.addAll(kieModule.getPomModel().getDependencies(dependencyFilter));
} else {
List<ReleaseId> dependencies = artifactResolver.getAllDependecies(dependencyFilter).stream().map(e -> e.getReleaseId()).collect(toList());
releasesId.addAll(dependencies);
}
for (ReleaseId rId : releasesId) {
ArtifactResolver.ArtifactLocation artifactLocation = artifactResolver.resolveArtifactLocation(rId);
addArtifact(artifactLocation);
}
packages.addAll(classes.keySet());
packages.addAll(rulesByPackage.keySet());
}
Aggregations