You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by pi...@apache.org on 2011/02/07 13:00:46 UTC
svn commit: r1067927 -
/karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/MojoSupport.java
Author: pieber
Date: Mon Feb 7 12:00:45 2011
New Revision: 1067927
URL: http://svn.apache.org/viewvc?rev=1067927&view=rev
Log:
[KARAF-422] features-maven-plugin supports automatic version of plugins now; thanks to Stephane Chomat
Signed-off-by: Andreas Pieber <an...@gmail.com>
Modified:
karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/MojoSupport.java
Modified: karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/MojoSupport.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/MojoSupport.java?rev=1067927&r1=1067926&r2=1067927&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/MojoSupport.java (original)
+++ karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/MojoSupport.java Mon Feb 7 12:00:45 2011
@@ -110,6 +110,13 @@ public abstract class MojoSupport extend
* @component
*/
protected ArtifactFactory factory;
+
+ /**
+ * The artifact type of a feature
+ *
+ * @parameter default-value="xml"
+ */
+ private String featureArtifactType = "xml";
protected MavenProject getProject() {
return project;
@@ -352,6 +359,17 @@ public abstract class MojoSupport extend
throw new RuntimeException("Repository URL is not valid", e);
}
}
+
+ private Dependency findDependency(List<Dependency> dependencies, String artifactId, String groupId) {
+ for(Dependency dep : dependencies) {
+ if (artifactId.equals(dep.getArtifactId()) && groupId.equals(dep.getGroupId()) &&
+ featureArtifactType.equals(dep.getType())) {
+ if (dep.getVersion() != null)
+ return dep;
+ }
+ }
+ return null;
+ }
protected Artifact bundleToArtifact(String bundle, boolean skipNonMavenProtocols) throws MojoExecutionException {
bundle = bundle.replace("\r\n", "").replace("\n", "").replace(" ", "");
@@ -412,6 +430,19 @@ public abstract class MojoSupport extend
classifier = parts[4];
}
}
+ } else {
+ Dependency dep = findDependency(project.getDependencies(), artifactId, groupId);
+ if (dep == null && project.getDependencyManagement() != null) {
+ dep = findDependency(project.getDependencyManagement().getDependencies(), artifactId, groupId);
+ }
+ if (dep != null) {
+ version = dep.getVersion();
+ classifier = dep.getClassifier();
+ type = dep.getType();
+ }
+ }
+ if (version == null || version.length() == 0) {
+ throw new MojoExecutionException("Cannot find version for: " + bundle);
}
Artifact artifact = factory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
artifact.setRepository(repo);