You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:16:23 UTC
[sling-maven-launchpad-plugin] 11/29: SLING-2265 - adding
maven-dependency-plugin style option includeDepenencies
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 <ju...@apache.org>
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 @@
<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>
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<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 AbstractBundleListMojo extends AbstractMojo {
}
}
+ @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()) {
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" <co...@sling.apache.org>.