public void execute()

in src/main/java/org/apache/sling/maven/bundlesupport/BundleUninstallMojo.java [68:115]


    public void execute() throws MojoExecutionException {
        final String bundleName;
        if (this.bundleName == null) {
            // only uninstall if file is really an OSGi bundle
            final File bundleFile = getBundleFileName();
            String bundleSymbolicName = getBundleSymbolicName(bundleFile);
            if (bundleSymbolicName == null) {
                getLog().info(bundleFile + " is not an OSGi Bundle, not uploading");
                return;
            }
            if (getDeploymentMethod() != BundleDeploymentMethod.WebConsole) {
                bundleName = bundleFile.getName();
            } else {
                bundleName = bundleSymbolicName;
            }
        } else {
            bundleName = this.bundleName;
        }

        URI targetURL = getTargetURL();

        BundleDeploymentMethod deployMethod = getDeploymentMethod();

        try (CloseableHttpClient httpClient = getHttpClient()) {
            if (mountByFS) {
                configure(httpClient, targetURL, null);
            }
            getLog().info("Uninstalling Bundle " + bundleName + " from " + targetURL + " via " + deployMethod + "...");
            deployMethod
                    .execute()
                    .undeploy(
                            targetURL,
                            bundleName,
                            new DeployContext()
                                    .log(getLog())
                                    .httpClient(httpClient)
                                    .failOnError(failOnError)
                                    .mimeType(mimeType));
            getLog().info("Bundle uninstalled successfully!");
        } catch (IOException e) {
            String msg = "Uninstall from " + targetURL + " failed, cause: " + e.getMessage();
            if (failOnError) {
                throw new MojoExecutionException(msg, e);
            } else {
                getLog().error(msg, e);
            }
        }
    }