From 5caf37b8b148ab6169c17f3f3796c65bdc0625f7 Mon Sep 17 00:00:00 2001 From: jeffliu <jeffliu> Date: Tue, 29 Nov 2005 17:12:39 +0000 Subject: [PATCH] [115141] The API Scanner should be able to run from within the Eclipse workspace --- .../api/progress/APIProgressScanner.java | 53 ++++++++++++++++++- .../tools/component/classes/LibVisitor.java | 27 ++++++++++ .../component/classes/PluginVisitor.java | 36 +++++++++++++ 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java index 82d3d7cfc..589d559c1 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/api/progress/APIProgressScanner.java @@ -48,6 +48,8 @@ public class APIProgressScanner extends AbstractEmitter private String timestamp; private String progressDir; private String outputDir; + private Collection includes; + private Collection excludes; public String getTimestamp() { @@ -99,6 +101,26 @@ public class APIProgressScanner extends AbstractEmitter this.src = src; } + public Collection getIncludes() + { + return includes; + } + + public void setIncludes(Collection includes) + { + this.includes = includes; + } + + public Collection getExcludes() + { + return excludes; + } + + public void setExcludes(Collection excludes) + { + this.excludes = excludes; + } + public void execute() { genAPIInfoSummary(); @@ -239,7 +261,12 @@ public class APIProgressScanner extends AbstractEmitter { String id = (String)it2.next(); if (!pluginIds.remove(id)) - pluginsWithoutComp.add(id); + { + if (include(id)) + { + pluginsWithoutComp.add(id); + } + } } } for (Iterator it = pluginIds.iterator(); it.hasNext();) @@ -358,6 +385,24 @@ public class APIProgressScanner extends AbstractEmitter fos.close(); } + private boolean include(String name) + { + name = name.replace('/', '.'); + name = name.replace('\\', '.'); + if (excludes != null && !excludes.isEmpty()) + for (Iterator it = excludes.iterator(); it.hasNext();) + if (name.matches((String)it.next())) + return false; + if (includes != null && !includes.isEmpty()) + { + for (Iterator it = includes.iterator(); it.hasNext();) + if (name.matches((String)it.next())) + return true; + return false; + } + return true; + } + public static void main(String[] args) { CommandOptionParser optionParser = new CommandOptionParser(args); @@ -367,6 +412,8 @@ public class APIProgressScanner extends AbstractEmitter List timestamp = (List)options.get("timestamp"); List progressDir = (List)options.get("progressDir"); List outputDir = (List)options.get("outputDir"); + Collection includes = (Collection)options.get("includes"); + Collection excludes = (Collection)options.get("excludes"); if (outputDir == null || outputDir.size() < 1) { printUsage(); @@ -382,6 +429,8 @@ public class APIProgressScanner extends AbstractEmitter if (progressDir != null && progressDir.size() > 0) scanner.setProgressDir((String)progressDir.iterator().next()); scanner.setOutputDir((String)outputDir.iterator().next()); + scanner.setIncludes(includes); + scanner.setExcludes(excludes); scanner.execute(); } @@ -397,6 +446,8 @@ public class APIProgressScanner extends AbstractEmitter System.out.println("\t-src\t\t<src>\t\tlocation of a Eclipse-based product"); System.out.println("\t-timestamp\t<timestamp>\ttimestamp"); System.out.println("\t-progressDir\t<progressDir>\tdirectory containing API progress documents"); + System.out.println("\t-includes\t<includes>\tspace seperated plug-ins to include"); + System.out.println("\t-excludes\t<excludes>\tspace seperated plug-ins to exclude"); } private class OverviewDocLoader diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java index 69a321574..12493afa2 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/LibVisitor.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; +import java.util.jar.JarInputStream; import java.util.jar.Manifest; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -303,6 +304,32 @@ public class LibVisitor implements ILocationVisitor } } } + if (Location.getExtension(location.getName()).equalsIgnoreCase("jar")) + { + try + { + JarInputStream jis = new JarInputStream(location.getInputStream()); + Manifest manifest = jis.getManifest(); + if (manifest != null) + { + java.util.jar.Attributes attrs = manifest.getMainAttributes(); + String bundleNameAttr = attrs.getValue(new java.util.jar.Attributes.Name(Bundle.CONST_BUNDLE_NAME)); + if (bundleNameAttr != null) + { + String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim(); + if (bundleName != null) + { + bundleName = (new StringTokenizer(bundleName, ";")).nextToken().trim(); + lib2pluginId.put(location.getName().replace('\\', '/'), bundleName); + return false; + } + } + } + } + catch (IOException ioe) + { + } + } return true; } diff --git a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java index 659063ad5..faa2c3cb9 100644 --- a/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java +++ b/archive/releng.builder/tools/apitools/org.eclipse.wtp.releng.tools.component.core/src/org/eclipse/wtp/releng/tools/component/classes/PluginVisitor.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.StringTokenizer; +import java.util.jar.JarInputStream; import java.util.jar.Manifest; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -136,6 +137,7 @@ public class PluginVisitor implements ILocationVisitor private boolean acceptSingleJar(ILocation location) { ILocationChildrenIterator it = location.childIterator(); + boolean pluginAdded = false; for (ILocation child = it.next(); child != null; child = it.next()) { String name = child.getName(); @@ -150,7 +152,10 @@ public class PluginVisitor implements ILocationVisitor { String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim(); if (bundleName != null && bundleName.length() > 0 && !pluginIds.contains(bundleName)) + { pluginIds.add(bundleName); + pluginAdded = true; + } } } catch (IOException e) @@ -169,7 +174,10 @@ public class PluginVisitor implements ILocationVisitor { String id = root.getAttribute("id"); if (id != null && id.length() > 0 && !pluginIds.contains(id)) + { pluginIds.add(id); + pluginAdded = true; + } } } catch (Throwable e) @@ -188,7 +196,10 @@ public class PluginVisitor implements ILocationVisitor { String id = root.getAttribute("id"); if (id != null && id.length() > 0 && !pluginIds.contains(id)) + { pluginIds.add(id); + pluginAdded = true; + } } } catch (Throwable e) @@ -196,6 +207,31 @@ public class PluginVisitor implements ILocationVisitor } } } + if (!pluginAdded && Location.getExtension(location.getName()).equalsIgnoreCase("jar")) + { + try + { + JarInputStream jis = new JarInputStream(location.getInputStream()); + Manifest manifest = jis.getManifest(); + if (manifest != null) + { + java.util.jar.Attributes attrs = manifest.getMainAttributes(); + String bundleNameAttr = attrs.getValue(new java.util.jar.Attributes.Name(Bundle.CONST_BUNDLE_NAME)); + if (bundleNameAttr != null) + { + String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim(); + if (bundleName != null && bundleName.length() > 0 && !pluginIds.contains(bundleName)) + { + pluginIds.add(bundleName); + pluginAdded = true; + } + } + } + } + catch (IOException ioe) + { + } + } return true; } -- GitLab