Package org.apache.sling.maven.bundlesupport

# Class BundleInstallMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.sling.maven.bundlesupport.BundleInstallMojo

All Implemented Interfaces:
  `org.apache.maven.plugin.ContextEnabled`, `org.apache.maven.plugin.Mojo`

@Mojo(name="install", defaultPhase=INSTALL) public class BundleInstallMojo extends org.apache.maven.plugin.AbstractMojo
Install the project's artifact to a running Sling instance (in case it is an OSGi bundle). It uses the first valid OSGi bundle file for deployment from the primary artifact and all secondary ones. For details refer to Bundle Installation. To install an arbitrary bundle not attached to the current Maven project use goal install-file.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected BundleDeploymentMethod`
`deploymentMethod`
Bundle deployment method.
`protected boolean`
`failOnError`
Determines whether or not to fail the build if the HTTP POST or PUT returns an non-OK response code.
`protected String`
`mimeType`
The content type / mime type used for WebDAV or Sling POST deployment.
`protected org.apache.maven.project.MavenProject`
`project`
The Maven project.
`protected org.eclipse.aether.RepositorySystemSession`
`repoSession`
`protected List<org.eclipse.aether.repository.RemoteRepository>`
`repositories`
`protected org.eclipse.aether.RepositorySystem`
`repoSystem`
`protected URI`
`slingConsoleUrl`
The WebConsole URL of the running Sling instance.
`protected URI`
`slingUrl`
The URL of the running Sling instance.
`protected String`
`slingUrlSuffix`
An optional url suffix which will be appended to the `sling.url` for use as the real target url.
`protected boolean`
`usePut`
Deprecated.
Use `deploymentMethod` instead.

### Fields inherited from interface org.apache.maven.plugin.Mojo

`ROLE`

## Constructor Summary

Constructors
Constructor
Description
`BundleInstallMojo()`

## Method Summary

Modifier and Type
Method
Description
`static URI`
`addTrailingSlash(URI targetURL)`
`protected void`
`configure(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, URI consoleTargetURL, File file)`
`void`
`execute()`
`protected File`
`getBundleFileName()`
`protected String`
`getBundleSymbolicName(File jarFile)`
Returns the symbolic name of the given bundle.
`protected URI`
`getConsoleTargetURL()`
`protected BundleDeploymentMethod`
`getDeploymentMethod()`
Retrieve the bundle deployment method matching the configuration.
`protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient`
`getHttpClient()`
`protected org.apache.hc.client5.http.config.RequestConfig.Builder`
`getRequestConfigBuilder()`
`protected URI`
`getTargetURL()`
`protected File`
`resolveArtifact(org.eclipse.aether.artifact.Artifact artifact)`

### Methods inherited from class org.apache.maven.plugin.AbstractMojo

`getLog, getPluginContext, setLog, setPluginContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### usePut

@Deprecated @Parameter(property="sling.usePut", defaultValue="false") protected boolean usePut
Deprecated.
Use `deploymentMethod` instead.
If a PUT via WebDAV should be used instead of the standard POST to the Felix Web Console. In the `uninstall` goal, a HTTP DELETE will be used.

### deploymentMethod

@Parameter(property="sling.deploy.method") protected BundleDeploymentMethod deploymentMethod
Bundle deployment method. One of the following three values are allowed

1. WebConsole, uses the Felix Web Console REST API for deployment (HTTP POST). This is the default. Make sure that `slingUrl` points to the Felix Web Console in that case.
2. WebDAV, uses WebDAV for deployment (HTTP PUT). Make sure that `slingUrl` points to the entry path of the Sling WebDAV bundle (defaults to `/dav/default` in the Sling starter). Issues a HTTP Delete for the uninstall goal.
3. SlingPostServlet, uses the Sling Post Servlet for deployment (HTTP POST). Make sure that `slingUrl` points a path which is handled by the Sling POST Servlet (usually below regular Sling root URL).

For more details refer to Bundle Installation. This has precedence over the deprecated parameter `usePut`. If nothing is set the default is either `WebConsole` or `WebDAV` (when `usePut` is `true`).

### mimeType

@Parameter(property="sling.mimeType", defaultValue="application/java-archive") protected String mimeType
The content type / mime type used for WebDAV or Sling POST deployment.

### project

@Parameter(defaultValue="${project}", required=true, readonly=true) protected org.apache.maven.project.MavenProject project
The Maven project.

### slingUrl

@Parameter(property="sling.url", defaultValue="http://localhost:8080/system/console", required=true) protected URI slingUrl
The URL of the running Sling instance.

The default is only useful for WebConsole deployment.

For WebDAV deployment it is recommended to include the Sling Simple WebDAV servlet root, for instance http://localhost:8080/dav/default/libs/sling/install. Omitting the `dav/default` segment can lead to conflicts with other servlets.

### slingConsoleUrl

@Parameter(property="sling.console.url") protected URI slingConsoleUrl
The WebConsole URL of the running Sling instance. This is required for file system provider operations. If not configured the value of slingUrl is used.

### slingUrlSuffix

@Parameter(property="sling.urlSuffix") protected String slingUrlSuffix
An optional url suffix which will be appended to the `sling.url` for use as the real target url. This allows to configure different target URLs in each POM, while using the same common `sling.url` in a parent POM (eg. `sling.url=http://localhost:8080` and `sling.urlSuffix=/project/specific/path`). This is typically used in conjunction with WebDAV or SlingPostServlet deployment methods.

### failOnError

@Parameter(property="sling.failOnError", defaultValue="true") protected boolean failOnError
Determines whether or not to fail the build if the HTTP POST or PUT returns an non-OK response code.

### repoSystem

@Component protected org.eclipse.aether.RepositorySystem repoSystem

### repoSession

@Parameter(defaultValue="${repositorySystemSession}", readonly=true, required=true) protected org.eclipse.aether.RepositorySystemSession repoSession

### repositories

@Parameter(defaultValue="${project.remoteProjectRepositories}", readonly=true, required=true) protected List<org.eclipse.aether.repository.RemoteRepository> repositories

## Constructor Details

### BundleInstallMojo

public BundleInstallMojo()

## Method Details

### execute

public void execute() throws org.apache.maven.plugin.MojoExecutionException

Specified by:
  `execute` in interface `org.apache.maven.plugin.Mojo`
Throws:
  `org.apache.maven.plugin.MojoExecutionException`

### getBundleFileName

protected File getBundleFileName() throws org.apache.maven.plugin.MojoExecutionException

Throws:
  `org.apache.maven.plugin.MojoExecutionException`

### configure

protected void configure(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, URI consoleTargetURL, File file) throws org.apache.maven.plugin.MojoExecutionException

Throws:
  `org.apache.maven.plugin.MojoExecutionException`

### getDeploymentMethod

protected BundleDeploymentMethod getDeploymentMethod() throws org.apache.maven.plugin.MojoExecutionException
Retrieve the bundle deployment method matching the configuration.

Returns:
  bundle deployment method matching the plugin configuration.
Throws:
  `org.apache.maven.plugin.MojoExecutionException` - Exception

### getBundleSymbolicName

protected String getBundleSymbolicName(File jarFile)
Returns the symbolic name of the given bundle. If the `jarFile` does not contain a manifest with a `Bundle-SymbolicName` header `null` is returned. Otherwise the value of the `Bundle-SymbolicName` header is returned.

This method may also be used to check whether the file is a bundle at all as it is assumed, that only if the file contains an OSGi bundle will the `Bundle-SymbolicName` manifest header be set.

Parameters:
  `jarFile` - The file providing the bundle whose symbolic name is requested.
Returns:
  The bundle's symbolic name from the `Bundle-SymbolicName` manifest header or `null` if no manifest exists in the file or the header is not contained in the manifest. However, if `null` is returned, the file may be assumed to not contain an OSGi bundle.

### getTargetURL

protected URI getTargetURL()

Returns:
  Returns the combination of `sling.url` and `sling.urlSuffix`. Always ends with "/".

### getConsoleTargetURL

protected URI getConsoleTargetURL()

Returns:
  Returns the combination of `sling.console.url` and `sling.urlSuffix`. Always ends with "/".

### addTrailingSlash

public static URI addTrailingSlash(URI targetURL)

### getHttpClient

protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient getHttpClient()

Returns:
  Get the http client

### getRequestConfigBuilder

protected org.apache.hc.client5.http.config.RequestConfig.Builder getRequestConfigBuilder()

### resolveArtifact

protected File resolveArtifact(org.eclipse.aether.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException

Throws:
  `org.apache.maven.plugin.MojoExecutionException`