use of org.appformer.maven.integration.ArtifactResolver in project drools by kiegroup.
the class KieRepositoryScannerImpl method loadPomArtifact.
private KieModule loadPomArtifact(ReleaseId releaseId) {
ArtifactResolver resolver = ArtifactResolver.getResolverFor(releaseId, false);
if (resolver == null) {
return null;
}
MemoryKieModule kieModule = new MemoryKieModule(releaseId);
addDependencies(kieModule, resolver, resolver.getPomDirectDependencies(DependencyFilter.COMPILE_FILTER));
kieModule.build();
return kieModule;
}
use of org.appformer.maven.integration.ArtifactResolver in project drools by kiegroup.
the class MavenClassLoaderResolver method getClassLoader.
@Override
public ClassLoader getClassLoader(KieModule kmodule) {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
if (parent == null) {
parent = ClassLoader.getSystemClassLoader();
}
if (parent == null) {
parent = MavenClassLoaderResolver.class.getClassLoader();
}
InternalKieModule internalKModule = (InternalKieModule) kmodule;
Collection<ReleaseId> jarDependencies = internalKModule.getJarDependencies(DependencyFilter.COMPILE_FILTER);
if (jarDependencies.isEmpty()) {
return parent;
}
ArtifactResolver resolver = ArtifactResolver.getResolverFor(internalKModule.getPomModel());
List<URL> urls = new ArrayList<URL>();
List<ReleaseId> unresolvedDeps = new ArrayList<ReleaseId>();
for (ReleaseId rid : jarDependencies) {
try {
Artifact artifact = resolver.resolveArtifact(rid);
if (artifact != null) {
File jar = artifact.getFile();
urls.add(jar.toURI().toURL());
} else {
logger.error("Dependency artifact not found for: " + rid);
unresolvedDeps.add(rid);
}
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
internalKModule.setUnresolvedDependencies(unresolvedDeps);
return new URLClassLoader(urls.toArray(new URL[urls.size()]), parent);
}
Aggregations