boolean check()

in src/it/apis-jar-wrapper-bundle/verify.groovy [24:68]


    boolean check() throws Exception {
        File apisJarDir = new File(basedir, "target/apis-jars");

        // base

        File baseApiJar = new File(apisJarDir, "slingfeature-maven-plugin-test-1.0.0-SNAPSHOT-base-apis.jar");
        if (!baseApiJar.exists()) {
            System.out.println("FAILED!");
            System.out.println("File '" + baseApiJar + "' not found");
            return false;
        }

        JarFile jarFile = null;
        try {
            jarFile = new JarFile(baseApiJar);
            Manifest manifest= jarFile.getManifest();
            String exportPackageHeader = manifest.getMainAttributes().getValue("Export-Package");

            if (exportPackageHeader.indexOf("com.google.gson.stream;version=2.8.4") < 0) {
                System.out.println("FAILED!");
                System.out.println("Export-Package header '" + exportPackageHeader + "' does not contain 'com.google.gson.stream;version=\"2.8.4\"' in bundle " + baseApiJar);
                return false;
            }

            for (String expectedEntry : [
                "com/google/gson/stream/JsonReader.class",
                "com/google/gson/stream/JsonScope.class",
                "com/google/gson/stream/JsonToken.class",
                "com/google/gson/stream/JsonWriter.class",
                "com/google/gson/stream/MalformedJsonException.class"
            ]) {
                if (jarFile.getJarEntry(expectedEntry) == null) {
                    System.out.println("FAILED!");
                    System.out.println("Entry '" + expectedEntry + "' does not exist in bundle " + baseApiJar);
                    return false;
                }
            }
        } finally {
            if (jarFile != null) {
                jarFile.close();
            }
        }

        return true;
    }