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 2017/02/22 09:10:29 UTC

svn commit: r1783983 - in /sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart: AbstractSlingStartMojo.java ModelPreprocessor.java PackageMojo.java PreparePackageMojo.java

Author: kwin
Date: Wed Feb 22 09:10:29 2017
New Revision: 1783983

URL: http://svn.apache.org/viewvc?rev=1783983&view=rev
Log:
SLING-6541 allow to disable the Maven classpath enrichment

improve documentation of parameters being evaluated outside of mojos

Modified:
    sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java
    sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java
    sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PackageMojo.java
    sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java

Modified: sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java?rev=1783983&r1=1783982&r2=1783983&view=diff
==============================================================================
--- sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java (original)
+++ sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/AbstractSlingStartMojo.java Wed Feb 22 09:10:29 2017
@@ -37,13 +37,22 @@ public abstract class AbstractSlingStart
      * As default first <code>${basedir}/src/main/provisioning</code> and then
      * <code>${basedir}/src/test/provisioning</code> is used 
      * (in case the former does not exist).
+     * <p>
+     * This parameter is evaluated in the {@link ModelPreprocessor}, i.e. outside of the Mojo execution therefore it must not be 
+     * configured within an <a href="https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag">execution tag</a>
+     * but rather in the global configuration section for this plugin.
+     * </p>
      */
     @Parameter(defaultValue="${basedir}/src/main/provisioning")
     private File modelDirectory;
 
     /**
      * The model file name pattern to consider.
-     * This parameter is evaluated in the {@link DependencyLifecycleParticipant}.
+     * <p>
+     * This parameter is evaluated in the {@link ModelPreprocessor}, i.e. outside of the Mojo execution therefore it must not be 
+     * configured within an <a href="https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag">execution tag</a>
+     * but rather in the global configuration section for this plugin.
+     * </p>
      */
     @Parameter(defaultValue=DEFAULT_MODEL_PATTERN)
     private String modelPattern;
@@ -52,12 +61,28 @@ public abstract class AbstractSlingStart
 
     /**
      * Inlined model. Is processed first and afterwards merged with any model found in {@link #modelDirectory}.
-     * This parameter is evaluated in the {@link DependencyLifecycleParticipant}.
+     * <p>
+     * This parameter is evaluated in the {@link ModelPreprocessor}, i.e. outside of the Mojo execution therefore it must not be 
+     * configured within an <a href="https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag">execution tag</a>
+     * but rather in the global configuration section for this plugin.
+     * </p>
      * @since 1.3
      * @see <a href="https://issues.apache.org/jira/browse/SLING-4912">SLING-4912</a>
      */
     @Parameter
     private String model;
+    
+    static final String CONFIGURATION_NAME_DISABLE_EXTENDING_CLASSPATH = "disableExtendingMavenClasspath";
+    /**
+     * If set to {@code true} the Maven classpath (either scope "provided" or "test") will not be extended by the artifacts being referenced in the model.
+     * <p>
+     * This parameter is evaluated in the {@link ModelPreprocessor}, i.e. outside of the Mojo execution therefore it must not be 
+     * configured within an <a href="https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag">execution tag</a>
+     * but rather in the global configuration section for this plugin.
+     * </p>
+     */
+    @Parameter(name=CONFIGURATION_NAME_DISABLE_EXTENDING_CLASSPATH)
+    private boolean disableExtendingMavenClasspath;
 
     @Parameter(property = "project", readonly = true, required = true)
     protected MavenProject project;
@@ -69,12 +94,6 @@ public abstract class AbstractSlingStart
     protected MavenSession mavenSession;
 
     /**
-     * If set to {@code true} creates a WAR artifact in addition to the standalone JAR from the model.
-     */
-    @Parameter(defaultValue="false")
-    protected boolean createWebapp;
-
-    /**
      * If set to true, properties from the Maven POM can be used as variables in the provisioning files.
      * The resolved variables are added to the generated provisioning file, so other tools using this model
      * do not have to resolve them themselves.

Modified: sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java?rev=1783983&r1=1783982&r2=1783983&view=diff
==============================================================================
--- sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java (original)
+++ sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/ModelPreprocessor.java Wed Feb 22 09:10:29 2017
@@ -52,6 +52,7 @@ import org.apache.sling.provisioning.mod
 import org.apache.sling.provisioning.model.RunMode;
 import org.apache.sling.provisioning.model.Traceable;
 import org.apache.sling.provisioning.model.io.ModelReader;
+import org.codehaus.plexus.component.configurator.converters.basic.BooleanConverter;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
@@ -64,6 +65,7 @@ public class ModelPreprocessor {
         public Model        localModel;
         public boolean      done = false;
         public Model        model;
+        public boolean      extendMavenClassPath = true;
         public final Map<org.apache.sling.provisioning.model.Artifact, Model> includedModels = new HashMap<org.apache.sling.provisioning.model.Artifact, Model>();
 
     }
@@ -135,6 +137,9 @@ public class ModelPreprocessor {
 
         // process attachments
         processAttachments(env, info);
+        
+        // is the maven classpath supposed to be extended?
+        info.extendMavenClassPath = !nodeBooleanValue(info.plugin, AbstractSlingStartMojo.CONFIGURATION_NAME_DISABLE_EXTENDING_CLASSPATH, false);
 
         // check for setting version
         if ( nodeBooleanValue(info.plugin, "setFeatureVersions", false) ) {
@@ -172,7 +177,12 @@ public class ModelPreprocessor {
             throw new MavenExecutionException("Unable to create model file for " + info.project + " : " + errors, (File)null);
         }
 
-        addDependenciesFromModel(env, info, scope);
+        if (info.extendMavenClassPath) {
+            addDependenciesFromModel(env, info, scope);
+            env.logger.info("Extended Maven classpath (scope '" + scope + "') by the dependencies extracted from the Sling model.");
+        } else {
+            env.logger.debug("Do not enrich Maven classpath with Sling model!");
+        }
 
         try {
            ProjectHelper.storeProjectInfo(info);

Modified: sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PackageMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PackageMojo.java?rev=1783983&r1=1783982&r2=1783983&view=diff
==============================================================================
--- sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PackageMojo.java (original)
+++ sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PackageMojo.java Wed Feb 22 09:10:29 2017
@@ -28,6 +28,7 @@ import org.apache.maven.plugin.MojoFailu
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 
@@ -45,6 +46,13 @@ public class PackageMojo extends Abstrac
 
     private static final String[] EXCLUDES_MANIFEST = new String[] {"META-INF/MANIFEST.MF"};
 
+
+    /**
+     * If set to {@code true} creates a WAR artifact in addition to the standalone JAR from the model.
+     */
+    @Parameter(defaultValue="false")
+    protected boolean createWebapp;
+
     /**
      * The Jar archiver.
      */

Modified: sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java?rev=1783983&r1=1783982&r2=1783983&view=diff
==============================================================================
--- sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java (original)
+++ sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/PreparePackageMojo.java Wed Feb 22 09:10:29 2017
@@ -47,6 +47,7 @@ import org.apache.maven.plugin.MojoFailu
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.sling.commons.osgi.BSNRenamer;
 import org.apache.sling.provisioning.model.ArtifactGroup;
@@ -94,6 +95,12 @@ public class PreparePackageMojo extends
     private static final String PROPERTIES_FILE = "sling_install.properties";
 
     /**
+     * If set to {@code true} creates a WAR artifact in addition to the standalone JAR from the model.
+     */
+    @Parameter(defaultValue="false")
+    protected boolean createWebapp;
+
+    /**
      * To look up Archiver/UnArchiver implementations
      */
     @Component