diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-27 19:00:06 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-27 19:00:06 +0000 |
commit | b2e057a087c08054ea301e3aee3c4c84afe85439 (patch) | |
tree | a1c9c1e4f2f64d827216cc10747a999f04876bdf /java/sca/tools/maven | |
parent | 1206dc69a267f18b68cb086e06dcc5f3f8ce9987 (diff) |
Add the capability to generate ant path. Rename tuscany-distribution-xyz to feature-xyz as the folder names.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@738187 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/tools/maven')
-rw-r--r-- | java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java b/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java index 176078ce7a..a54fd25736 100644 --- a/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java +++ b/java/sca/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java @@ -194,6 +194,11 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { private boolean generateManifestJar = true; /** + * @parameter default-value="true" + */ + private boolean generateAntScript = true; + + /** * @parameter */ private ArtifactAggregation[] artifactAggregations; @@ -467,7 +472,7 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { 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 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { 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 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { 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 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { 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 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { 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]; |