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/15 17:28:02 UTC

[sling-maven-plugin] branch bugfix/improve-exception-for-invalid-bundle-files created (now 5fa91fb)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch bugfix/improve-exception-for-invalid-bundle-files
in repository https://gitbox.apache.org/repos/asf/sling-maven-plugin.git


      at 5fa91fb  SLING-11543 improve exception handling for invalid bundle files

This branch includes the following new commits:

     new 5fa91fb  SLING-11543 improve exception handling for invalid bundle files

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-maven-plugin] 01/01: SLING-11543 improve exception handling for invalid bundle files

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch bugfix/improve-exception-for-invalid-bundle-files
in repository https://gitbox.apache.org/repos/asf/sling-maven-plugin.git

commit 5fa91fb6e37e17e19b9835991f68a80daaf2e3d3
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Aug 15 19:27:57 2022 +0200

    SLING-11543 improve exception handling for invalid bundle files
    
    add ITs for standalone goal usage of "install" and "install-file"
---
 src/it/install-file-test/invoker.properties                        | 4 +++-
 src/it/install-file-test/pom.xml                                   | 2 +-
 src/it/install-test/invoker.properties                             | 5 ++++-
 .../sling/maven/bundlesupport/AbstractBundleInstallMojo.java       | 7 +++----
 .../org/apache/sling/maven/bundlesupport/BundleInstallMojo.java    | 4 ++--
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/it/install-file-test/invoker.properties b/src/it/install-file-test/invoker.properties
index 44fca57..4c74892 100644
--- a/src/it/install-file-test/invoker.properties
+++ b/src/it/install-file-test/invoker.properties
@@ -20,4 +20,6 @@ invoker.goals.2=install -Dsling.deploy.method=WebDAV -Dsling.urlSuffix=/dav/defa
 invoker.goals.3=install -Dsling.deploy.method=SlingPostServlet -Dsling.urlSuffix=/apps/sling-it
 # invalid URL must lead to build failure
 invoker.goals.4=install -Dsling.urlSuffix=/system/console2
-invoker.buildResult.4=failure
\ No newline at end of file
+invoker.buildResult.4=failure
+# call goal alone
+invoker.goals.5=sling:install-file -Dsling.urlSuffix=/system/console -Dsling.artifact=org.apache.sling:org.apache.sling.commons.messaging:1.0.2
diff --git a/src/it/install-file-test/pom.xml b/src/it/install-file-test/pom.xml
index 645157c..0ce29b1 100644
--- a/src/it/install-file-test/pom.xml
+++ b/src/it/install-file-test/pom.xml
@@ -65,8 +65,8 @@
                         </goals>
                         <phase>install</phase>
                         <configuration>
-                            <artifactId>org.apache.sling.commons.messaging</artifactId>
                             <groupId>org.apache.sling</groupId>
+                            <artifactId>org.apache.sling.commons.messaging</artifactId>
                             <version>1.0.2</version>
                         </configuration>
                     </execution>
diff --git a/src/it/install-test/invoker.properties b/src/it/install-test/invoker.properties
index 3c0aaa5..2c9f0c7 100644
--- a/src/it/install-test/invoker.properties
+++ b/src/it/install-test/invoker.properties
@@ -20,4 +20,7 @@ invoker.goals.2=install -Dsling.deploy.method=WebDAV -Dsling.urlSuffix=/dav/defa
 invoker.goals.3=install -Dsling.deploy.method=SlingPostServlet -Dsling.urlSuffix=/apps/sling-it
 # invalid URL must lead to build failure
 invoker.goals.4=install -Dsling.urlSuffix=/system/console2
-invoker.buildResult.4=failure
\ No newline at end of file
+invoker.buildResult.4=failure
+# call goal alone
+invoker.goals.5=sling:install -Dsling.urlSuffix=/system/console
+invoker.buildResult.5=failure
\ No newline at end of file
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 9354fc3..41a99f4 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/AbstractBundleInstallMojo.java
@@ -24,6 +24,7 @@ import java.net.URI;
 
 import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.sling.maven.bundlesupport.deploy.BundleDeploymentMethod;
@@ -121,14 +122,12 @@ abstract class AbstractBundleInstallMojo extends AbstractBundleRequestMojo {
 
         // only upload if packaging as an osgi-bundle
         if (!bundleFile.exists()) {
-            getLog().info(bundleFile + " does not exist, not uploading");
-            return;
+            throw new MojoExecutionException("The given bundle file " + bundleFile + " does not exist!");
         }
 
         String bundleName = getBundleSymbolicName(bundleFile);
         if (bundleName == null) {
-            getLog().info(bundleFile + " is not an OSGi Bundle, not uploading");
-            return;
+            throw new MojoExecutionException("The given file " + bundleFile + " is no OSGi bundle");
         }
 
         URI targetURL = getTargetURL();
diff --git a/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallMojo.java b/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallMojo.java
index 256879e..9e3488c 100644
--- a/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallMojo.java
+++ b/src/main/java/org/apache/sling/maven/bundlesupport/BundleInstallMojo.java
@@ -52,7 +52,7 @@ public class BundleInstallMojo extends AbstractBundleInstallMojo {
     }
 
     @Override
-    protected File getBundleFileName() {
+    protected File getBundleFileName() throws MojoExecutionException {
         File file = project.getArtifact().getFile();
         if (isBundleFile(file)) {
             return file;
@@ -65,7 +65,7 @@ public class BundleInstallMojo extends AbstractBundleInstallMojo {
                 getLog().debug("No bundle found in secondary artifact " + file);
             }
         }
-        return null;
+        throw new MojoExecutionException("No attached bundle found for this Maven project, for standalone usage use goal 'install-file' instead!");
     }
 
     private boolean isBundleFile(File file) {