You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:17:02 UTC
[sling-maven-sling-plugin] 20/30: SLING-2075 - adding failOnError
option to install, install-file, deploy and deploy-file goals
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag maven-sling-plugin-2.0.6
in repository https://gitbox.apache.org/repos/asf/sling-maven-sling-plugin.git
commit 686e82e6b596f97dc48250b56a5df1431c3987ba
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri May 6 18:26:23 2011 +0000
SLING-2075 - adding failOnError option to install, install-file, deploy and deploy-file goals
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-sling-plugin@1100313 13f79535-47bb-0310-9956-ffa450edef68
---
.../bundlesupport/AbstractBundleDeployMojo.java | 10 +++++++---
.../bundlesupport/AbstractBundleInstallMojo.java | 20 ++++++++++++++------
.../maven/bundlesupport/AbstractBundlePostMojo.java | 9 +++++++++
3 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleDeployMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleDeployMojo.java
index 1f64609..cba29ca 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleDeployMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleDeployMojo.java
@@ -114,9 +114,13 @@ abstract class AbstractBundleDeployMojo extends AbstractBundlePostMojo {
if (status == HttpStatus.SC_OK) {
getLog().info("Bundle deployed");
} else {
- this.getLog().error(
- "Deployment failed, cause: "
- + HttpStatus.getStatusText(status));
+ String msg = "Deployment failed, cause: "
+ + HttpStatus.getStatusText(status);
+ if (failOnError) {
+ throw new MojoExecutionException(msg);
+ } else {
+ getLog().error(msg);
+ }
}
} catch (Exception ex) {
throw new MojoExecutionException("Deployment on " + targetURL
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
index 9316c3e..c44ebe9 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -278,9 +278,13 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
if (status == HttpStatus.SC_OK) {
getLog().info("Bundle installed");
} else {
- getLog().error(
- "Installation failed, cause: "
- + HttpStatus.getStatusText(status));
+ String msg = "Installation failed, cause: "
+ + HttpStatus.getStatusText(status);
+ if (failOnError) {
+ throw new MojoExecutionException(msg);
+ } else {
+ getLog().error(msg);
+ }
}
} catch (Exception ex) {
throw new MojoExecutionException("Installation on " + targetURL
@@ -301,9 +305,13 @@ abstract class AbstractBundleInstallMojo extends AbstractBundlePostMojo {
if (status >= 200 && status < 300) {
getLog().info("Bundle installed");
} else {
- getLog().error(
- "Installation failed, cause: "
- + HttpStatus.getStatusText(status));
+ String msg = "Installation failed, cause: "
+ + HttpStatus.getStatusText(status);
+ if (failOnError) {
+ throw new MojoExecutionException(msg);
+ } else {
+ getLog().error(msg);
+ }
}
} catch (Exception ex) {
throw new MojoExecutionException("Installation on " + targetURL
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundlePostMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundlePostMojo.java
index b10b5a2..12fa77e 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundlePostMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundlePostMojo.java
@@ -28,6 +28,15 @@ import org.apache.maven.plugin.AbstractMojo;
abstract class AbstractBundlePostMojo extends AbstractMojo {
/**
+ * Determines whether or not to fail the build if
+ * the HTTP POST or PUT returns an non-OK response code.
+ *
+ * @parameter expression="${sling.failOnError}" default-value="false"
+ * @required
+ */
+ protected boolean failOnError;
+
+ /**
* Returns the symbolic name of the given bundle. If the
* <code>jarFile</code> does not contain a manifest with a
* <code>Bundle-SymbolicName</code> header <code>null</code> is
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.