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:30 UTC
[sling-maven-launchpad-plugin] 18/29: SLING-2194 : generate a
partial bundle list from a project's dependencies SLING-2265 :
maven-launchpad-plugin should support a syntax similar to the
maven-dependency-plugin
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 210d0d40ccfa1aa08349af59f13e7ed1a5f50fa4
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Dec 23 09:51:55 2011 +0000
SLING-2194 : generate a partial bundle list from a project's dependencies
SLING-2265 : maven-launchpad-plugin should support a syntax similar to the maven-dependency-plugin
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@1222624 13f79535-47bb-0310-9956-ffa450edef68
---
.../projectsupport/AbstractBundleListMojo.java | 63 +-------
.../AbstractUsingBundleListMojo.java | 15 +-
.../AttachPartialBundleListMojo.java | 2 -
.../projectsupport/ConfigurationStartLevel.java | 166 ---------------------
.../projectsupport/ValidateBundleListMojo.java | 15 +-
5 files changed, 21 insertions(+), 240 deletions(-)
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 7119c21..eca43fe 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
@@ -18,7 +18,6 @@ package org.apache.sling.maven.projectsupport;
import java.io.File;
import java.util.List;
-import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -32,13 +31,10 @@ import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
-import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
-import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
import org.codehaus.plexus.util.StringUtils;
public abstract class AbstractBundleListMojo extends AbstractMojo {
@@ -54,13 +50,8 @@ public abstract class AbstractBundleListMojo extends AbstractMojo {
protected File bundleListFile;
/**
- * @parameter
- */
- private ConfigurationStartLevel[] includeDependencies;
-
- /**
* The Maven project.
- *
+ *
* @parameter expression="${project}"
* @required
* @readonly
@@ -128,13 +119,6 @@ public abstract class AbstractBundleListMojo extends AbstractMojo {
protected MavenSession mavenSession;
/**
- * The start level to be used when generating the bundle list.
- *
- * @parameter default-value="-1"
- */
- private int dependencyStartLevel;
-
- /**
* Used to look up Artifacts in the remote repository.
*
* @component
@@ -177,41 +161,6 @@ public abstract class AbstractBundleListMojo extends AbstractMojo {
return this.configDirectory;
}
- 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) {
- if (!PARTIAL.equals(dependency.getType())) {
- bundleList.add(ArtifactDefinition.toBundle(dependency, dependencyStartLevel));
- }
- }
- }
- }
-
- @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;
- }
-
/**
* Get a resolved Artifact from the coordinates found in the artifact
* definition.
@@ -234,20 +183,20 @@ public abstract class AbstractBundleListMojo extends AbstractMojo {
throws MojoExecutionException {
Artifact artifact;
VersionRange vr;
-
+
try {
vr = VersionRange.createFromVersionSpec(version);
} catch (InvalidVersionSpecificationException e) {
vr = VersionRange.createFromVersion(version);
}
-
+
if (StringUtils.isEmpty(classifier)) {
artifact = factory.createDependencyArtifact(groupId, artifactId, vr, type, null, Artifact.SCOPE_COMPILE);
} else {
artifact = factory.createDependencyArtifact(groupId, artifactId, vr, type, classifier,
Artifact.SCOPE_COMPILE);
}
-
+
// This code kicks in when the version specifier is a range.
if (vr.getRecommendedVersion() == null) {
try {
@@ -257,9 +206,9 @@ public abstract class AbstractBundleListMojo extends AbstractMojo {
} catch (ArtifactMetadataRetrievalException e) {
throw new MojoExecutionException("Unable to find version for artifact", e);
}
-
+
}
-
+
try {
resolver.resolve(artifact, remoteRepos, local);
} catch (ArtifactResolutionException e) {
diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
index 3f242a4..90dd76f 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
@@ -16,6 +16,9 @@
*/
package org.apache.sling.maven.projectsupport;
+import static org.apache.sling.maven.projectsupport.BundleListUtils.interpolateProperties;
+import static org.apache.sling.maven.projectsupport.BundleListUtils.readBundleList;
+
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@@ -30,6 +33,7 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.shared.filtering.MavenFileFilter;
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.maven.shared.filtering.PropertyUtils;
+import org.apache.sling.maven.projectsupport.BundleListUtils.ArtifactDefinitionsCallback;
import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
@@ -43,9 +47,6 @@ import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
-import org.apache.sling.maven.projectsupport.BundleListUtils.ArtifactDefinitionsCallback;
-import static org.apache.sling.maven.projectsupport.BundleListUtils.readBundleList;
-import static org.apache.sling.maven.projectsupport.BundleListUtils.interpolateProperties;
public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo {
@@ -196,7 +197,7 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo
*/
private final void initArtifactDefinitions() throws IOException {
BundleListUtils.initArtifactDefinitions(getClass().getClassLoader(), new ArtifactDefinitionsCallback() {
-
+
public void initArtifactDefinitions(Properties dependencies) {
if (defaultBundleList == null) {
defaultBundleList = new ArtifactDefinition();
@@ -231,7 +232,7 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo
initializedBundleList.add(def.toBundle());
}
}
- addDependencies(initializedBundleList);
+
if (bundleExclusions != null) {
for (ArtifactDefinition def : bundleExclusions) {
initializedBundleList.remove(def.toBundle(), false);
@@ -255,7 +256,7 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo
rewriteBundleList(initializedBundleList);
}
-
+
private final void extractConfigurations() throws MojoExecutionException, IOException {
final Set<Artifact> dependencies = project.getDependencyArtifacts();
for (Artifact artifact : dependencies) {
@@ -322,7 +323,7 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo
}
}
}
-
+
private void rewriteBundleList(BundleList bundleList) throws MojoExecutionException {
if (rewriteRuleFiles != null) {
KnowledgeBase knowledgeBase = createKnowledgeBase(rewriteRuleFiles);
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 aa2dcd3..c4e264c 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
@@ -93,8 +93,6 @@ public class AttachPartialBundleListMojo extends AbstractBundleListMojo {
initializedBundleList = new BundleList();
}
- addDependencies(initializedBundleList);
-
interpolateProperties(initializedBundleList, this.project, this.mavenSession);
final BundleListXpp3Writer writer = new BundleListXpp3Writer();
diff --git a/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java b/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
deleted file mode 100644
index dd41fcd..0000000
--- a/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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/ValidateBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
index d57d2f7..df890cf 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
@@ -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
@@ -16,6 +16,9 @@
*/
package org.apache.sling.maven.projectsupport;
+import static org.apache.sling.maven.projectsupport.BundleListUtils.interpolateProperties;
+import static org.apache.sling.maven.projectsupport.BundleListUtils.readBundleList;
+
import java.io.IOException;
import org.apache.maven.plugin.MojoExecutionException;
@@ -24,8 +27,6 @@ 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.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import static org.apache.sling.maven.projectsupport.BundleListUtils.readBundleList;
-import static org.apache.sling.maven.projectsupport.BundleListUtils.interpolateProperties;
/**
* Validate that the artifacts listed in a bundle list are valid
@@ -36,7 +37,7 @@ import static org.apache.sling.maven.projectsupport.BundleListUtils.interpolateP
* @description validate that the artifacts listed in a bundle list are valid
*/
public class ValidateBundleListMojo extends AbstractBundleListMojo {
-
+
public void execute() throws MojoExecutionException, MojoFailureException {
final BundleList initializedBundleList;
if (bundleListFile.exists()) {
@@ -50,11 +51,9 @@ public class ValidateBundleListMojo extends AbstractBundleListMojo {
} else {
initializedBundleList = new BundleList();
}
-
- addDependencies(initializedBundleList);
interpolateProperties(initializedBundleList, project, mavenSession);
-
+
for (StartLevel sl : initializedBundleList.getStartLevels()) {
for (Bundle bundle : sl.getBundles()) {
getArtifact(new ArtifactDefinition(bundle, -1));
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.