You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2022/08/14 16:06:17 UTC
[sling-maven-plugin] branch master updated: SLING-11522 Add IT for mounting FileVault package (#15)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-maven-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new c4398f0 SLING-11522 Add IT for mounting FileVault package (#15)
c4398f0 is described below
commit c4398f0910fe2aea471f6a2c4f03e8075670ee80
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Aug 14 18:06:12 2022 +0200
SLING-11522 Add IT for mounting FileVault package (#15)
Improve logging when mounting does not work
Centralize artifact resolving
---
pom.xml | 15 ++++++
.../invoker.properties | 0
.../pom.xml | 38 ++-----------
.../src/main/META-INF/vault/filter.xml | 20 +++++++
.../apps/fsmount-filevault-test}/example.txt | 0
.../verify.groovy | 4 +-
.../invoker.properties | 0
.../pom.xml | 0
.../src/main/webapp/app-root/example.txt | 0
.../verify.groovy | 0
.../bundlesupport/AbstractBundleRequestMojo.java | 42 +++++++++++++++
.../maven/bundlesupport/AbstractFsMountMojo.java | 35 +++++++-----
.../maven/bundlesupport/BundleInstallFileMojo.java | 41 --------------
.../sling/maven/bundlesupport/FsMountMojo.java | 62 +++++++---------------
.../fsresource/FileVaultXmlMounter.java | 2 +-
.../fsresource/SlingInitialContentMounter.java | 4 +-
16 files changed, 129 insertions(+), 134 deletions(-)
diff --git a/pom.xml b/pom.xml
index cbbc5dd..2d7d6ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -217,11 +217,25 @@
<version>2.11.0</version>
<scope>compile</scope>
</dependency>
+ <!-- just for JsonTicksConverter -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.contentparser</artifactId>
<version>1.2.8</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!-- only for WorkspaceFilter and Constants -->
+ <dependency>
+ <groupId>org.apache.jackrabbit.vault</groupId>
+ <artifactId>org.apache.jackrabbit.vault</artifactId>
+ <version>3.6.0</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@@ -318,6 +332,7 @@
</plugin>
</plugins>
</pluginManagement>
+
</build>
</profile>
<!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
diff --git a/src/it/fs-mount-test/invoker.properties b/src/it/fs-mount-contentpackage-test/invoker.properties
similarity index 100%
copy from src/it/fs-mount-test/invoker.properties
copy to src/it/fs-mount-contentpackage-test/invoker.properties
diff --git a/src/it/fs-mount-test/pom.xml b/src/it/fs-mount-contentpackage-test/pom.xml
similarity index 64%
copy from src/it/fs-mount-test/pom.xml
copy to src/it/fs-mount-contentpackage-test/pom.xml
index f8c59dd..c151942 100644
--- a/src/it/fs-mount-test/pom.xml
+++ b/src/it/fs-mount-contentpackage-test/pom.xml
@@ -25,14 +25,14 @@
<groupId>org.apache.sling</groupId>
<artifactId>example-pom</artifactId>
<version>1.0.0-SNAPSHOT</version>
- <packaging>jar</packaging>
+ <packaging>pom</packaging>
<build>
<resources>
- <!-- copy webapp resources to SLING-INF/app-root -->
+ <!-- mark jcr_root as resource directory of Maven project -->
<resource>
- <directory>src/main/webapp</directory>
- <targetPath>SLING-INF</targetPath>
+ <directory>src/main/jcr_root</directory>
+ <targetPath>jcr_root</targetPath>
<filtering>false</filtering>
</resource>
</resources>
@@ -58,32 +58,6 @@
</pluginManagement>
<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>3.3.0</version>
- <executions>
- <execution>
- <id>copy</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>io.wcm</groupId>
- <artifactId>io.wcm.caconfig.editor</artifactId>
- <version>1.8.0</version>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <destFileName>ca-config-editor.jar</destFileName>
- </artifactItem>
- </artifactItems>
- <!-- other configurations here -->
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
@@ -104,10 +78,6 @@
<phase>install</phase>
</execution>
</executions>
- <configuration>
- <!-- try a bundle with Sling Initial content -->
- <bundleFileName>${project.build.directory}/ca-config-editor.jar</bundleFileName>
- </configuration>
</plugin>
</plugins>
</build>
diff --git a/src/it/fs-mount-contentpackage-test/src/main/META-INF/vault/filter.xml b/src/it/fs-mount-contentpackage-test/src/main/META-INF/vault/filter.xml
new file mode 100644
index 0000000..3e63216
--- /dev/null
+++ b/src/it/fs-mount-contentpackage-test/src/main/META-INF/vault/filter.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<workspaceFilter version="1.0">
+ <filter root="/apps/fsmount-filevault-test"/>
+</workspaceFilter>
\ No newline at end of file
diff --git a/src/it/fs-mount-test/src/main/webapp/app-root/example.txt b/src/it/fs-mount-contentpackage-test/src/main/jcr_root/apps/fsmount-filevault-test/example.txt
similarity index 100%
copy from src/it/fs-mount-test/src/main/webapp/app-root/example.txt
copy to src/it/fs-mount-contentpackage-test/src/main/jcr_root/apps/fsmount-filevault-test/example.txt
diff --git a/src/it/fs-mount-test/verify.groovy b/src/it/fs-mount-contentpackage-test/verify.groovy
similarity index 91%
copy from src/it/fs-mount-test/verify.groovy
copy to src/it/fs-mount-contentpackage-test/verify.groovy
index e488cd4..8c429c4 100644
--- a/src/it/fs-mount-test/verify.groovy
+++ b/src/it/fs-mount-contentpackage-test/verify.groovy
@@ -18,5 +18,5 @@
*/
String buildLog = new File(basedir, 'build.log').text
-assert buildLog.contains('[INFO] Added new configuration for resource path /apps/wcm-io/caconfig/editor to server')
-assert buildLog.contains('[INFO] Removed configuration for resource path /apps/wcm-io/caconfig/editor')
+assert buildLog.contains('[INFO] Added new configuration for resource path /apps/fsmount-filevault-test to server')
+assert buildLog.contains('[INFO] Removed configuration for resource path /apps/fsmount-filevault-test')
diff --git a/src/it/fs-mount-test/invoker.properties b/src/it/fs-mount-initialcontent-test/invoker.properties
similarity index 100%
rename from src/it/fs-mount-test/invoker.properties
rename to src/it/fs-mount-initialcontent-test/invoker.properties
diff --git a/src/it/fs-mount-test/pom.xml b/src/it/fs-mount-initialcontent-test/pom.xml
similarity index 100%
rename from src/it/fs-mount-test/pom.xml
rename to src/it/fs-mount-initialcontent-test/pom.xml
diff --git a/src/it/fs-mount-test/src/main/webapp/app-root/example.txt b/src/it/fs-mount-initialcontent-test/src/main/webapp/app-root/example.txt
similarity index 100%
rename from src/it/fs-mount-test/src/main/webapp/app-root/example.txt
rename to src/it/fs-mount-initialcontent-test/src/main/webapp/app-root/example.txt
diff --git a/src/it/fs-mount-test/verify.groovy b/src/it/fs-mount-initialcontent-test/verify.groovy
similarity index 100%
rename from src/it/fs-mount-test/verify.groovy
rename to src/it/fs-mount-initialcontent-test/verify.groovy
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleRequestMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleRequestMojo.java
index 9517807..b54d2c9 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleRequestMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleRequestMojo.java
@@ -22,6 +22,8 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -39,8 +41,17 @@ import org.apache.hc.core5.http.HttpRequestInterceptor;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Timeout;
import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.RepositoryPolicy;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
import org.osgi.framework.Constants;
abstract class AbstractBundleRequestMojo extends AbstractMojo {
@@ -109,6 +120,15 @@ abstract class AbstractBundleRequestMojo extends AbstractMojo {
@Parameter(property = "sling.httpResponseTimeoutSec", defaultValue = "60")
private int httpResponseTimeoutSec;
+ @Component
+ protected RepositorySystem repoSystem;
+
+ @Parameter(defaultValue = "${repositorySystemSession}", readonly = true, required = true)
+ protected RepositorySystemSession repoSession;
+
+ @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true)
+ protected List<RemoteRepository> repositories;
+
/**
* Returns the symbolic name of the given bundle. If the
* <code>jarFile</code> does not contain a manifest with a
@@ -220,6 +240,28 @@ abstract class AbstractBundleRequestMojo extends AbstractMojo {
.setResponseTimeout(Timeout.ofSeconds(httpResponseTimeoutSec));
}
+ protected File resolveArtifact(org.eclipse.aether.artifact.Artifact artifact) throws MojoExecutionException {
+ ArtifactRequest req = new ArtifactRequest(artifact, getRemoteRepositoriesWithUpdatePolicy(repositories, RepositoryPolicy.UPDATE_POLICY_ALWAYS), null);
+ ArtifactResult resolutionResult;
+ try {
+ resolutionResult = repoSystem.resolveArtifact(repoSession, req);
+ return resolutionResult.getArtifact().getFile();
+ } catch (ArtifactResolutionException e) {
+ throw new MojoExecutionException("Artifact " + artifact + " could not be resolved.", e);
+ }
+ }
+
+ private List<RemoteRepository> getRemoteRepositoriesWithUpdatePolicy(List<RemoteRepository> repositories, String updatePolicy) {
+ List<RemoteRepository> newRepositories = new ArrayList<>();
+ for (RemoteRepository repo : repositories) {
+ RemoteRepository.Builder builder = new RemoteRepository.Builder(repo);
+ RepositoryPolicy newPolicy = new RepositoryPolicy(repo.getPolicy(false).isEnabled(), updatePolicy, repo.getPolicy(false).getChecksumPolicy());
+ builder.setPolicy(newPolicy);
+ newRepositories.add(builder.build());
+ }
+ return newRepositories;
+ }
+
private static final class PreemptiveBasicAuthInterceptor implements HttpRequestInterceptor {
private final BasicScheme basicAuth;
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractFsMountMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractFsMountMojo.java
index af58bd1..133615b 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractFsMountMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractFsMountMojo.java
@@ -42,7 +42,7 @@ import org.apache.maven.project.MavenProject;
abstract class AbstractFsMountMojo extends AbstractBundleRequestMojo {
/**
- * The name of the generated JAR file.
+ * The path of the bundle file whose Sling Initial Content should be mounted.
*/
@Parameter(property = "sling.file", defaultValue = "${project.build.directory}/${project.build.finalName}.jar", required = true)
private String bundleFileName;
@@ -75,20 +75,22 @@ abstract class AbstractFsMountMojo extends AbstractBundleRequestMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
- getLog().debug("Skipping fsmount/fsunmount operation as instructed.");
+ getLog().info("Skipping fsmount/fsunmount operation as instructed.");
return;
}
- URI targetUrl = getConsoleTargetURL();
+ URI consoleTargetUrl = getConsoleTargetURL();
try (CloseableHttpClient httpClient = getHttpClient()) {
// ensure required bundles are installed
- ensureBundlesInstalled(httpClient, targetUrl);
+ ensureBundlesInstalled(httpClient, consoleTargetUrl);
// check for Sling-Initial-Content
File bundleFile = new File(bundleFileName);
if (bundleFile.exists()) {
- configureSlingInitialContent(httpClient, targetUrl, bundleFile);
+ configureSlingInitialContent(httpClient, consoleTargetUrl, bundleFile);
return;
+ } else {
+ getLog().debug("Bundle file at " + bundleFileName + " does not exist");
}
// try to detect filevault layout
@@ -106,14 +108,20 @@ abstract class AbstractFsMountMojo extends AbstractBundleRequestMojo {
else {
filterXmlFile = detectFilterXmlFile();
}
- if (jcrRootFile != null && jcrRootFile.exists() && filterXmlFile != null && filterXmlFile.exists()) {
- configureFileVaultXml(httpClient, targetUrl, jcrRootFile, filterXmlFile);
- return;
+ if (jcrRootFile != null && filterXmlFile != null) {
+ if (jcrRootFile.exists() && filterXmlFile.exists()) {
+ configureFileVaultXml(httpClient, consoleTargetUrl, jcrRootFile, filterXmlFile);
+ return;
+ } else {
+ getLog().warn("jcr_root directory at " + jcrRootFile + " and/or filter.xml file at " + filterXmlFile + " does not exist");
+ }
+ } else {
+ getLog().warn("Could not auto-detect jcr_root directory and/or filter.xml file");
}
} catch (IOException e) {
getLog().error("Could not close underlying HTTP client" + e.getMessage(), e);
}
- getLog().info("No Bundle with initial content or FileVault content package found - skipping.");
+ getLog().warn("No Bundle with initial content or FileVault content package found - skipping.");
}
private File detectJcrRootFile() {
@@ -125,7 +133,10 @@ abstract class AbstractFsMountMojo extends AbstractBundleRequestMojo {
if (dir.exists() && dir.isDirectory() && StringUtils.equals(dir.getName(), ROOT_DIR)) {
return dir;
}
+ getLog().debug("Maven project resource directory " + dir + " does not have name " + ROOT_DIR + " and therefore cannot be FileVault package root");
}
+ } else {
+ getLog().debug("This Maven project does not have any resources");
}
return null;
}
@@ -163,13 +174,13 @@ abstract class AbstractFsMountMojo extends AbstractBundleRequestMojo {
return null;
}
- protected abstract void configureSlingInitialContent(CloseableHttpClient httpClient, final URI targetUrl, final File bundleFile)
+ protected abstract void configureSlingInitialContent(CloseableHttpClient httpClient, final URI consoleTargetUrl, final File bundleFile)
throws MojoExecutionException;
- protected abstract void configureFileVaultXml(CloseableHttpClient httpClient, final URI targetUrl, final File jcrRootFile, final File filterXmlFile)
+ protected abstract void configureFileVaultXml(CloseableHttpClient httpClient, final URI consoleTargetUrl, final File jcrRootFile, final File filterXmlFile)
throws MojoExecutionException;
- protected abstract void ensureBundlesInstalled(CloseableHttpClient httpClient, final URI targetUrl)
+ protected abstract void ensureBundlesInstalled(CloseableHttpClient httpClient, final URI consoleTargetUrl)
throws MojoExecutionException;
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallFileMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallFileMojo.java
index 0b55391..2b97cd7 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallFileMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallFileMojo.java
@@ -18,22 +18,12 @@
package org.apache.sling.maven.bundlesupport;
import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.StringUtils;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.RepositoryPolicy;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.eclipse.aether.resolution.ArtifactResult;
/**
* Install an OSGi bundle from a given file path or Maven coordinates (resolved from the repository) to a running Sling instance.
@@ -92,15 +82,6 @@ public class BundleInstallFileMojo extends AbstractBundleInstallMojo {
@Parameter(property="sling.artifact")
private String artifact;
- @Component
- private RepositorySystem repoSystem;
-
- @Parameter( defaultValue = "${repositorySystemSession}", readonly = true, required = true )
- private RepositorySystemSession repoSession;
-
- @Parameter( defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true )
- private List<RemoteRepository> repositories;
-
@Override
protected File getBundleFileName() throws MojoExecutionException {
File fileName = bundleFileName;
@@ -141,26 +122,4 @@ public class BundleInstallFileMojo extends AbstractBundleInstallMojo {
getLog().info("Resolved artifact to " + resolvedArtifactFile.getAbsolutePath());
return resolvedArtifactFile;
}
-
- protected File resolveArtifact(org.eclipse.aether.artifact.Artifact artifact) throws MojoExecutionException {
- ArtifactRequest req = new ArtifactRequest(artifact, getRemoteRepositoriesWithUpdatePolicy(repositories, RepositoryPolicy.UPDATE_POLICY_ALWAYS), null);
- ArtifactResult resolutionResult;
- try {
- resolutionResult = repoSystem.resolveArtifact(repoSession, req);
- return resolutionResult.getArtifact().getFile();
- } catch (ArtifactResolutionException e) {
- throw new MojoExecutionException("Artifact " + artifact + " could not be resolved.", e);
- }
- }
-
- private List<RemoteRepository> getRemoteRepositoriesWithUpdatePolicy(List<RemoteRepository> repositories, String updatePolicy) {
- List<RemoteRepository> newRepositories = new ArrayList<>();
- for (RemoteRepository repo : repositories) {
- RemoteRepository.Builder builder = new RemoteRepository.Builder(repo);
- RepositoryPolicy newPolicy = new RepositoryPolicy(repo.getPolicy(false).isEnabled(), updatePolicy, repo.getPolicy(false).getChecksumPolicy());
- builder.setPolicy(newPolicy);
- newRepositories.add(builder.build());
- }
- return newRepositories;
- }
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/FsMountMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/FsMountMojo.java
index 6109f1c..434c5ca 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/FsMountMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/FsMountMojo.java
@@ -34,21 +34,16 @@ import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.core5.http.HttpStatus;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.repository.RepositorySystem;
import org.apache.sling.maven.bundlesupport.BundlePrerequisite.Bundle;
import org.apache.sling.maven.bundlesupport.deploy.BundleDeploymentMethod;
import org.apache.sling.maven.bundlesupport.deploy.DeployContext;
import org.apache.sling.maven.bundlesupport.fsresource.FileVaultXmlMounter;
import org.apache.sling.maven.bundlesupport.fsresource.SlingInitialContentMounter;
+import org.eclipse.aether.artifact.DefaultArtifact;
/**
* Create OSGi configurations for the
@@ -153,13 +148,6 @@ public class FsMountMojo extends AbstractFsMountMojo {
@Parameter(required = false)
private List<BundlePrerequisite> deployFsResourceBundlePrerequisites;
- @Component
- private RepositorySystem repository;
- @Parameter(property = "localRepository", required = true, readonly = true)
- private ArtifactRepository localRepository;
- @Parameter(property = "project.remoteArtifactRepositories", required = true, readonly = true)
- private java.util.List<ArtifactRepository> remoteRepositories;
-
public void addDeployFsResourceBundlePrerequisite(BundlePrerequisite item) {
if (this.deployFsResourceBundlePrerequisites == null) {
this.deployFsResourceBundlePrerequisites = new ArrayList<>();
@@ -168,17 +156,17 @@ public class FsMountMojo extends AbstractFsMountMojo {
}
@Override
- protected void configureSlingInitialContent(CloseableHttpClient httpClient, final URI targetUrl, final File bundleFile) throws MojoExecutionException {
- new SlingInitialContentMounter(getLog(), getHttpClient(), getRequestConfigBuilder(), project).mount(targetUrl, bundleFile);
+ protected void configureSlingInitialContent(CloseableHttpClient httpClient, final URI consoleTargetUrl, final File bundleFile) throws MojoExecutionException {
+ new SlingInitialContentMounter(getLog(), getHttpClient(), getRequestConfigBuilder(), project).mount(consoleTargetUrl, bundleFile);
}
@Override
- protected void configureFileVaultXml(CloseableHttpClient httpClient, URI targetUrl, File jcrRootFile, File filterXmlFile) throws MojoExecutionException {
- new FileVaultXmlMounter(getLog(), httpClient, getRequestConfigBuilder(), project).mount(targetUrl, jcrRootFile, filterXmlFile);
+ protected void configureFileVaultXml(CloseableHttpClient httpClient, URI consoleTargetUrl, File jcrRootFile, File filterXmlFile) throws MojoExecutionException {
+ new FileVaultXmlMounter(getLog(), httpClient, getRequestConfigBuilder(), project).mount(consoleTargetUrl, jcrRootFile, filterXmlFile);
}
@Override
- protected void ensureBundlesInstalled(CloseableHttpClient httpClient,URI targetUrl) throws MojoExecutionException {
+ protected void ensureBundlesInstalled(CloseableHttpClient httpClient, URI consoleTargetUrl) throws MojoExecutionException {
if (!deployFsResourceBundle) {
return;
}
@@ -198,9 +186,9 @@ public class FsMountMojo extends AbstractFsMountMojo {
}
for (BundlePrerequisite bundlePrerequisite : deployFsResourceBundlePrerequisites) {
- if (isBundlePrerequisitesPreconditionsMet(httpClient, bundlePrerequisite, targetUrl)) {
+ if (isBundlePrerequisitesPreconditionsMet(httpClient, bundlePrerequisite, consoleTargetUrl)) {
for (Bundle bundle : bundlePrerequisite.getBundles()) {
- deployBundle(httpClient, bundle, targetUrl);
+ deployBundle(httpClient, bundle, consoleTargetUrl);
}
break;
} else {
@@ -209,26 +197,26 @@ public class FsMountMojo extends AbstractFsMountMojo {
}
}
- private void deployBundle(CloseableHttpClient httpClient, Bundle bundle, URI targetUrl) throws MojoExecutionException {
+ private void deployBundle(CloseableHttpClient httpClient, Bundle bundle, URI consoleTargetUrl) throws MojoExecutionException {
try {
- if (isBundleInstalled(httpClient, bundle, targetUrl)) {
+ if (isBundleInstalled(httpClient, bundle, consoleTargetUrl)) {
getLog().debug("Bundle " + bundle.getSymbolicName() + " " + bundle.getOsgiVersion() + " (or higher) already installed.");
return;
}
} catch(IOException e) {
- throw new MojoExecutionException("Error getting installation status of " + bundle + " via " + targetUrl + ": " + e.getMessage(), e);
+ throw new MojoExecutionException("Error getting installation status of " + bundle + " via " + consoleTargetUrl + ": " + e.getMessage(), e);
}
try {
getLog().info("Installing Bundle " + bundle.getSymbolicName() + " " + bundle.getOsgiVersion() + " to "
- + targetUrl + " via " + deploymentMethod);
+ + consoleTargetUrl + " via " + deploymentMethod);
File file = getArtifactFile(bundle, "jar");
- deploymentMethod.execute().deploy(targetUrl, file, bundle.getSymbolicName(), new DeployContext()
+ deploymentMethod.execute().deploy(getTargetURL(), file, bundle.getSymbolicName(), new DeployContext()
.log(getLog())
.httpClient(httpClient)
.failOnError(failOnError));
} catch(IOException e) {
- throw new MojoExecutionException("Error deploying bundle " + bundle + " to " + targetUrl + ": " + e.getMessage(), e);
+ throw new MojoExecutionException("Error deploying bundle " + bundle + " to " + getTargetURL() + ": " + e.getMessage(), e);
}
}
@@ -247,8 +235,8 @@ public class FsMountMojo extends AbstractFsMountMojo {
return true;
}
- private boolean isBundleInstalled(CloseableHttpClient httpClient, Bundle bundle, URI targetUrl) throws IOException {
- String installedVersionString = getBundleInstalledVersion(httpClient, bundle.getSymbolicName(), targetUrl);
+ private boolean isBundleInstalled(CloseableHttpClient httpClient, Bundle bundle, URI consoleTargetUrl) throws IOException {
+ String installedVersionString = getBundleInstalledVersion(httpClient, bundle.getSymbolicName(), consoleTargetUrl);
if (StringUtils.isBlank(installedVersionString)) {
return false;
}
@@ -264,8 +252,8 @@ public class FsMountMojo extends AbstractFsMountMojo {
* @return Version number or null if non installed
* @throws MojoExecutionException
*/
- private String getBundleInstalledVersion(CloseableHttpClient httpClient, final String bundleSymbolicName, final URI targetUrl) throws IOException {
- final URI getUrl = targetUrl.resolve( "/system/console/bundles/" + bundleSymbolicName + ".json");
+ private String getBundleInstalledVersion(CloseableHttpClient httpClient, final String bundleSymbolicName, final URI consoleTargetUrl) throws IOException {
+ final URI getUrl = consoleTargetUrl.resolve( "bundles/" + bundleSymbolicName + ".json");
getLog().debug("Get bundle data via request to " + getUrl);
final HttpGet get = new HttpGet(getUrl);
@@ -292,18 +280,8 @@ public class FsMountMojo extends AbstractFsMountMojo {
return null;
}
- private File getArtifactFile(Bundle bundle, String type) throws MojoExecutionException {
- Artifact artifactObject = repository.createArtifact(bundle.getGroupId(), bundle.getArtifactId(), bundle.getVersion(), type);
- ArtifactResolutionRequest request = new ArtifactResolutionRequest();
- request.setArtifact(artifactObject);
- request.setLocalRepository(localRepository);
- request.setRemoteRepositories(remoteRepositories);
- ArtifactResolutionResult result = repository.resolve(request);
- if (result.isSuccess()) {
- return artifactObject.getFile();
- } else {
- throw new MojoExecutionException("Unable to download artifact: " + artifactObject.toString());
- }
+ private File getArtifactFile(Bundle bundle, String extension) throws MojoExecutionException {
+ return resolveArtifact(new DefaultArtifact(bundle.getGroupId(), bundle.getArtifactId(), extension, bundle.getVersion()));
}
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/FileVaultXmlMounter.java b/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/FileVaultXmlMounter.java
index 1c32f56..ff6dc18 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/FileVaultXmlMounter.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/FileVaultXmlMounter.java
@@ -56,7 +56,7 @@ public final class FileVaultXmlMounter {
* @throws MojoExecutionException Exception
*/
public void mount(final URI consoleTargetUrl, final File jcrRootFile, final File filterXmlFile) throws MojoExecutionException {
- log.info("Trying to configure file system provider...");
+ log.info("Trying to configure file system provider for FileVault...");
// create config for each path defined in filter
final List<FsResourceConfiguration> cfgs = new ArrayList<>();
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/SlingInitialContentMounter.java b/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/SlingInitialContentMounter.java
index 1e6d6d3..a8f6a7f 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/SlingInitialContentMounter.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/fsresource/SlingInitialContentMounter.java
@@ -69,7 +69,7 @@ public final class SlingInitialContentMounter {
final Manifest mf = getManifest(bundleFile);
final String value = mf.getMainAttributes().getValue(HEADER_INITIAL_CONTENT);
if ( value == null ) {
- log.debug("Bundle has no initial content - no file system provider config created.");
+ log.warn("Bundle has no initial content - no file system provider config created.");
return;
}
header = ManifestHeader.parse(value);
@@ -81,7 +81,7 @@ public final class SlingInitialContentMounter {
throw new MojoExecutionException("Unable to read manifest from file " + bundleFile, ioe);
}
- log.info("Trying to configure file system provider...");
+ log.info("Trying to configure file system provider for Sling initial content...");
// quick check if resources are configured
final List<Resource> resources = project.getResources();
if ( resources == null || resources.size() == 0 ) {