Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A11F200D35 for ; Tue, 7 Nov 2017 10:14:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 788F5160C0F; Tue, 7 Nov 2017 09:14:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6D703160C00 for ; Tue, 7 Nov 2017 10:14:52 +0100 (CET) Received: (qmail 20406 invoked by uid 500); 7 Nov 2017 09:14:49 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 19868 invoked by uid 99); 7 Nov 2017 09:14:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Nov 2017 09:14:49 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id C916584C80; Tue, 7 Nov 2017 09:14:48 +0000 (UTC) Date: Tue, 07 Nov 2017 09:16:23 +0000 To: "commits@sling.apache.org" Subject: [sling-maven-launchpad-plugin] 11/29: SLING-2265 - adding maven-dependency-plugin style option includeDepenencies MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: rombert@apache.org In-Reply-To: <151004608308.28929.15610345946728794915@gitbox.apache.org> References: <151004608308.28929.15610345946728794915@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: sling-maven-launchpad-plugin X-Git-Refname: refs/tags/maven-launchpad-plugin-2.1.2 X-Git-Reftype: annotated tag X-Git-Rev: 69e876402c0f7929637b74721e4db531330eb449 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20171107091448.C916584C80@gitbox.apache.org> archived-at: Tue, 07 Nov 2017 09:14:57 -0000 This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag maven-launchpad-plugin-2.1.2 in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git commit 69e876402c0f7929637b74721e4db531330eb449 Author: Justin Edelson AuthorDate: Fri Nov 4 20:46:12 2011 +0000 SLING-2265 - adding maven-dependency-plugin style option includeDepenencies git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@1197759 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 7 +- .../projectsupport/AbstractBundleListMojo.java | 35 ++++- .../maven/projectsupport/AttachBundleListMojo.java | 1 + .../AttachPartialBundleListMojo.java | 1 + .../CheckBundleListForSnapshotsMojo.java | 1 + .../projectsupport/ConfigurationStartLevel.java | 166 +++++++++++++++++++++ .../CreateKarafFeatureDescriptorMojo.java | 1 + .../maven/projectsupport/OutputBundleListMojo.java | 1 + 8 files changed, 210 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3265d3d..d61c403 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,6 @@ maven-archiver 2.0 - org.codehaus.plexus plexus-archiver @@ -124,6 +123,12 @@ + + + org.apache.maven.plugins + maven-dependency-plugin + 2.3 + org.codehaus.plexus plexus-utils diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java index bd5e788..54d402a 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java @@ -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.MojoExecutionException; 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 AbstractBundleListMojo extends AbstractMojo { protected File bundleListFile; /** + * @parameter + */ + private ConfigurationStartLevel[] includeDependencies; + + /** * The Maven project. - * + * * @parameter expression="${project}" * @required * @readonly @@ -195,7 +202,16 @@ public abstract class AbstractBundleListMojo extends AbstractMojo { } @SuppressWarnings("unchecked") - protected void addDependencies(final BundleList bundleList) { + protected void addDependencies(final BundleList bundleList) throws MojoExecutionException { + if (includeDependencies != null) { + for (ConfigurationStartLevel startLevel : includeDependencies) { + Set artifacts = getArtifacts(startLevel); + for (Artifact artifact : artifacts) { + bundleList.add(ArtifactDefinition.toBundle(artifact, startLevel.getLevel())); + } + } + } + if (dependencyStartLevel >= 0) { final List dependencies = project.getDependencies(); for (Dependency dependency : dependencies) { @@ -206,6 +222,21 @@ public abstract class AbstractBundleListMojo extends AbstractMojo { } } + @SuppressWarnings("unchecked") + private Set getArtifacts(ConfigurationStartLevel startLevel) throws MojoExecutionException { + // start with all artifacts. + Set 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()) { diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java index 9cebe53..e7d9977 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java @@ -29,6 +29,7 @@ import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleLis * * @goal attach-bundle-list * @phase package + * @requiresDependencyResolution test * @description attach the bundle list as a project artifact */ public class AttachBundleListMojo extends AbstractUsingBundleListMojo { diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java index 3c34afa..470aef0 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java @@ -34,6 +34,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; * * @goal attach-partial-bundle-list * @phase package + * @requiresDependencyResolution test * @description attach the partial bundle list as a project artifact */ public class AttachPartialBundleListMojo extends AbstractBundleListMojo { diff --git a/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java index aeebc61..59e92cf 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/CheckBundleListForSnapshotsMojo.java @@ -30,6 +30,7 @@ import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel; * to SNAPSHOT versions. * * @goal check-bundle-list-for-snapshots + * @requiresDependencyResolution test * */ public class CheckBundleListForSnapshotsMojo extends AbstractUsingBundleListMojo { diff --git a/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java b/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java new file mode 100644 index 0000000..dd41fcd --- /dev/null +++ b/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java @@ -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; + } + + + +} diff --git a/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java index f66b60b..504d9cd 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/CreateKarafFeatureDescriptorMojo.java @@ -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 { diff --git a/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java index a1e5b67..31d0523 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/OutputBundleListMojo.java @@ -27,6 +27,7 @@ import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleLis * Output the bundle list back to the console. * * @goal output-bundle-list + * @requiresDependencyResolution test * */ public class OutputBundleListMojo extends AbstractUsingBundleListMojo { -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" .