sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1570154 - in /sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport: ./ bundlelist/
Date Thu, 20 Feb 2014 11:47:18 GMT
Author: fmeschbe
Date: Thu Feb 20 11:47:18 2014
New Revision: 1570154

URL: http://svn.apache.org/r1570154
Log:
SLING-3401 Support multiple bundles for the jarWebSupport

The solution is to extend the ArtifactDefinition to internally support
a collection of ArtifactDefinitions named "bundles". 

Modified:
    sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
    sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
    sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
    sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/LaunchpadPluginLifecycleParticipant.java
    sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
    sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java

Modified: sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java?rev=1570154&r1=1570153&r2=1570154&view=diff
==============================================================================
--- sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
(original)
+++ sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
Thu Feb 20 11:47:18 2014
@@ -234,6 +234,6 @@ public abstract class AbstractLaunchpadS
      */
     @Override
     protected void initBundleList(BundleList bundleList) {
-        bundleList.add(jarWebSupport.toBundle());
+        bundleList.add(jarWebSupport.toBundleList());
     }
 }

Modified: sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java?rev=1570154&r1=1570153&r2=1570154&view=diff
==============================================================================
--- sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
(original)
+++ sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
Thu Feb 20 11:47:18 2014
@@ -255,7 +255,7 @@ public abstract class AbstractUsingBundl
         // add additional bundles
         if (additionalBundles != null) {
             for (ArtifactDefinition def : additionalBundles) {
-                initializedBundleList.add(def.toBundle());
+                initializedBundleList.add(def.toBundleList());
             }
         }
 
@@ -273,7 +273,7 @@ public abstract class AbstractUsingBundl
         // handle exclusions
         if (bundleExclusions != null) {
             for (ArtifactDefinition def : bundleExclusions) {
-                initializedBundleList.remove(def.toBundle(), false);
+                initializedBundleList.remove(def.toBundleList(), false);
             }
         }
 

Modified: sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java?rev=1570154&r1=1570153&r2=1570154&view=diff
==============================================================================
--- sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
(original)
+++ sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ArtifactDefinition.java
Thu Feb 20 11:47:18 2014
@@ -18,6 +18,9 @@ package org.apache.sling.maven.projectsu
 
 import static org.apache.sling.maven.projectsupport.BundleListUtils.nodeValue;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.maven.model.Dependency;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
 import org.codehaus.plexus.util.StringUtils;
@@ -49,6 +52,8 @@ public class ArtifactDefinition {
     /** The artifact run modes */
     private String runModes;
 
+    private ArtifactDefinition[] bundles;
+
     public ArtifactDefinition() {
     }
 
@@ -176,54 +181,80 @@ public class ArtifactDefinition {
      */
     public void initDefaults(String groupId, String artifactId, String version,
             String type, String classifier, int startLevel) {
-        if (this.groupId == null && StringUtils.isNotEmpty(groupId)) {
-            this.groupId = groupId;
-        }
-        if (this.artifactId == null && StringUtils.isNotEmpty(artifactId)) {
-            this.artifactId = artifactId;
-        }
-        if (this.version == null && StringUtils.isNotEmpty(version)) {
-            this.version = version;
-        }
-        if (this.type == null && StringUtils.isNotEmpty(groupId)) {
-            this.type = type;
-        }
-        if (this.classifier == null && StringUtils.isNotEmpty(classifier)) {
-            this.classifier = classifier;
+        if (this.bundles == null) {
+            if (this.groupId == null && StringUtils.isNotEmpty(groupId)) {
+                this.groupId = groupId;
+            }
+            if (this.artifactId == null && StringUtils.isNotEmpty(artifactId)) {
+                this.artifactId = artifactId;
+            }
+            if (this.version == null && StringUtils.isNotEmpty(version)) {
+                this.version = version;
+            }
+            if (this.type == null && StringUtils.isNotEmpty(groupId)) {
+                this.type = type;
+            }
+            if (this.classifier == null && StringUtils.isNotEmpty(classifier)) {
+                this.classifier = classifier;
+            }
+            if (this.startLevel == 0) {
+                this.startLevel = startLevel;
+            }
+        } else {
+            for (ArtifactDefinition bundle : this.bundles) {
+                bundle.initDefaults(groupId, artifactId, version, type, classifier, startLevel);
+            }
+        }
+    }
+
+    public List<Bundle> toBundleList() {
+        ArrayList<Bundle> bundleList = new ArrayList<Bundle>();
+
+        if (bundles == null) {
+            Bundle bnd = new Bundle();
+            bnd.setArtifactId(artifactId);
+            bnd.setGroupId(groupId);
+            bnd.setVersion(version);
+            if (type != null) {
+                bnd.setType(type);
+            }
+            bnd.setClassifier(classifier);
+            bnd.setStartLevel(startLevel);
+            bundleList.add(bnd);
+        } else {
+            for (ArtifactDefinition bundle : bundles) {
+                bundleList.addAll(bundle.toBundleList());
+            }
+        }
+
+        return bundleList;
+    }
+
+    public List<Dependency> toDependencyList(String scope) {
+        ArrayList<Dependency> depList = new ArrayList<Dependency>();
+
+        if (bundles == null) {
+            Dependency dep = new Dependency();
+            dep.setArtifactId(artifactId);
+            dep.setGroupId(groupId);
+            dep.setVersion(version);
+            if (type != null) {
+                dep.setType(type);
+            }
+            dep.setClassifier(classifier);
+            dep.setScope(scope);
+            depList.add(dep);
+        } else {
+            for (ArtifactDefinition bundle : bundles) {
+                depList.addAll(bundle.toDependencyList(scope));
+            }
         }
-        if (this.startLevel == 0) {
-            this.startLevel = startLevel;
-        }
-    }
-
-    public Bundle toBundle() {
-        Bundle bnd = new Bundle();
-        bnd.setArtifactId(artifactId);
-        bnd.setGroupId(groupId);
-        bnd.setVersion(version);
-        if (type != null) {
-            bnd.setType(type);
-        }
-        bnd.setClassifier(classifier);
-        bnd.setStartLevel(startLevel);
-        return bnd;
-    }
 
-    public Dependency toDependency(String scope) {
-        Dependency dep = new Dependency();
-        dep.setArtifactId(artifactId);
-        dep.setGroupId(groupId);
-        dep.setVersion(version);
-        if (type != null) {
-            dep.setType(type);
-        }
-        dep.setClassifier(classifier);
-        dep.setScope(scope);
-        return dep;
+        return depList;
     }
 
-    public static Dependency toDependency(Bundle bundle, String scope) {
-        return new ArtifactDefinition(bundle, 0).toDependency(scope);
+    public static List<Dependency> toDependencyList(Bundle bundle, String scope) {
+        return new ArtifactDefinition(bundle, 0).toDependencyList(scope);
     }
 
 }

Modified: sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/LaunchpadPluginLifecycleParticipant.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/LaunchpadPluginLifecycleParticipant.java?rev=1570154&r1=1570153&r2=1570154&view=diff
==============================================================================
--- sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/LaunchpadPluginLifecycleParticipant.java
(original)
+++ sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/LaunchpadPluginLifecycleParticipant.java
Thu Feb 20 11:47:18 2014
@@ -5,9 +5,9 @@
  * licenses this file to You under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -50,7 +50,7 @@ import org.codehaus.plexus.util.xml.pull
 public class LaunchpadPluginLifecycleParticipant extends AbstractMavenLifecycleParticipant
{
 
     private static final String PLUGIN_ID = "maven-launchpad-plugin";
-    
+
     private static final String PROVIDED = "provided";
 
     @Requirement
@@ -100,43 +100,43 @@ public class LaunchpadPluginLifecyclePar
 
         void addDependencies() throws Exception {
             readConfiguration();
-            
+
             addBundleListDependencies();
 
             if (hasPreparePackageExecution()) {
                 if (includeDefaultBundles && !isCurrentArtifact(project, defaultBundleList))
{
                     log.debug(String.format("adding default bundle list (%s) to dependencies
of project %s", defaultBundleList, project));
-                    project.getDependencies().add(defaultBundleList.toDependency(PROVIDED));
+                    project.getDependencies().addAll(defaultBundleList.toDependencyList(PROVIDED));
                 }
 
                 if (hasJarPackagingExecution()) {
                     log.debug(String.format("adding jar web support (%s) to dependencies
of project %s", jarWebSupport, project));
-                    project.getDependencies().add(jarWebSupport.toDependency(PROVIDED));
+                    project.getDependencies().addAll(jarWebSupport.toDependencyList(PROVIDED));
                 }
             }
         }
 
         private void addBundleListDependencies() throws IOException, XmlPullParserException,
MojoExecutionException {
             BundleList bundleList;
-            
+
             if (bundleListFile.exists()) {
                 bundleList = readBundleList(bundleListFile);
             } else {
                 bundleList = new BundleList();
             }
-            
+
             if (additionalBundles != null) {
                 for (ArtifactDefinition def : additionalBundles) {
-                    bundleList.add(def.toBundle());
+                    bundleList.add(def.toBundleList());
                 }
             }
-            
+
             interpolateProperties(bundleList, project, session);
-            
+
             for (StartLevel startLevel : bundleList.getStartLevels()) {
                 for (Bundle bundle : startLevel.getBundles()) {
                     log.debug(String.format("adding bundle (%s) from bundle list to dependencies
of project %s", bundle, project));
-                    project.getDependencies().add(ArtifactDefinition.toDependency(bundle,
PROVIDED));
+                    project.getDependencies().addAll(ArtifactDefinition.toDependencyList(bundle,
PROVIDED));
                 }
             }
         }
@@ -161,10 +161,10 @@ public class LaunchpadPluginLifecyclePar
                 if (bundleListFileConfig != null) {
                     bundleListFile = new File(project.getBasedir(), bundleListFileConfig.getValue());
                 }
-                
+
                 configureAdditionalBundles(configuration);
             }
-            
+
             for (PluginExecution execution : plugin.getExecutions()) {
                 Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration();
                 if (executionConfiguration != null) {

Modified: sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java?rev=1570154&r1=1570153&r2=1570154&view=diff
==============================================================================
--- sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
(original)
+++ sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
Thu Feb 20 11:47:18 2014
@@ -136,7 +136,7 @@ public class PreparePackageMojo extends 
     @Override
     protected void initBundleList(BundleList bundleList) {
         if (packaging.equals(JAR)) {
-            bundleList.add(jarWebSupport.toBundle());
+            bundleList.add(jarWebSupport.toBundleList());
         }
     }
 

Modified: sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java?rev=1570154&r1=1570153&r2=1570154&view=diff
==============================================================================
--- sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
(original)
+++ sling/trunk/tooling/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
Thu Feb 20 11:47:18 2014
@@ -39,16 +39,19 @@ public abstract class BaseBundleList {
         return null;
     }
 
-    public boolean remove(Bundle bundle, boolean compareVersions) {
-        for (StartLevel sl : getStartLevels()) {
-            if (sl.removeBundle(bundle, compareVersions)) {
-                return true;
+    public boolean remove(List<Bundle> bundles, boolean compareVersions) {
+        boolean result = false;
+        for (Bundle bundle : bundles) {
+            for (StartLevel sl : getStartLevels()) {
+                if (sl.removeBundle(bundle, compareVersions)) {
+                    result = true;
+                    break;
+                }
             }
         }
-        return false;
+        return result;
     }
 
-
     /**
      * Merge the current bundle list with an additional list.
      * @see #add(Bundle)
@@ -69,8 +72,10 @@ public abstract class BaseBundleList {
      *
      * @param newBnd the bundle to add
      */
-    public void add(Bundle newBnd) {
-       add(null, newBnd);
+    public void add(List<Bundle> newBnd) {
+        for (Bundle bundle : newBnd) {
+            add(null, bundle);
+        }
     }
 
     /**



Mime
View raw message