diff --git a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/MapFileGenerator.java b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/MapFileGenerator.java index 527eeb455b096e3a37f33133deb5f5f8febc1f8c..cf22314dc145ec755fcf6fb8579229bf2d4160b3 100644 --- a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/MapFileGenerator.java +++ b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/MapFileGenerator.java @@ -6,14 +6,13 @@ * * Contributors: IBM Corporation - initial API and implementation * - * This Class was copied from similar package in Orbit, org.eclipse.orbit.releng.tools + * This Class was originally copied and modified from similar package in Orbit, org.eclipse.orbit.releng.tools * Thanks to DJ and others. *******************************************************************************/ package org.eclipse.wtp.releng.tools; import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; @@ -32,7 +31,7 @@ import org.apache.tools.ant.Task; /** * <pre> - * <code> + * <code> * * <!-- This declares the task to ant. It needs to be tweaked to point to the jar containing the task --> * <taskdef @@ -52,30 +51,27 @@ import org.apache.tools.ant.Task; * <eclipse.mapGenerator * root="${topBuildDirectory}/${buildLabel}/bundles" * addressPrefix="http://download.eclipse.org/tools/orbit/committers/drops/${buildLabel}/bundles/" - * inputFile="${topBuildDirectory}/finalPluginsVersions.properties" + * inputFilePluginVersions="${topBuildDirectory}/finalPluginsVersions.properties" * outputFile="${topBuildDirectory}/${buildLabel}/orbitBundles.map" /> * </target> - * </code> - </pre> + * </code> + * </pre> */ public class MapFileGenerator extends Task { private static final String EOL = System.getProperty("line.separator"); - // Longterm we'll want to use 'bundle', but due to + // Longterm we'll want to use 'bundle', but due to // https://bugs.eclipse.org/bugs/show_bug.cgi?id=174331 // we'll use 'plugin' for now. private static final String BUNDLE = "bundle"; private static final String PLUGIN = "plugin"; private String BUNDLE_LINE_PREFIX = BUNDLE; + private String FEATURE_LINE_PREFIX = "feature"; private boolean usePlugin = true; private DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); - private File root; - private String username; - private String pwd; - private String addressPrefix; - private String inputFile; - private String outputFile; + private String inputFilePluginVersions; + private String inputFileFeatureVersions; private String p2MapFile; private String p2Repository; @@ -95,30 +91,25 @@ public class MapFileGenerator extends Task { BUNDLE_LINE_PREFIX = PLUGIN; } try { - List list = getBundleDetails(); - writeList(list, outputFile, false); - // only write out a p2 map file if the required attributes are present + List listbundleinfo = getVersionDetails(inputFilePluginVersions); + List listfeatureinfo = getVersionDetails(inputFileFeatureVersions); + // only write out a p2 map file if the required attributes are + // present if (p2MapFile != null && p2Repository != null) - writeList(list, p2MapFile, true); + writeList(listfeatureinfo, listbundleinfo, p2MapFile); - } catch (IOException e) { + } + catch (IOException e) { new BuildException(e); } } - // plugin@my.bundle.id,1.0.0=p2IU,id=my.bundle.id,version=1.0.0.v20081201,repository=http:/example.com/repo - private String generateP2Fetch(BundleInfo info) { - return BUNDLE_LINE_PREFIX + '@' + info.id + ',' + info.version + "=p2IU,id=" + info.id + ",version=" + info.fullVersion + ",repository=" + p2Repository + EOL; - } - - // plugin@my.bundle.id,1.0.0=GET,http://eclipse.org/downloads/orbit/my.bundle.id_1.0.0.v20081201.zip,unpack=true|false - private String generateCVSFetch(BundleInfo info) { - String fileName = info.id + "_" + info.fullVersion; - boolean isJar = isJar(fileName); - return new String(BUNDLE_LINE_PREFIX + "@" + info.id + ',' + info.version + "=GET," + addressPrefix + fileName + (isJar ? ".jar" : ".zip,unpack=true") + (username == null ? "" : ',' + username) + (pwd == null ? "" : ',' + pwd) + EOL); + // plugin@my.bundle.id,1.0.0=p2IU,id=my.bundle.id,version=1.0.0.v20081201,repository=http:/example.com/repo + private String generateP2Fetch(String prefix, BundleInfo info) { + return prefix + '@' + info.id + ',' + info.version + "=p2IU,id=" + info.id + ",version=" + info.fullVersion + ",repository=" + p2Repository + EOL; } - private List getBundleDetails() throws FileNotFoundException, IOException { + private List getVersionDetails(String inputFile) throws FileNotFoundException, IOException { List bundleDetailsList = new ArrayList(); BufferedReader reader = null; try { @@ -133,7 +124,8 @@ public class MapFileGenerator extends Task { m = replacementExpression.matcher(current); if (!m.matches()) continue; - // the properties file contains entries with and without a version and + // the properties file contains entries with and without a + // version and // we want to skip the non-version ones if (m.group(2) == null) continue; @@ -145,68 +137,57 @@ public class MapFileGenerator extends Task { bundleDetailsList.add(info); } - } finally { + } + finally { if (reader != null) reader.close(); } return bundleDetailsList; } - private void writeList(List bundleDetailsList, String output, boolean isP2) throws IOException { + private void writeList(List featureDetailsList, List bundleDetailsList, String output) throws IOException { BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(output)); writer.write("!*** This file was created on " + dateFormat.format(new Date())); - Collections.sort(bundleDetailsList); - Iterator iterator = bundleDetailsList.iterator(); + + Collections.sort(featureDetailsList); + Iterator iterator = featureDetailsList.iterator(); while (iterator.hasNext()) { BundleInfo info = (BundleInfo) iterator.next(); // double space for readability - writer.write(EOL); - writer.write(isP2 ? generateP2Fetch(info) : generateCVSFetch(info)); + // writer.write(EOL); + writer.write(generateP2Fetch(FEATURE_LINE_PREFIX, info)); } - } finally { + + Collections.sort(bundleDetailsList); + Iterator iterator2 = bundleDetailsList.iterator(); + while (iterator2.hasNext()) { + BundleInfo info = (BundleInfo) iterator2.next(); + // double space for readability + // writer.write(EOL); + writer.write(generateP2Fetch(BUNDLE_LINE_PREFIX, info)); + } + } + finally { if (writer != null) writer.close(); } } - private boolean isJar(String path) { - File checked = new File(root, path + ".jar"); - if (checked.exists()) - return true; - return false; - } - - public void setRoot(File root) { - this.root = root; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String pwd) { - this.pwd = pwd; - } - - public void setAddressPrefix(String addressPrefix) { - this.addressPrefix = addressPrefix; - } - - public void setInputFile(String inputFile) { - this.inputFile = inputFile; - } - - public void setOutputFile(String outputFile) { - this.outputFile = outputFile; + public void setInputFilePluginVersions(String inputFile) { + this.inputFilePluginVersions = inputFile; } public void setP2MapFile(String value) { this.p2MapFile = value; } - + public void setP2Repository(String value) { this.p2Repository = value; } + + public void setInputFileFeatureVersions(String inputFileFeatureVersions) { + this.inputFileFeatureVersions = inputFileFeatureVersions; + } }