Skip to content
Snippets Groups Projects
Commit 5caf37b8 authored by jeffliu's avatar jeffliu
Browse files

[115141] The API Scanner should be able to run from within the Eclipse workspace

parent 5f2558b6
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,8 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -48,6 +48,8 @@ public class APIProgressScanner extends AbstractEmitter
private String timestamp; private String timestamp;
private String progressDir; private String progressDir;
private String outputDir; private String outputDir;
private Collection includes;
private Collection excludes;
public String getTimestamp() public String getTimestamp()
{ {
...@@ -99,6 +101,26 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -99,6 +101,26 @@ public class APIProgressScanner extends AbstractEmitter
this.src = src; 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() public void execute()
{ {
genAPIInfoSummary(); genAPIInfoSummary();
...@@ -239,7 +261,12 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -239,7 +261,12 @@ public class APIProgressScanner extends AbstractEmitter
{ {
String id = (String)it2.next(); String id = (String)it2.next();
if (!pluginIds.remove(id)) if (!pluginIds.remove(id))
pluginsWithoutComp.add(id); {
if (include(id))
{
pluginsWithoutComp.add(id);
}
}
} }
} }
for (Iterator it = pluginIds.iterator(); it.hasNext();) for (Iterator it = pluginIds.iterator(); it.hasNext();)
...@@ -358,6 +385,24 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -358,6 +385,24 @@ public class APIProgressScanner extends AbstractEmitter
fos.close(); 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) public static void main(String[] args)
{ {
CommandOptionParser optionParser = new CommandOptionParser(args); CommandOptionParser optionParser = new CommandOptionParser(args);
...@@ -367,6 +412,8 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -367,6 +412,8 @@ public class APIProgressScanner extends AbstractEmitter
List timestamp = (List)options.get("timestamp"); List timestamp = (List)options.get("timestamp");
List progressDir = (List)options.get("progressDir"); List progressDir = (List)options.get("progressDir");
List outputDir = (List)options.get("outputDir"); List outputDir = (List)options.get("outputDir");
Collection includes = (Collection)options.get("includes");
Collection excludes = (Collection)options.get("excludes");
if (outputDir == null || outputDir.size() < 1) if (outputDir == null || outputDir.size() < 1)
{ {
printUsage(); printUsage();
...@@ -382,6 +429,8 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -382,6 +429,8 @@ public class APIProgressScanner extends AbstractEmitter
if (progressDir != null && progressDir.size() > 0) if (progressDir != null && progressDir.size() > 0)
scanner.setProgressDir((String)progressDir.iterator().next()); scanner.setProgressDir((String)progressDir.iterator().next());
scanner.setOutputDir((String)outputDir.iterator().next()); scanner.setOutputDir((String)outputDir.iterator().next());
scanner.setIncludes(includes);
scanner.setExcludes(excludes);
scanner.execute(); scanner.execute();
} }
...@@ -397,6 +446,8 @@ public class APIProgressScanner extends AbstractEmitter ...@@ -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-src\t\t<src>\t\tlocation of a Eclipse-based product");
System.out.println("\t-timestamp\t<timestamp>\ttimestamp"); System.out.println("\t-timestamp\t<timestamp>\ttimestamp");
System.out.println("\t-progressDir\t<progressDir>\tdirectory containing API progress documents"); 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 private class OverviewDocLoader
......
...@@ -15,6 +15,7 @@ import java.io.IOException; ...@@ -15,6 +15,7 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
...@@ -303,6 +304,32 @@ public class LibVisitor implements ILocationVisitor ...@@ -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; return true;
} }
......
...@@ -15,6 +15,7 @@ import java.util.ArrayList; ...@@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
...@@ -136,6 +137,7 @@ public class PluginVisitor implements ILocationVisitor ...@@ -136,6 +137,7 @@ public class PluginVisitor implements ILocationVisitor
private boolean acceptSingleJar(ILocation location) private boolean acceptSingleJar(ILocation location)
{ {
ILocationChildrenIterator it = location.childIterator(); ILocationChildrenIterator it = location.childIterator();
boolean pluginAdded = false;
for (ILocation child = it.next(); child != null; child = it.next()) for (ILocation child = it.next(); child != null; child = it.next())
{ {
String name = child.getName(); String name = child.getName();
...@@ -150,7 +152,10 @@ public class PluginVisitor implements ILocationVisitor ...@@ -150,7 +152,10 @@ public class PluginVisitor implements ILocationVisitor
{ {
String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim(); String bundleName = (new StringTokenizer(bundleNameAttr, ";")).nextToken().trim();
if (bundleName != null && bundleName.length() > 0 && !pluginIds.contains(bundleName)) if (bundleName != null && bundleName.length() > 0 && !pluginIds.contains(bundleName))
{
pluginIds.add(bundleName); pluginIds.add(bundleName);
pluginAdded = true;
}
} }
} }
catch (IOException e) catch (IOException e)
...@@ -169,7 +174,10 @@ public class PluginVisitor implements ILocationVisitor ...@@ -169,7 +174,10 @@ public class PluginVisitor implements ILocationVisitor
{ {
String id = root.getAttribute("id"); String id = root.getAttribute("id");
if (id != null && id.length() > 0 && !pluginIds.contains(id)) if (id != null && id.length() > 0 && !pluginIds.contains(id))
{
pluginIds.add(id); pluginIds.add(id);
pluginAdded = true;
}
} }
} }
catch (Throwable e) catch (Throwable e)
...@@ -188,7 +196,10 @@ public class PluginVisitor implements ILocationVisitor ...@@ -188,7 +196,10 @@ public class PluginVisitor implements ILocationVisitor
{ {
String id = root.getAttribute("id"); String id = root.getAttribute("id");
if (id != null && id.length() > 0 && !pluginIds.contains(id)) if (id != null && id.length() > 0 && !pluginIds.contains(id))
{
pluginIds.add(id); pluginIds.add(id);
pluginAdded = true;
}
} }
} }
catch (Throwable e) catch (Throwable e)
...@@ -196,6 +207,31 @@ public class PluginVisitor implements ILocationVisitor ...@@ -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; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment