in core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/LoadResourceMojo.java [88:151]
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("[MAVEN-CORE-IT-LOG] Looking up wagon for protocol " + wagonProtocol);
Object wagon;
try {
if (repositoryId != null) {
wagon = wagonManager.getWagon(new Repository(repositoryId, wagonProtocol + "://host/path"));
} else {
wagon = wagonManager.getWagon(wagonProtocol);
}
} catch (Exception e) {
throw new MojoExecutionException("Failed to load wagon for protocol " + wagonProtocol, e);
}
ClassLoader classLoader = wagon.getClass().getClassLoader();
getLog().info("[MAVEN-CORE-IT-LOG] Using class loader " + classLoader);
Properties loaderProperties = new Properties();
loaderProperties.setProperty("wagon.class", wagon.getClass().getName());
if (resourcePaths != null) {
for (String path : resourcePaths) {
getLog().info("[MAVEN-CORE-IT-LOG] Loading resource " + path);
URL url = classLoader.getResource(path);
getLog().info("[MAVEN-CORE-IT-LOG] Loaded resource from " + url);
if (url != null) {
loaderProperties.setProperty(path, url.toString());
}
try {
List urls = Collections.list(classLoader.getResources(path));
loaderProperties.setProperty(path + ".count", "" + urls.size());
for (int j = 0; j < urls.size(); j++) {
loaderProperties.setProperty(path + "." + j, urls.get(j).toString());
}
} catch (IOException e) {
throw new MojoExecutionException("Resources could not be enumerated: " + path, e);
}
}
}
getLog().info("[MAVEN-CORE-IT-LOG] Creating output file " + wagonClassLoaderOutput);
OutputStream out = null;
try {
wagonClassLoaderOutput.getParentFile().mkdirs();
out = new FileOutputStream(wagonClassLoaderOutput);
loaderProperties.store(out, "MAVEN-CORE-IT-LOG");
} catch (IOException e) {
throw new MojoExecutionException("Output file could not be created: " + wagonClassLoaderOutput, e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// just ignore
}
}
}
getLog().info("[MAVEN-CORE-IT-LOG] Created output file " + wagonClassLoaderOutput);
}