in src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java [117:165]
public void execute() throws MojoExecutionException {
// get the file to upload
File bundleFile = getBundleFileName();
// only upload if packaging as an osgi-bundle
if (!bundleFile.exists()) {
throw new MojoExecutionException("The given bundle file " + bundleFile + " does not exist!");
}
String bundleName = getBundleSymbolicName(bundleFile);
if (bundleName == null) {
throw new MojoExecutionException("The given file " + bundleFile + " is no OSGi bundle");
}
URI targetURL = getTargetURL();
BundleDeploymentMethod deploymentMethod = getDeploymentMethod();
getLog().info("Installing Bundle " + bundleName + "(" + bundleFile + ") to " + targetURL + " via "
+ deploymentMethod + "...");
try (CloseableHttpClient httpClient = getHttpClient()) {
deploymentMethod
.execute()
.deploy(
targetURL,
bundleFile,
bundleName,
new DeployContext()
.log(getLog())
.httpClient(httpClient)
.failOnError(failOnError)
.bundleStartLevel(bundleStartLevel)
.bundleStart(bundleStart)
.mimeType(mimeType)
.refreshPackages(refreshPackages));
getLog().info("Bundle installed successfully");
if (mountByFS) {
configure(httpClient, getConsoleTargetURL(), bundleFile);
}
} catch (IOException e) {
String msg = "Installation failed, cause: " + e.getMessage();
if (failOnError) {
throw new MojoExecutionException(msg, e);
} else {
getLog().error(msg, e);
}
}
}