From 0a7ba7594585b7ca9d50ac1bfdd5407da23fde95 Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Tue, 16 Oct 2012 20:39:24 +0200 Subject: [391874] [Releng] Generate API reports during Hudson build https://bugs.eclipse.org/bugs/show_bug.cgi?id=391874 --- .../hudson/api_reports.ant | 3 +- .../hudson/api_reports.excludelist | 2 + .../src/org/eclipse/emf/cdo/releng/Api2Html.java | 52 ++++++++++++++++++---- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.ant b/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.ant index 3ae71cabe2..1a69662659 100644 --- a/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.ant +++ b/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.ant @@ -19,8 +19,7 @@ + includelist="${script.dir}/api_reports.includelist" /> diff --git a/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.excludelist b/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.excludelist index 1c3a0c61d6..1a15f87990 100644 --- a/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.excludelist +++ b/plugins/org.eclipse.emf.cdo.releng/hudson/api_reports.excludelist @@ -1,4 +1,6 @@ R:.*\.releng.* + R:.*\.doc.* + R:.*\.sdk.* R:.*\.examples.* R:.*\.tests.* R:.*\.buddies.* diff --git a/plugins/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Api2Html.java b/plugins/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Api2Html.java index ef313a000e..4ce8b32c7d 100644 --- a/plugins/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Api2Html.java +++ b/plugins/org.eclipse.emf.cdo.releng/src/org/eclipse/emf/cdo/releng/Api2Html.java @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; +import java.util.jar.Manifest; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -97,6 +98,9 @@ public class Api2Html extends DefaultHandler { try { + String componentVersion = null; + String componentChange = null; + String componentID = attributes.getValue("componentId"); String typeName = attributes.getValue("type_name"); String elementType = attributes.getValue("element_type"); @@ -105,9 +109,17 @@ public class Api2Html extends DefaultHandler if (message.startsWith("The re-exported type")) { return; + // int pos = message.indexOf(" from "); + // if (pos != -1) + // { + // message = message.substring(0, pos); + // } + // + // componentChange = message; + // message = null; + // typeName = null; } - String componentChange = null; if (componentID == null || componentID.length() == 0) { if (message.startsWith("The API component ")) @@ -117,12 +129,12 @@ public class Api2Html extends DefaultHandler if (message.endsWith("added")) { - componentChange = "The API component has been added"; - componentID = componentID.replace('_', '(') + ")"; + componentChange = "The plugin has been added"; + componentVersion = readComponentVersion(componentID); } else if (message.endsWith("removed")) { - componentChange = "The API component has been removed"; + componentChange = "The plugin has been removed"; } else { @@ -142,7 +154,6 @@ public class Api2Html extends DefaultHandler } } - String componentVersion = null; int pos = componentID.indexOf('('); if (pos != -1) { @@ -156,7 +167,7 @@ public class Api2Html extends DefaultHandler message = remove(message, " for class " + typeName); message = remove(message, " to " + typeName); - if (message.startsWith("The deprecation modifiers has")) + if (message != null && message.startsWith("The deprecation modifiers has")) { message = "The deprecation modifier has" + message.substring("The deprecation modifiers has".length()); } @@ -206,6 +217,26 @@ public class Api2Html extends DefaultHandler } } + private String readComponentVersion(String componentID) throws Exception + { + File plugin = new File(pluginsFolder, componentID); + File metaInf = new File(plugin, "META-INF"); + File manifestFile = new File(metaInf, "MANIFEST.MF"); + + FileInputStream in = new FileInputStream(manifestFile); + + try + { + Manifest manifest = new Manifest(in); + java.util.jar.Attributes attributes = manifest.getMainAttributes(); + return attributes.getValue("Bundle-Version"); + } + finally + { + in.close(); + } + } + private String determineElementType(String typeName) throws MalformedURLException { if (classLoader == null) @@ -311,10 +342,13 @@ public class Api2Html extends DefaultHandler private String remove(String string, String remove) { - int pos = string.indexOf(remove); - if (pos != -1) + if (string != null) { - string = string.substring(0, pos) + string.substring(pos + remove.length()); + int pos = string.indexOf(remove); + if (pos != -1) + { + string = string.substring(0, pos) + string.substring(pos + remove.length()); + } } return string; -- cgit v1.2.3