@Mojo(name="install",
defaultPhase=INSTALL)
public class BundleInstallMojo
extends org.apache.maven.plugin.AbstractMojo
Modifier and Type | Field and Description |
---|---|
protected org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.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 static String |
JSON_MIME_TYPE
Mime type for json response.
|
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 String |
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. |
Constructor and Description |
---|
BundleInstallMojo() |
Modifier and Type | Method and Description |
---|---|
protected void |
addConfiguration(org.apache.commons.httpclient.HttpClient client,
String targetURL,
String dir,
String path)
Add a new configuration for the file system provider
|
protected String |
checkWebConsoleVersion(String targetUrl)
Try to get the version of the web console
|
protected void |
configure(String targetURL,
File file)
Add configurations to a running OSGi instance for initial content.
|
void |
execute() |
protected String |
getBundleFileName() |
protected String |
getBundleSymbolicName(File jarFile)
Returns the symbolic name of the given bundle.
|
protected Map |
getCurrentFileProviderConfigs(String targetURL,
org.apache.commons.httpclient.HttpClient client)
Return all file provider configs for this project
|
protected org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.BundleDeploymentMethod |
getDeploymentMethod()
Retrieve the bundle deployment method matching the configuration.
|
protected org.apache.commons.httpclient.HttpClient |
getHttpClient()
Get the http client
|
protected Manifest |
getManifest(File bundleFile)
Get the manifest from the File.
|
protected String |
getTargetURL()
Returns the combination of
sling.url and
sling.urlSuffix . |
protected String |
getURLWithFilename(String targetURL,
String fileName)
Returns the URL with the filename appended to it.
|
protected void |
postToFelix(String targetURL,
File file)
Install the bundle via POST to the Felix Web Console
|
protected void |
postToSling(String targetURL,
File file)
Perform the operation via POST to SlingPostServlet
|
protected void |
putViaWebDav(String targetURL,
File file)
Puts the file via PUT (leveraging WebDAV).
|
protected void |
removeConfiguration(org.apache.commons.httpclient.HttpClient client,
String targetURL,
String pid) |
protected void |
throwWebConsoleTooOldException()
Helper method to throw a meaningful exception for an outdated felix
web console.
|
protected static final String JSON_MIME_TYPE
@Parameter(property="sling.url", defaultValue="http://localhost:8080/system/console", required=true) protected String slingUrl
deploymentMethod
).@Parameter(property="sling.urlSuffix") protected String slingUrlSuffix
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.@Parameter(property="sling.usePut", defaultValue="false") protected boolean usePut
deploymentMethod
instead.uninstall
goal, a HTTP DELETE will be
used.@Parameter(property="sling.deploy.method", required=false) protected org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.BundleDeploymentMethod deploymentMethod
slingUrl
points to the Felix Web Console in that case.slingUrl
points to the entry path of
the Sling WebDAV bundle (usually below regular Sling root URL). Issues a HTTP Delete for the uninstall goal.
slingUrl
points a path which is handled by the Sling POST Servlet (usually below regular Sling root URL).usePut
.@Parameter(property="sling.mimeType", defaultValue="application/java-archive", required=true) protected String mimeType
@Parameter(defaultValue="${project}", required=true, readonly=true) protected org.apache.maven.project.MavenProject project
@Parameter(property="sling.failOnError", defaultValue="true", required=true) protected boolean failOnError
public void execute() throws org.apache.maven.plugin.MojoExecutionException
execute
in interface org.apache.maven.plugin.Mojo
org.apache.maven.plugin.MojoExecutionException
protected String getBundleFileName()
protected String getTargetURL()
sling.url
and
sling.urlSuffix
.protected String getURLWithFilename(String targetURL, String fileName)
targetURL
- the original requested targetURL to append fileName tofileName
- the name of the file to append to the targetURL.protected org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.BundleDeploymentMethod getDeploymentMethod() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected void throwWebConsoleTooOldException() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected org.apache.commons.httpclient.HttpClient getHttpClient()
protected void postToFelix(String targetURL, File file) throws org.apache.maven.plugin.MojoExecutionException
targetURL
- the URL to the Felix Web Console Bundles listingfile
- the file to POSTorg.apache.maven.plugin.MojoExecutionException
protected void postToSling(String targetURL, File file) throws org.apache.maven.plugin.MojoExecutionException
targetURL
- the URL of the Sling instance to post the file to.file
- the file being interacted with the POST to Sling.org.apache.maven.plugin.MojoExecutionException
protected void putViaWebDav(String targetURL, File file) throws org.apache.maven.plugin.MojoExecutionException
targetURL
- file
- org.apache.maven.plugin.MojoExecutionException
protected void configure(String targetURL, File file) throws org.apache.maven.plugin.MojoExecutionException
targetURL
- The web console base urlfile
- The artifact (bundle)org.apache.maven.plugin.MojoExecutionException
protected void removeConfiguration(org.apache.commons.httpclient.HttpClient client, String targetURL, String pid) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected void addConfiguration(org.apache.commons.httpclient.HttpClient client, String targetURL, String dir, String path) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected Map getCurrentFileProviderConfigs(String targetURL, org.apache.commons.httpclient.HttpClient client) throws org.apache.maven.plugin.MojoExecutionException
targetURL
- The targetURL of the webconsoleclient
- The http clientorg.apache.maven.plugin.MojoExecutionException
protected Manifest getManifest(File bundleFile) throws IOException
bundleFile
- The bundle jarIOException
protected String checkWebConsoleVersion(String targetUrl)
null
if version is not detectable.protected String getBundleSymbolicName(File jarFile)
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.
jarFile
- The file providing the bundle whose symbolic name is
requested.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.Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.