From b2e057a087c08054ea301e3aee3c4c84afe85439 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 27 Jan 2009 19:00:06 +0000 Subject: 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 --- .../bundle/plugin/ModuleBundlesBuildMojo.java | 49 ++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'java/sca') 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 @@ -193,6 +193,11 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { */ private boolean generateManifestJar = true; + /** + * @parameter default-value="true" + */ + private boolean generateAntScript = true; + /** * @parameter */ @@ -467,7 +472,7 @@ public class ModuleBundlesBuildMojo extends AbstractMojo { if (generateTargetPlatform) { for (Map.Entry> e : bundleSymbolicNames.nameMap.entrySet()) { Set 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> e : bundleLocations.nameMap.entrySet()) { Set 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> e : jarNames.nameMap.entrySet()) { MavenProject pom = jarNames.getProject(e.getKey()); Set 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> e : jarNames.nameMap.entrySet()) { + Set 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(""); + ps.println(""); + ps.println(""); + ps.println(" "); + for (String jar : jars) { + ps.println(" "); + } + ps.println(" "); + ps.println(""); + ps.println(""); + } + } } 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]; -- cgit v1.2.3