Author: rfeng
Date: Tue Jan 27 19:00:06 2009
New Revision: 738187

URL: http://svn.apache.org/viewvc?rev=738187&view=rev
Log:
Add the capability to generate ant path. Rename tuscany-distribution-xyz to 
feature-xyz as the folder names.

Modified:
    
tuscany/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java

Modified: 
tuscany/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java?rev=738187&r1=738186&r2=738187&view=diff
==============================================================================
--- 
tuscany/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
 (original)
+++ 
tuscany/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
 Tue Jan 27 19:00:06 2009
@@ -194,6 +194,11 @@
     private boolean generateManifestJar = true;
 
     /**
+     * @parameter default-value="true"
+     */
+    private boolean generateAntScript = true;
+    
+    /**
      * @parameter
      */
     private ArtifactAggregation[] artifactAggregations;
@@ -467,7 +472,7 @@
             if (generateTargetPlatform) {
                 for (Map.Entry<String, Set<String>> e : 
bundleSymbolicNames.nameMap.entrySet()) {
                     Set<String> bundles = e.getValue();
-                    File feature = new File(root, "../" + (useDistributionName 
? e.getKey() : ""));
+                    File feature = new File(root, "../" + (useDistributionName 
? trim(e.getKey()) : ""));
                     feature.mkdir();
                     File target = new File(feature, "tuscany.target");
                     log.info("Generating target definition: " + target);
@@ -475,7 +480,7 @@
                     if (!bundles.contains("org.eclipse.osgi")) {
                         bundles.add("org.eclipse.osgi");
                     }
-                    writeTarget(new PrintStream(targetFile), e.getKey(), 
bundles, eclipseFeatures);
+                    writeTarget(new PrintStream(targetFile), trim(e.getKey()), 
bundles, eclipseFeatures);
                     targetFile.close();
                 }
             }
@@ -491,7 +496,7 @@
             if (generateConfig) {
                 for (Map.Entry<String, Set<String>> e : 
bundleLocations.nameMap.entrySet()) {
                     Set<String> locations = e.getValue();
-                    File feature = new File(root, "../" + (useDistributionName 
? e.getKey() : ""));
+                    File feature = new File(root, "../" + (useDistributionName 
? trim(e.getKey()) : ""));
                     File config = new File(feature, "configuration");
                     config.mkdirs();
                     File ini = new File(config, "config.ini");
@@ -513,7 +518,7 @@
                 for (Map.Entry<String, Set<String>> e : 
jarNames.nameMap.entrySet()) {
                     MavenProject pom = jarNames.getProject(e.getKey());
                     Set<String> jars = e.getValue();
-                    File feature = new File(root, "../" + (useDistributionName 
? e.getKey() : ""));
+                    File feature = new File(root, "../" + (useDistributionName 
? trim(e.getKey()) : ""));
                     feature.mkdir();
                     File mfJar = new File(feature, "manifest.jar");
                     log.info("Generating manifest jar: " + mfJar);
@@ -539,12 +544,48 @@
                     jos.close();
                 }
             }
+            
+            if (generateAntScript) {
+                for (Map.Entry<String, Set<String>> e : 
jarNames.nameMap.entrySet()) {
+                    Set<String> jars = e.getValue();
+                    File feature = new File(root, "../" + (useDistributionName 
? trim(e.getKey()) : ""));
+                    feature.mkdir();
+                    File antPath = new File(feature, "build-path.xml");
+                    log.info("Generating ANT build path: " + antPath);
+                    FileOutputStream fos = new FileOutputStream(antPath);
+                    PrintStream ps = new PrintStream(fos);
+                    ps.println("<property name=\"tuscany.distro\" value=\"" + 
trim(e.getKey()) + "\"/>");
+                    ps.println("<property name=\"tuscany.manifest\" value=\"" 
+ new File(feature, "manifest.mf")
+                        + "\"/>");
+                    ps.println("<path id=\"" + "tuscany.path" + "\">");
+                    ps.println("  <fileset dir=\"" + root + "\">");
+                    for (String jar : jars) {
+                        ps.println("    <include name=\"" + jar + "\"/>");
+                    }
+                    ps.println("  </fileset>");
+                    ps.println("</path>");
+                    ps.println("<classpath id=\"tuscany.classpath\" 
refid=\"tuscany.path\"/>");
+                }
+            }
 
         } catch (Exception e) {
             throw new MojoExecutionException(e.getMessage(), e);
         }
 
     }
+    
+    /**
+     * Convert tuscany-distribution-xyz to feature-xyz
+     * @param artifactId
+     * @return
+     */
+    private String trim(String artifactId) {
+        if (artifactId.startsWith("tuscany-distribution-")) {
+            return "feature-" + 
artifactId.substring("tuscany-distribution-".length());
+        } else {
+            return artifactId;
+        }
+    }
 
     private static void copyFile(File jar, File dir) throws 
FileNotFoundException, IOException {
         byte[] buf = new byte[4096];


Reply via email to