incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1186417 - in /sling/trunk: launchpad/test-bundles/ launchpad/test-bundles/src/main/bundles/ launchpad/testing-war/src/main/bundles/ launchpad/testing/ launchpad/testing/src/main/bundles/ maven/maven-launchpad-plugin/ maven/maven-launchpad-...
Date Wed, 19 Oct 2011 19:14:54 GMT
Author: justin
Date: Wed Oct 19 19:14:54 2011
New Revision: 1186417

URL: http://svn.apache.org/viewvc?rev=1186417&view=rev
Log:
SLING-2194 - generating bundle list content from a project's dependencies; refactoring testing
projects to use this feature.

Removed:
    sling/trunk/launchpad/test-bundles/src/main/bundles/list.xml
    sling/trunk/launchpad/testing-war/src/main/bundles/list.xml
    sling/trunk/launchpad/testing/src/main/bundles/list.xml
Modified:
    sling/trunk/launchpad/test-bundles/pom.xml
    sling/trunk/launchpad/testing/pom.xml
    sling/trunk/maven/maven-launchpad-plugin/pom.xml
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.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/AttachPartialBundleListMojo.java

Modified: sling/trunk/launchpad/test-bundles/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-bundles/pom.xml?rev=1186417&r1=1186416&r2=1186417&view=diff
==============================================================================
--- sling/trunk/launchpad/test-bundles/pom.xml (original)
+++ sling/trunk/launchpad/test-bundles/pom.xml Wed Oct 19 19:14:54 2011
@@ -39,9 +39,31 @@
             <plugin>
                 <groupId>org.apache.sling</groupId>
                 <artifactId>maven-launchpad-plugin</artifactId>
-                <version>2.1.0</version>
+                <version>2.1.1-SNAPSHOT</version>
                 <extensions>true</extensions>
+                <configuration>
+                    <dependencyStartLevel>0</dependencyStartLevel>
+                </configuration>
             </plugin>
         </plugins>
     </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.launchpad.test-services</artifactId>
+            <version>2.0.9-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.launchpad.test-services-war</artifactId>
+            <version>2.0.8</version>
+            <type>war</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.servlets.compat</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
 </project>
\ No newline at end of file

Modified: sling/trunk/launchpad/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/pom.xml?rev=1186417&r1=1186416&r2=1186417&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/pom.xml (original)
+++ sling/trunk/launchpad/testing/pom.xml Wed Oct 19 19:14:54 2011
@@ -492,14 +492,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-jcr2dav</artifactId>
-            <version>2.0.0</version>
-            <scope>test</scope>
-        </dependency>
-
-
         <!-- Dependencies for the Test Build and Run -->
         <dependency>
             <groupId>org.apache.sling</groupId>

Modified: sling/trunk/maven/maven-launchpad-plugin/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/pom.xml?rev=1186417&r1=1186416&r2=1186417&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/pom.xml (original)
+++ sling/trunk/maven/maven-launchpad-plugin/pom.xml Wed Oct 19 19:14:54 2011
@@ -21,7 +21,6 @@
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
-    <groupId>org.apache.sling</groupId>
     <artifactId>maven-launchpad-plugin</artifactId>
     <version>2.1.1-SNAPSHOT</version>
     <packaging>maven-plugin</packaging>

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java?rev=1186417&r1=1186416&r2=1186417&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
Wed Oct 19 19:14:54 2011
@@ -17,10 +17,17 @@
 package org.apache.sling.maven.projectsupport;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.List;
 
+import org.apache.maven.model.Dependency;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Reader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 public abstract class AbstractBundleListMojo extends AbstractMojo {
 
@@ -90,7 +97,42 @@ public abstract class AbstractBundleList
      */
     protected File standaloneSlingBootstrap;
 
+    /**
+     * @parameter expression="${ignoreBundleListConfig}"
+     *            default-value="false"
+     */
+    protected boolean ignoreBundleListConfig;
+
+    /**
+     * The start level to be used when generating the bundle list.
+     * 
+     * @parameter default-value="-1"
+     */
+    private int dependencyStartLevel;
+
     protected File getConfigDirectory() {
         return this.configDirectory;
     }
+
+    protected BundleList readBundleList(File file) throws IOException, XmlPullParserException
{
+        BundleListXpp3Reader reader = new BundleListXpp3Reader();
+        FileInputStream fis = new FileInputStream(file);
+        try {
+            return reader.read(fis);
+        } finally {
+            fis.close();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void addDependencies(final BundleList bundleList) {
+        if (dependencyStartLevel >= 0) {
+            final List<Dependency> dependencies = project.getDependencies();
+            for (Dependency dependency : dependencies) {
+                if (!PARTIAL.equals(dependency.getType())) {
+                    bundleList.add(ArtifactDefinition.toBundle(dependency, dependencyStartLevel));
+                }
+            }
+        }
+    }
 }

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java?rev=1186417&r1=1186416&r2=1186417&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
Wed Oct 19 19:14:54 2011
@@ -17,7 +17,6 @@
 package org.apache.sling.maven.projectsupport;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.Reader;
@@ -48,7 +47,6 @@ import org.apache.maven.shared.filtering
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel;
-import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Reader;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
 import org.codehaus.plexus.interpolation.InterpolationException;
@@ -359,6 +357,7 @@ public abstract class AbstractUsingBundl
                 bundleList.add(def.toBundle());
             }
         }
+        addDependencies(bundleList);
         if (bundleExclusions != null) {
             for (ArtifactDefinition def : bundleExclusions) {
                 bundleList.remove(def.toBundle(), false);
@@ -513,16 +512,6 @@ public abstract class AbstractUsingBundl
         return base;
     }
 
-    private BundleList readBundleList(File file) throws IOException, XmlPullParserException
{
-        BundleListXpp3Reader reader = new BundleListXpp3Reader();
-        FileInputStream fis = new FileInputStream(file);
-        try {
-            return reader.read(fis);
-        } finally {
-            fis.close();
-        }
-    }
-
     private void copyProperties(final Properties source, final Properties dest) {
         final Enumeration<Object> keys = source.keys();
         while ( keys.hasMoreElements() ) {

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=1186417&r1=1186416&r2=1186417&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
Wed Oct 19 19:14:54 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.maven.projectsupport;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Dependency;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -45,16 +47,34 @@ public class ArtifactDefinition {
     public ArtifactDefinition() {
     }
 
+    public ArtifactDefinition(Artifact artifact, int startLevel) {
+        this.groupId = artifact.getGroupId();
+        this.artifactId = artifact.getArtifactId();
+        this.type = artifact.getType();
+        this.version = artifact.getVersion();
+        this.classifier = artifact.getClassifier();
+        this.startLevel = startLevel;
+    }
+
+    public ArtifactDefinition(Dependency dependency, int startLevel) {
+        this.groupId = dependency.getGroupId();
+        this.artifactId = dependency.getArtifactId();
+        this.type = dependency.getType();
+        this.version = dependency.getVersion();
+        this.classifier = dependency.getClassifier();
+        this.startLevel = startLevel;
+    }
+    
     public ArtifactDefinition(Bundle bundle, int startLevel) {
-		this.groupId = bundle.getGroupId();
-		this.artifactId = bundle.getArtifactId();
-		this.type = bundle.getType();
-		this.version = bundle.getVersion();
-		this.classifier = bundle.getClassifier();
-		this.startLevel = startLevel;
-	}
+        this.groupId = bundle.getGroupId();
+        this.artifactId = bundle.getArtifactId();
+        this.type = bundle.getType();
+        this.version = bundle.getVersion();
+        this.classifier = bundle.getClassifier();
+        this.startLevel = startLevel;
+    }
 
-	public String getArtifactId() {
+    public String getArtifactId() {
         return artifactId;
     }
 
@@ -185,5 +205,13 @@ public class ArtifactDefinition {
         bnd.setStartLevel(startLevel);
         return bnd;
     }
+    
+    public static Bundle toBundle(Artifact artifact, int startLevel) {
+        return new ArtifactDefinition(artifact, startLevel).toBundle();
+    }
+    
+    public static Bundle toBundle(Dependency dependency, int startLevel) {
+        return new ArtifactDefinition(dependency, startLevel).toBundle();
+    }
 
 }

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java?rev=1186417&r1=1186416&r2=1186417&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
Wed Oct 19 19:14:54 2011
@@ -17,13 +17,17 @@
 package org.apache.sling.maven.projectsupport;
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
+import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Writer;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.zip.ZipArchiver;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 /**
  * Attaches the bundle list as a project artifact.
@@ -54,12 +58,11 @@ public class AttachPartialBundleListMojo
      * @parameter default-value="${project.build.directory}/bundleListconfig"
      */
     private File configOutputDir;
-
+    
     /**
-     * @parameter expression="${ignoreBundleListConfig}"
-     *            default-value="false"
+     * @parameter default-value="${project.build.directory}/list.xml"
      */
-    private boolean ignoreBundleListConfig;
+    private File bundleListOutput;
 
     /**
      * The zip archiver.
@@ -69,7 +72,30 @@ public class AttachPartialBundleListMojo
     private ZipArchiver zipArchiver;
 
     public void execute() throws MojoExecutionException, MojoFailureException {
-        project.getArtifact().setFile(bundleListFile);
+        final BundleList bundleList;
+        if (bundleListFile.exists()) {
+            try {
+                bundleList = readBundleList(bundleListFile);
+            } catch (IOException e) {
+                throw new MojoExecutionException("Unable to read bundle list file", e);
+            } catch (XmlPullParserException e) {
+                throw new MojoExecutionException("Unable to read bundle list file", e);
+            }
+        } else {
+            bundleList = new BundleList();
+        }
+        
+        addDependencies(bundleList);
+        
+        BundleListXpp3Writer writer = new BundleListXpp3Writer();
+        try {
+            writer.write(new FileWriter(bundleListOutput), bundleList);
+        } catch (IOException e) {
+            throw new MojoExecutionException("Unable to write bundle list", e);
+        }
+        
+        project.getArtifact().setFile(bundleListOutput);
+
         this.getLog().info("Attaching bundle list configuration");
         try {
             this.attachConfigurations();



Mime
View raw message