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 10:28:30 UTC

[sling-slingstart-maven-plugin] 11/13: SLING-6556 allow to reference the main artifact of the build within the model (in case it has been built already)

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

rombert pushed a commit to annotated tag slingstart-maven-plugin-1.7.2
in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git

commit 891ecd06700a97462d216a04bf6078d3ddd2d6ab
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Feb 23 14:29:50 2017 +0000

    SLING-6556 allow to reference the main artifact of the build within the model (in case it has been built already)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1784136 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/maven/slingstart/PreparePackageMojo.java | 25 ++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
index 8ffa677..292bfc9 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
@@ -42,6 +42,7 @@ import org.apache.maven.MavenExecutionException;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Component;
@@ -116,6 +117,9 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
     @Component
     private ArtifactResolver resolver;
 
+    @Parameter(defaultValue = "${mojoExecution}", readonly = true, required = true)
+    protected MojoExecution mojoExecution;
+
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         final Model model = ProjectHelper.getEffectiveModel(this.project, getResolverOptions());
@@ -270,8 +274,25 @@ public class PreparePackageMojo extends AbstractSlingStartMojo {
                             break;
                         }
                     }
-                    if ( artifact == null ) {
-                        throw new MojoExecutionException("Unable to find artifact from same project: " + a.toMvnUrl());
+                    // check if the artifact is bound already?
+                    if (project.getArtifact().getFile().exists()) {
+                        if (a.getClassifier() != null) {
+                            if (a.getClassifier().equals(project.getArtifact().getClassifier())) {
+                                artifact = project.getArtifact();
+                            } else {
+                                throw new MojoExecutionException(
+                                        "Unable to find artifact from same project with the given classifier: " + a.toMvnUrl());
+                            }
+                        } else {
+                            if (project.getArtifact().getClassifier() == null) {
+                                artifact = project.getArtifact();
+                            } else {
+                                throw new MojoExecutionException("Unable to find artifact with no classifier from same project, because the main artifact is bound to classifier " + project.getArtifact().getClassifier());
+                            }
+                        }
+                    } else {
+                        throw new MojoExecutionException("You must not reference artifact " + a.toMvnUrl()
+                                + " from the model which is not yet available in the phase '" + mojoExecution.getLifecyclePhase()+ ". Make sure to execute this goal after phase 'package'");
                     }
                 } else {
                     artifact = ModelUtils.getArtifact(this.project, this.mavenSession, this.artifactHandlerManager, this.resolver,

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.