karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1129865 - in /karaf/branches/karaf-2.2.x: manual/src/main/webapp/developers-guide/ tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/
Date Tue, 31 May 2011 19:24:32 GMT
Author: jbonofre
Date: Tue May 31 19:24:31 2011
New Revision: 1129865

URL: http://svn.apache.org/viewvc?rev=1129865&view=rev
Log:
[KARAF-663] Automatically add Karaf core features descriptors (standard and enterprise) in
the add-features-to-repo goal.

Modified:
    karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
    karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
    karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java

Modified: karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf?rev=1129865&r1=1129864&r2=1129865&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
(original)
+++ karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
Tue May 31 19:24:31 2011
@@ -2,6 +2,8 @@ h2. Goal {{features:add-features-to-repo
 
 The {{features:add-features-to-repo}} goal adds all the required bundles for a given set
of features into directory.  You can use this goal to create a {{/system}} directory for building
your own Karaf-based distribution.
 
+By default, the Karaf core features descriptors (standard and enterprise) are automatically
included in the descriptors set.
+
 h3. Example
 The example below copies the bundles for the {{spring}} and {{war}} features defined in the
Karaf features XML descriptor into the {{target/features-repo}} directory.
 {pygmentize:xml}
@@ -22,11 +24,12 @@ The example below copies the bundles for
             </goals>
             <configuration>
               <descriptors>
-                <descriptor>mvn:org.apache.karaf/apache-karaf/${karaf.version}/xml/features</descriptor>
+                <descriptor>mvn:my.groupid/my.artifactid/1.0.0/xml/features</descriptor>
               </descriptors>
               <features>
                 <feature>spring</feature>
                 <feature>war</feature>
+                <feature>my</feature>
               </features>
               <repository>target/features-repo</repository>
             </configuration>
@@ -40,6 +43,7 @@ The example below copies the bundles for
 
 h3. Parameters
 || Name || Type || Description ||
-| {{descriptors}} | {{String[]}} | List of features XML descriptors where the features are
defined |
+| {{descriptors}} | {{String[]}} | List of features XML descriptors where the features are
defined \\ NB: Karaf core features descriptors (standard and enterprise) are automatically
added in this list |
 | {{features}} | {{String[]}} | List of features that bundles should be copied to the repository
directory |
-| {{repository}} | {{File}} | The directory where the bundles will be copied by the plugin
goal |
\ No newline at end of file
+| {{repository}} | {{File}} | The directory where the bundles will be copied by the plugin
goal |
+| {{karafVersion}} | {{String}} | Target Karaf version to use to resolve the Karaf core features
descriptors (standard and enterprise) |
\ No newline at end of file

Modified: karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.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/AddFeaturesToRepoMojo.java?rev=1129865&r1=1129864&r2=1129865&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
(original)
+++ karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
Tue May 31 19:24:31 2011
@@ -64,6 +64,9 @@ import org.xml.sax.SAXException;
  */
 public class AddFeaturesToRepoMojo extends MojoSupport {
 
+    private final static String KARAF_CORE_STANDARD_FEATURE_URL = "mvn:org.apache.karaf.assemblies.features/standard/%s/xml/features";
+    private final static String KARAF_CORE_ENTERPRISE_FEATURE_URL = "mvn:org.apache.karaf.assemblies.features/enterprise/%s/xml/features";
+
     /**
      * @parameter
      */
@@ -80,6 +83,13 @@ public class AddFeaturesToRepoMojo exten
     private File repository;
 
     /**
+     * which is the target karaf version used to resolve karaf core features descriptors
+     *
+     * @parameter
+     */
+    private String karafVersion;
+
+    /**
      * @parameter
      */
     private boolean includeMvnBasedDescriptors = false;
@@ -105,21 +115,49 @@ public class AddFeaturesToRepoMojo exten
     private boolean addTransitiveFeatures = true;
 
     public void execute() throws MojoExecutionException, MojoFailureException {
+        if (karafVersion == null) {
+            Package p = Package.getPackage("org.apache.karaf.tooling.features");
+            karafVersion = p.getImplementationVersion();
+        }
+        String karafCoreEnterpriseFeatureUrl = String.format(KARAF_CORE_ENTERPRISE_FEATURE_URL,
karafVersion);
+        Artifact enterpriseFeatureDescriptor = bundleToArtifact(karafCoreEnterpriseFeatureUrl,
true);
+        if (enterpriseFeatureDescriptor != null) {
+            try {
+                resolveBundle(enterpriseFeatureDescriptor, remoteRepos);
+                descriptors.add(0, karafCoreEnterpriseFeatureUrl);
+            } catch (Exception e) {
+                getLog().warn("Can't add " + enterpriseFeatureDescriptor + " in the descriptors
set");
+                getLog().debug(e);
+            }
+        }
+        String karafCoreStandardFeatureUrl = String.format(KARAF_CORE_STANDARD_FEATURE_URL,
karafVersion);
+        Artifact standardFeatureDescriptor = bundleToArtifact(karafCoreStandardFeatureUrl,
true);
+        if (standardFeatureDescriptor != null) {
+            try {
+                resolveBundle(standardFeatureDescriptor, remoteRepos);
+                descriptors.add(0, karafCoreStandardFeatureUrl);
+            } catch (Exception e) {
+                getLog().warn("Can't add " + standardFeatureDescriptor + " in the descriptors
set");
+                getLog().debug(e);
+            }
+        }
         try {
             Set<String> bundles = new HashSet<String>();
             Map<String, Feature> featuresMap = new HashMap<String, Feature>();
             for (String uri : descriptors) {
-                // let's ensure a mvn: based url is sitting in the local repo before we try
reading it
-                Artifact descriptor = bundleToArtifact(uri, true);
-                if (descriptor != null) {
-                    resolveBundle(descriptor, remoteRepos);
-                }
-                if (includeMvnBasedDescriptors) {
-                    bundles.add(uri);
-                }
-                Repository repo = new Repository(URI.create(translateFromMaven(uri)));
-                for (Feature f : repo.getFeatures()) {
-                    featuresMap.put(f.getName(), f);
+                if (!uri.equals(karafCoreStandardFeatureUrl) && !uri.equals(karafCoreEnterpriseFeatureUrl))
{
+                    // let's ensure a mvn: based url is sitting in the local repo before
we try reading it
+                    Artifact descriptor = bundleToArtifact(uri, true);
+                    if (descriptor != null) {
+                        resolveBundle(descriptor, remoteRepos);
+                    }
+                    if (includeMvnBasedDescriptors) {
+                        bundles.add(uri);
+                    }
+                    Repository repo = new Repository(URI.create(translateFromMaven(uri)));
+                    for (Feature f : repo.getFeatures()) {
+                        featuresMap.put(f.getName(), f);
+                    }
                 }
             }
             

Modified: karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.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/ValidateFeaturesMojo.java?rev=1129865&r1=1129864&r2=1129865&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java
(original)
+++ karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/ValidateFeaturesMojo.java
Tue May 31 19:24:31 2011
@@ -199,6 +199,9 @@ public class ValidateFeaturesMojo extend
         appendKarafCoreFeaturesDescriptors();
     }
 
+    /**
+     * Add Karaf core features descriptors in the default repositories set.
+     */
     private void appendKarafCoreFeaturesDescriptors() {
         if (repositories == null) {
             repositories = new ArrayList<String>();



Mime
View raw message