incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1197759 - in /sling/trunk/maven/maven-launchpad-plugin: ./ src/main/java/org/apache/sling/maven/projectsupport/
Date Fri, 04 Nov 2011 20:46:12 GMT
Author: justin
Date: Fri Nov  4 20:46:12 2011
New Revision: 1197759

URL: http://svn.apache.org/viewvc?rev=1197759&view=rev
Log:
SLING-2265 - adding maven-dependency-plugin style option includeDepenencies

Added:
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
Modified:
    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/AttachBundleListMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java

Modified: sling/trunk/maven/maven-launchpad-plugin/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/pom.xml?rev=1197759&r1=1197758&r2=1197759&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/pom.xml (original)
+++ sling/trunk/maven/maven-launchpad-plugin/pom.xml Fri Nov  4 20:46:12 2011
@@ -108,7 +108,6 @@
             <artifactId>maven-archiver</artifactId>
             <version>2.0</version>
         </dependency>
-
         <dependency>
             <groupId>org.codehaus.plexus</groupId>
             <artifactId>plexus-archiver</artifactId>
@@ -124,6 +123,12 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <!-- using utility classes from this plugin -->
+        <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <version>2.3</version>
+        </dependency>
         <dependency>
             <groupId>org.codehaus.plexus</groupId>
             <artifactId>plexus-utils</artifactId>

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=1197759&r1=1197758&r2=1197759&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
Fri Nov  4 20:46:12 2011
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -41,6 +42,7 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
 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;
@@ -66,8 +68,13 @@ public abstract class AbstractBundleList
     protected File bundleListFile;
 
     /**
+     * @parameter
+     */
+    private ConfigurationStartLevel[] includeDependencies;
+
+    /**
      * The Maven project.
-     *
+     * 
      * @parameter expression="${project}"
      * @required
      * @readonly
@@ -195,7 +202,16 @@ public abstract class AbstractBundleList
     }
 
     @SuppressWarnings("unchecked")
-    protected void addDependencies(final BundleList bundleList) {
+    protected void addDependencies(final BundleList bundleList) throws MojoExecutionException
{
+        if (includeDependencies != null) {
+            for (ConfigurationStartLevel startLevel : includeDependencies) {
+                Set<Artifact> artifacts = getArtifacts(startLevel);
+                for (Artifact artifact : artifacts) {
+                    bundleList.add(ArtifactDefinition.toBundle(artifact, startLevel.getLevel()));
+                }
+            }
+        }
+
         if (dependencyStartLevel >= 0) {
             final List<Dependency> dependencies = project.getDependencies();
             for (Dependency dependency : dependencies) {
@@ -206,6 +222,21 @@ public abstract class AbstractBundleList
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private Set<Artifact> getArtifacts(ConfigurationStartLevel startLevel) throws MojoExecutionException
{
+        // start with all artifacts.
+        Set<Artifact> artifacts = project.getArtifacts();
+
+        // perform filtering
+        try {
+            artifacts = startLevel.buildFilter(project).filter(artifacts);
+        } catch (ArtifactFilterException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+        
+        return artifacts;
+    }
+
     protected void interpolateProperties(BundleList bundleList) throws MojoExecutionException
{
         Interpolator interpolator = createInterpolator();
         for (final StartLevel sl : bundleList.getStartLevels()) {

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java?rev=1197759&r1=1197758&r2=1197759&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
Fri Nov  4 20:46:12 2011
@@ -29,6 +29,7 @@ import org.apache.sling.maven.projectsup
  *
  * @goal attach-bundle-list
  * @phase package
+ * @requiresDependencyResolution test
  * @description attach the bundle list as a project artifact
  */
 public class AttachBundleListMojo extends AbstractUsingBundleListMojo {

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=1197759&r1=1197758&r2=1197759&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
Fri Nov  4 20:46:12 2011
@@ -34,6 +34,7 @@ import org.codehaus.plexus.util.xml.pull
  *
  * @goal attach-partial-bundle-list
  * @phase package
+ * @requiresDependencyResolution test
  * @description attach the partial bundle list as a project artifact
  */
 public class AttachPartialBundleListMojo extends AbstractBundleListMojo {

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java?rev=1197759&r1=1197758&r2=1197759&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java
Fri Nov  4 20:46:12 2011
@@ -30,6 +30,7 @@ import org.apache.sling.maven.projectsup
  * to SNAPSHOT versions.
  *
  * @goal check-bundle-list-for-snapshots
+ * @requiresDependencyResolution test
  *
  */
 public class CheckBundleListForSnapshotsMojo extends AbstractUsingBundleListMojo {

Added: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java?rev=1197759&view=auto
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
(added)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
Fri Nov  4 20:46:12 2011
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * 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
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.maven.projectsupport;
+
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter;
+import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
+import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
+
+public class ConfigurationStartLevel {
+    
+    private int level;
+
+    private String includeTypes;
+
+    private String excludeTypes;
+
+    private String includeScope;
+
+    private String excludeScope;
+
+    private String includeClassifiers;
+
+    private String excludeClassifiers;
+
+    private String excludeArtifactIds;
+
+    private String includeArtifactIds;
+
+    private String excludeGroupIds;
+
+    private String includeGroupIds;
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public String getIncludeTypes() {
+        return includeTypes;
+    }
+
+    public void setIncludeTypes(String includeTypes) {
+        this.includeTypes = includeTypes;
+    }
+
+    public String getExcludeTypes() {
+        return excludeTypes;
+    }
+
+    public void setExcludeTypes(String excludeTypes) {
+        this.excludeTypes = excludeTypes;
+    }
+
+    public String getIncludeScope() {
+        return includeScope;
+    }
+
+    public void setIncludeScope(String includeScope) {
+        this.includeScope = includeScope;
+    }
+
+    public String getExcludeScope() {
+        return excludeScope;
+    }
+
+    public void setExcludeScope(String excludeScope) {
+        this.excludeScope = excludeScope;
+    }
+
+    public String getIncludeClassifiers() {
+        return includeClassifiers;
+    }
+
+    public void setIncludeClassifiers(String includeClassifiers) {
+        this.includeClassifiers = includeClassifiers;
+    }
+
+    public String getExcludeClassifiers() {
+        return excludeClassifiers;
+    }
+
+    public void setExcludeClassifiers(String excludeClassifiers) {
+        this.excludeClassifiers = excludeClassifiers;
+    }
+
+    public String getExcludeArtifactIds() {
+        return excludeArtifactIds;
+    }
+
+    public void setExcludeArtifactIds(String excludeArtifactIds) {
+        this.excludeArtifactIds = excludeArtifactIds;
+    }
+
+    public String getIncludeArtifactIds() {
+        return includeArtifactIds;
+    }
+
+    public void setIncludeArtifactIds(String includeArtifactIds) {
+        this.includeArtifactIds = includeArtifactIds;
+    }
+
+    public String getExcludeGroupIds() {
+        return excludeGroupIds;
+    }
+
+    public void setExcludeGroupIds(String excludeGroupIds) {
+        this.excludeGroupIds = excludeGroupIds;
+    }
+
+    public String getIncludeGroupIds() {
+        return includeGroupIds;
+    }
+
+    public void setIncludeGroupIds(String includeGroupIds) {
+        this.includeGroupIds = includeGroupIds;
+    }
+
+    public FilterArtifacts buildFilter(MavenProject project) {
+        // add filters in well known order, least specific to most specific
+        FilterArtifacts filter = new FilterArtifacts();
+
+        filter.addFilter(new ProjectTransitivityFilter(project.getDependencyArtifacts(),
true));
+
+        filter.addFilter(new ScopeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeScope),
DependencyUtil
+                .cleanToBeTokenizedString(this.excludeScope)));
+
+        filter.addFilter(new TypeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeTypes),
DependencyUtil
+                .cleanToBeTokenizedString(this.excludeTypes)));
+
+        filter.addFilter(new ClassifierFilter(DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers),
+                DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
+
+        filter.addFilter(new GroupIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds),
+                DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
+
+        filter.addFilter(new ArtifactIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds),
+                DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
+        return filter;
+    }
+    
+    
+
+}

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java?rev=1197759&r1=1197758&r2=1197759&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java
Fri Nov  4 20:46:12 2011
@@ -36,6 +36,7 @@ import org.jdom.output.XMLOutputter;
  * @goal create-karaf-descriptor
  * @phase package
  * @description create a karaf feature descriptor
+ * @requiresDependencyResolution test
  */
 public class CreateKarafFeatureDescriptorMojo extends AbstractUsingBundleListMojo {
 

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java?rev=1197759&r1=1197758&r2=1197759&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java
Fri Nov  4 20:46:12 2011
@@ -27,6 +27,7 @@ import org.apache.sling.maven.projectsup
  * Output the bundle list back to the console.
  * 
  * @goal output-bundle-list
+ * @requiresDependencyResolution test
  * 
  */
 public class OutputBundleListMojo extends AbstractUsingBundleListMojo {



Mime
View raw message