Author: cziegeler
Date: Fri Dec 23 09:51:55 2011
New Revision: 1222624
URL: http://svn.apache.org/viewvc?rev=1222624&view=rev
Log:
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
Removed:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ConfigurationStartLevel.java
Modified:
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/AttachPartialBundleListMojo.java
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
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=1222624&r1=1222623&r2=1222624&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 Dec 23 09:51:55 2011
@@ -18,7 +18,6 @@ package org.apache.sling.maven.projectsu
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.version
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 AbstractBundleList
protected File bundleListFile;
/**
- * @parameter
- */
- private ConfigurationStartLevel[] includeDependencies;
-
- /**
* The Maven project.
- *
+ *
* @parameter expression="${project}"
* @required
* @readonly
@@ -128,13 +119,6 @@ public abstract class AbstractBundleList
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 AbstractBundleList
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 AbstractBundleList
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 AbstractBundleList
} catch (ArtifactMetadataRetrievalException e) {
throw new MojoExecutionException("Unable to find
version for artifact", e);
}
-
+
}
-
+
try {
resolver.resolve(artifact, remoteRepos, local);
} catch (ArtifactResolutionException e) {
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=1222624&r1=1222623&r2=1222624&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
Fri Dec 23 09:51:55 2011
@@ -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.MojoFailu
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.KnowledgeBuild
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 AbstractUsingBundl
*/
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 AbstractUsingBundl
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 AbstractUsingBundl
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 AbstractUsingBundl
}
}
}
-
+
private void rewriteBundleList(BundleList bundleList) throws
MojoExecutionException {
if (rewriteRuleFiles != null) {
KnowledgeBase knowledgeBase =
createKnowledgeBase(rewriteRuleFiles);
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=1222624&r1=1222623&r2=1222624&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 Dec 23 09:51:55 2011
@@ -93,8 +93,6 @@ public class AttachPartialBundleListMojo
initializedBundleList = new BundleList();
}
- addDependencies(initializedBundleList);
-
interpolateProperties(initializedBundleList, this.project,
this.mavenSession);
final BundleListXpp3Writer writer = new BundleListXpp3Writer();
Modified:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java?rev=1222624&r1=1222623&r2=1222624&view=diff
==============================================================================
---
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
(original)
+++
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/ValidateBundleListMojo.java
Fri Dec 23 09:51:55 2011
@@ -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.projectsup
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.pro
* @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 exte
} 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));