incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1408828 - in /sling/trunk/maven/maven-launchpad-plugin/src/main: java/org/apache/sling/maven/projectsupport/ mdo/
Date Tue, 13 Nov 2012 16:46:15 GMT
Author: cziegeler
Date: Tue Nov 13 16:46:14 2012
New Revision: 1408828

URL: http://svn.apache.org/viewvc?rev=1408828&view=rev
Log:
SLING.2649 : Add support for run modes

Modified:
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java?rev=1408828&r1=1408827&r2=1408828&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
Tue Nov 13 16:46:14 2012
@@ -18,6 +18,8 @@ package org.apache.sling.maven.projectsu
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Set;
+import java.util.TreeSet;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -48,20 +50,41 @@ public abstract class AbstractLaunchpadF
     private String bundlesDirectory;
 
     /**
-     * The directory which contains the bootstraop bundle directories.
+     * The directory which contains the bootstrap bundle directories.
      *
      * @parameter
      */
     private String bootDirectory;
 
-    protected String getPathForArtifact(final int startLevel, final String artifactName)
{
+    protected String getPathForArtifact(final int startLevel, final String artifactName,
final String runModes) {
+        final Set<String> runModesList = new TreeSet<String>();
+        if (runModes != null ) {
+            for(final String mode : runModes.split(",")) {
+                if ( mode.trim().length() > 0 ) {
+                    runModesList.add(mode);
+                }
+            }
+        }
+        final String runModeExt;
+        if ( runModesList.size() == 0 ) {
+            runModeExt = "";
+        } else {
+            final StringBuilder sb = new StringBuilder();
+            for(final String n : runModesList ) {
+                sb.append('.');
+                sb.append(n);
+            }
+            runModeExt = sb.toString();
+        }
         if ( startLevel == -1 && bootDirectory != null ) {
-            return String.format("%s/%s/1/%s", baseDestination, bootDirectory,
+            return String.format("%s/%s%s/1/%s", baseDestination, bootDirectory,
+                    runModeExt,
                     artifactName);
         }
-        return String.format("%s/%s/%s/%s", baseDestination, bundlesDirectory,
+        return String.format("%s/%s%s/%s/%s", baseDestination, bundlesDirectory,
+                runModeExt,
                 (startLevel == -1 ? 1 : startLevel),
-                artifactName);
+                artifactName, runModeExt);
     }
 
     protected void copyBundles(BundleList bundles, File outputDirectory) throws MojoExecutionException
{
@@ -74,11 +97,11 @@ public abstract class AbstractLaunchpadF
 
     protected void copy(ArtifactDefinition additionalBundle, File outputDirectory) throws
MojoExecutionException {
         Artifact artifact = getArtifact(additionalBundle);
-        copy(artifact.getFile(), additionalBundle.getStartLevel(), outputDirectory);
+        copy(artifact.getFile(), additionalBundle.getStartLevel(), additionalBundle.getRunModes(),
outputDirectory);
     }
 
-    protected void copy(File file, int startLevel, File outputDirectory) throws MojoExecutionException
{
-        File destination = new File(outputDirectory, getPathForArtifact(startLevel, file.getName().replace('/',
File.separatorChar)));
+    protected void copy(File file, int startLevel, String runModes, File outputDirectory)
throws MojoExecutionException {
+        File destination = new File(outputDirectory, getPathForArtifact(startLevel, file.getName().replace('/',
File.separatorChar), runModes));
         if (shouldCopy(file, destination)) {
             getLog().info(String.format("Copying bundle from %s to %s", file.getPath(), destination.getPath()));
             try {

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java?rev=1408828&r1=1408827&r2=1408828&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
Tue Nov 13 16:46:14 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.sling.maven.projectsupport;
 
-import static org.apache.sling.maven.projectsupport.BundleListUtils.*;
+import static org.apache.sling.maven.projectsupport.BundleListUtils.nodeValue;
 
 import org.apache.maven.model.Dependency;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
@@ -46,9 +46,12 @@ public class ArtifactDefinition {
     /** The artifact version */
     private String version;
 
+    /** The artifact run modes */
+    private String runModes;
+
     public ArtifactDefinition() {
     }
-    
+
     public ArtifactDefinition(Bundle bundle, int startLevel) {
         this.groupId = bundle.getGroupId();
         this.artifactId = bundle.getArtifactId();
@@ -56,6 +59,7 @@ public class ArtifactDefinition {
         this.version = bundle.getVersion();
         this.classifier = bundle.getClassifier();
         this.startLevel = startLevel;
+        this.runModes = bundle.getRunModes();
     }
 
     public ArtifactDefinition(Xpp3Dom config) {
@@ -65,6 +69,7 @@ public class ArtifactDefinition {
         this.version = nodeValue(config, "version", null);
         this.classifier = nodeValue(config, "classifier", null);
         this.startLevel = nodeValue(config, "startLevel", 0);
+        this.runModes = nodeValue(config, "runModes", null);
     }
 
     public String getArtifactId() {
@@ -91,6 +96,10 @@ public class ArtifactDefinition {
         return version;
     }
 
+    public String getRunModes() {
+        return runModes;
+    }
+
     public void setArtifactId(String artifactId) {
         this.artifactId = artifactId;
     }
@@ -119,7 +128,8 @@ public class ArtifactDefinition {
     public String toString() {
         return "ArtifactDefinition [artifactId=" + artifactId + ", classifier="
                 + classifier + ", groupId=" + groupId + ", startLevel="
-                + startLevel + ", type=" + type + ", version=" + version + "]";
+                + startLevel + ", type=" + type + ", version=" + version
+                + ", runModes=" + runModes + "]";
     }
 
     /**
@@ -198,7 +208,7 @@ public class ArtifactDefinition {
         bnd.setStartLevel(startLevel);
         return bnd;
     }
-    
+
     public Dependency toDependency(String scope) {
         Dependency dep = new Dependency();
         dep.setArtifactId(artifactId);
@@ -211,7 +221,7 @@ public class ArtifactDefinition {
         dep.setScope(scope);
         return dep;
     }
-    
+
     public static Dependency toDependency(Bundle bundle, String scope) {
         return new ArtifactDefinition(bundle, 0).toDependency(scope);
     }

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java?rev=1408828&r1=1408827&r2=1408828&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
Tue Nov 13 16:46:14 2012
@@ -81,7 +81,7 @@ public class CreateBundleJarMojo extends
             for (Bundle bundle : level.getBundles()) {
                 Artifact artifact = getArtifact(new ArtifactDefinition(bundle,
                         level.getStartLevel()));
-                final String destFileName = getPathForArtifact(level.getStartLevel(), artifact.getFile().getName());
+                final String destFileName = getPathForArtifact(level.getStartLevel(), bundle.getRunModes(),
artifact.getFile().getName());
                 try {
                     jarArchiver.addFile(artifact.getFile(), destFileName);
                 } catch (ArchiverException e) {
@@ -168,13 +168,13 @@ public class CreateBundleJarMojo extends
         DirectoryScanner scanner = new DirectoryScanner();
         scanner.setBasedir(resource.getDirectory());
         if (resource.getIncludes() != null && !resource.getIncludes().isEmpty())
{
-            scanner.setIncludes((String[]) resource.getIncludes().toArray(
+            scanner.setIncludes(resource.getIncludes().toArray(
                     new String[resource.getIncludes().size()]));
         } else {
             scanner.setIncludes(DEFAULT_INCLUDES);
         }
         if (resource.getExcludes() != null && !resource.getExcludes().isEmpty())
{
-            scanner.setExcludes((String[]) resource.getExcludes().toArray(
+            scanner.setExcludes(resource.getExcludes().toArray(
                     new String[resource.getExcludes().size()]));
         }
 

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java?rev=1408828&r1=1408827&r2=1408828&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
Tue Nov 13 16:46:14 2012
@@ -60,9 +60,10 @@ public class PrepareTestWebAppMojo exten
      */
     private ArtifactHandlerManager artifactHandlerManager;
 
+    @Override
     public void executeWithArtifacts() throws MojoExecutionException, MojoFailureException
{
         super.executeWithArtifacts();
-        copy(getPrimaryArtifact(), startLevel, getOutputDirectory());
+        copy(getPrimaryArtifact(), startLevel, null, getOutputDirectory());
     }
 
     @Override

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml?rev=1408828&r1=1408827&r2=1408828&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml (original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml Tue Nov 13 16:46:14
2012
@@ -107,6 +107,11 @@
                     <type>int</type>
                     <required>true</required>
                 </field>
+                <field>
+                    <name>runModes</name>
+                    <version>1.0.0</version>
+                    <type>String</type>
+                </field>
             </fields>
         </class>
     </classes>



Mime
View raw message