changeset 1355:2b4f0b23f517

Build javadocs for core API only Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-November/008881.html
author Omair Majid <omajid@redhat.com>
date Fri, 22 Nov 2013 12:50:26 -0500
parents 21047c9ee50e
children b917318b72ce
files distribution/tools/ListExportedClasses.java pom.xml
diffstat 2 files changed, 60 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/distribution/tools/ListExportedClasses.java	Fri Nov 22 11:29:05 2013 -0500
+++ b/distribution/tools/ListExportedClasses.java	Fri Nov 22 12:50:26 2013 -0500
@@ -52,20 +52,52 @@
     public static void main(String[] args) {
         if (args.length == 0) {
             System.out.println("Usage:");
-            System.out.println("\tjava ListExportedClass path/to/jar1 [path/to/jar2 [path/to/jar3 [...]]]");
+            System.out.println("\tjava ListExportedClass [options] path/to/jar1 [path/to/jar2 [path/to/jar3 [...]]]");
             System.out.println();
             System.out.println("Prints a list of OSGi-exported packages and public classes in those packages");
+            System.out.println();
+            System.out.println("Options:");
+            System.out.println("\t--private\t\tshow only OSGi-private packages");
+            System.out.println("\t--packages\t\tshow packages only");
         }
 
-        List<String> jarNames = Arrays.asList(args);
+        // whether to show public or private packages
+        boolean listPublicPackages = true;
+
+        boolean listPackagesOnly = false;
+
+        List<String> jarNames = new ArrayList<>(Arrays.asList(args));
+        for (String arg : args) {
+            if (arg.equals("--private")) {
+                listPublicPackages = false;
+                jarNames.remove(arg);
+            } else if (arg.equals("--packages")) {
+                listPackagesOnly = true;
+                jarNames.remove(arg);
+            }
+        }
+
         for (String jarName : jarNames) {
-            System.out.println(jarName);
+            if (!listPackagesOnly) {
+                System.out.println(jarName);
+            }
             try {
                 JarFile jarFile = new JarFile(jarName);
-                for (String exportedPackage : findOSGiExportedPackages(jarFile)) {
-                    System.out.println("\t" + exportedPackage);
-                    for (String exportedClass : findOSGiExportedClassesInPackage(jarFile, exportedPackage)) {
-                        System.out.println("\t\t" + exportedClass);
+                if (listPublicPackages) {
+                    for (String exportedPackage : findOSGiExportedPackages(jarFile)) {
+                        System.out.println("\t" + exportedPackage);
+                        if (!listPackagesOnly) {
+                            for (String exportedClass : findOSGiExportedClassesInPackage(jarFile, exportedPackage)) {
+                                System.out.println("\t\t" + exportedClass);
+                            }
+                        }
+                    }
+                } else {
+                    for (String privatePackage : findOSGiPrivatePackages(jarFile)) {
+                        System.out.println(privatePackage);
+                        if (!listPackagesOnly) {
+                            System.err.println("not implemented");
+                        }
                     }
                 }
             } catch (IOException ioe) {
@@ -172,21 +204,32 @@
 
     private static List<String> findOSGiExportedPackages(JarFile jarFile) throws IOException {
         Manifest manifest = jarFile.getManifest();
-        String exportedPackagesString = manifest.getMainAttributes().getValue("Export-Package");
-        if (exportedPackagesString == null) {
+        String exportedPackages = manifest.getMainAttributes().getValue("Export-Package");
+        return convertPackageStringToList(exportedPackages);
+    }
+
+    private static List<String> findOSGiPrivatePackages(JarFile jarFile) throws IOException {
+        Manifest manifest = jarFile.getManifest();
+        String privatePackages = manifest.getMainAttributes().getValue("Private-Package");
+        return convertPackageStringToList(privatePackages);
+    }
+
+    private static List<String> convertPackageStringToList(String packages) {
+        if (packages == null) {
             return new ArrayList<>();
         }
-        List<String> exportedPackages = Arrays.asList(exportedPackagesString.split(","));
-        for (int i = 0; i < exportedPackages.size(); i++) {
-            String exportedPackage = exportedPackages.get(i);
+        List<String> packagesList = Arrays.asList(packages.split(","));
+        for (int i = 0; i < packagesList.size(); i++) {
+            String exportedPackage = packagesList.get(i);
             // exports can have a ";uses.." part after the package name. remove it.
             int indexOfUses = exportedPackage.indexOf(";");
             if (indexOfUses != -1) {
                 exportedPackage = exportedPackage.substring(0, indexOfUses);
             }
-            exportedPackages.set(i, exportedPackage);
+            packagesList.set(i, exportedPackage);
         }
-        Collections.sort(exportedPackages);
-        return exportedPackages;
+        Collections.sort(packagesList);
+        return packagesList;
     }
+
 }
--- a/pom.xml	Fri Nov 22 11:29:05 2013 -0500
+++ b/pom.xml	Fri Nov 22 12:50:26 2013 -0500
@@ -221,7 +221,8 @@
           <artifactId>maven-javadoc-plugin</artifactId>
           <version>2.9.1</version>
           <configuration>
-            <excludePackageNames>*.impl.*;*.internal.*</excludePackageNames>
+            <excludePackageNames>*.impl*;*.internal.*;com.redhat.thermostat.agent.locale;com.redhat.thermostat.agent.proxy.server;com.redhat.thermostat.backend.system;com.redhat.thermostat.client.command.cli;com.redhat.thermostat.client.filter.host.swing;com.redhat.thermostat.client.filter.vm.swing;com.redhat.thermostat.numa;com.redhat.thermostat.plugin.validator.locale;com.redhat.thermostat.test;com.redhat.thermostat.testutils;com.redhat.thermostat.utils.keyring.activator;com.redhat.thermostat.vm;com.redhat.thermostat.host;com.redhat.thermostat.gc;com.redhat.thermostat.thread;com.redhat.thermostat.validate;com.redhat.thermostat.service.activator</excludePackageNames>
+            <debug>true</debug>
           </configuration>
         </plugin>
         <plugin>