in tooling/common/src/main/java/org/apache/karaf/minho/tooling/common/Runtime.java [206:257]
private void copyArtifact(String location) throws Exception {
String libFolder = (properties != null && properties.get("minho.lib") != null) ? properties.get("minho.lib").toString() : "";
Path runtimeDependenciesFolder = baseFolder.resolve(libFolder);
Files.createDirectories(runtimeDependenciesFolder);
if (!location.startsWith("file:") && !location.startsWith("http:") && !location.startsWith("https:") && !location.startsWith("mvn:")) {
if (location.startsWith("minho:")) {
location = location.substring("minho:".length());
}
location = "mvn:org.apache.karaf.minho/" + location + "/" + version;
}
// copy service jar in working dir
if (location.startsWith("mvn")) {
if (properties != null && properties.get("include.transitive") != null && properties.get("include.transitive").toString().equalsIgnoreCase("true")) {
// resolving dependencies
String pomLocation = location + "/pom";
File pomFile = Parser.resolve(pomLocation);
if (pomFile.exists()) {
List<String> dependencies = new ArrayList<>();
Parser.getDependencies(pomFile, dependencies, true);
dependencies.forEach(dependency -> {
try {
File dependencyFile = Parser.resolve(dependency);
Path targetPath = runtimeDependenciesFolder.resolve(dependencyFile.toPath().getFileName());
Files.copy(dependencyFile.toPath(), targetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
log.warning("Can't include transitive " + dependency + ": " + e);
}
});
}
}
// resolve artifact
File file = Parser.resolve(location);
location = "file:" + file.getAbsolutePath();
}
if (location.startsWith("http:") || location.startsWith("https:")) {
InputStream in = new URL(location).openStream();
String fileName = UUID.randomUUID() + ".jar";
if (location.lastIndexOf("/") != -1) {
fileName = location.substring(location.lastIndexOf("/") + 1);
}
Files.copy(in, runtimeDependenciesFolder.resolve(fileName), StandardCopyOption.REPLACE_EXISTING);
} else {
if (location.startsWith("file:")) {
location = location.substring("file:".length());
}
Path servicePath = Paths.get(location);
Path targetPath = runtimeDependenciesFolder.resolve(servicePath.getFileName());
Files.copy(servicePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
}
}