in uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/util/Util.java [124:170]
public static URLClassLoader getClassloader(MavenProject aProject, Log aLog,
String aIncludeScopeThreshold) throws MojoExecutionException {
List<URL> urls = new ArrayList<URL>();
try {
for (Object object : aProject.getCompileClasspathElements()) {
String path = (String) object;
aLog.debug("Classpath entry: " + object);
urls.add(new File(path).toURI().toURL());
}
} catch (IOException e) {
throw new MojoExecutionException(
"Unable to assemble classpath: " + ExceptionUtils.getRootCauseMessage(e), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(
"Unable to resolve dependencies: " + ExceptionUtils.getRootCauseMessage(e), e);
}
ScopeArtifactFilter filter = new ScopeArtifactFilter(aIncludeScopeThreshold);
for (Artifact dep : (Set<Artifact>) aProject.getArtifacts()) {
try {
if (!filter.include(dep)) {
aLog.debug("Not generating classpath entry for out-of-scope artifact: " + dep.getGroupId()
+ ":" + dep.getArtifactId() + ":" + dep.getVersion() + " (" + dep.getScope()
+ ")");
continue;
}
if (dep.getFile() == null) {
aLog.debug("Not generating classpath entry for unresolved artifact: " + dep.getGroupId()
+ ":" + dep.getArtifactId() + ":" + dep.getVersion() + " (" + dep.getScope()
+ ")");
// Unresolved file because it is in the wrong scope (e.g. test?)
continue;
}
aLog.debug("Classpath entry: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":"
+ dep.getVersion() + " -> " + dep.getFile());
urls.add(dep.getFile().toURI().toURL());
} catch (Exception e) {
throw new MojoExecutionException("Unable get dependency artifact location for "
+ dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion()
+ ExceptionUtils.getRootCauseMessage(e), e);
}
}
return new URLClassLoader(urls.toArray(new URL[] {}), Util.class.getClassLoader());
}