This is an automated email from the ASF dual-hosted git repository.

simonetripodi pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 6aa471c  SLING-8340 - APIs jar MOJO doesn't handle OSGi wrapper bundles
6aa471c is described below

commit 6aa471c1a73846334b9369b611bdd3efa9d9d05e
Author: stripodi <stripodi@simos-mbp>
AuthorDate: Mon May 13 06:35:04 2019 +0200

    SLING-8340 - APIs jar MOJO doesn't handle OSGi wrapper bundles
    
    added integration test and fixed recursion handling
---
 src/it/apis-jar-wrapper-bundle/invoker.properties  | 17 +++++
 src/it/apis-jar-wrapper-bundle/pom.xml             | 53 +++++++++++++++
 .../src/main/features/main.json                    | 17 +++++
 src/it/apis-jar-wrapper-bundle/verify.bsh          | 77 ++++++++++++++++++++++
 .../sling/feature/maven/mojos/ApisJarMojo.java     |  4 +-
 5 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/src/it/apis-jar-wrapper-bundle/invoker.properties 
b/src/it/apis-jar-wrapper-bundle/invoker.properties
new file mode 100644
index 0000000..91f59c8
--- /dev/null
+++ b/src/it/apis-jar-wrapper-bundle/invoker.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+invoker.goals = clean org.apache.sling:slingfeature-maven-plugin:apis-jar
+invoker.debug = true
diff --git a/src/it/apis-jar-wrapper-bundle/pom.xml 
b/src/it/apis-jar-wrapper-bundle/pom.xml
new file mode 100644
index 0000000..1ecf87e
--- /dev/null
+++ b/src/it/apis-jar-wrapper-bundle/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+    agreements. See the NOTICE file distributed with this work for additional 
information
+    regarding copyright ownership. The ASF licenses this file to you under the 
Apache License,
+    Version 2.0 (the "License"); you may not use this file except in 
compliance with the
+    License. You may obtain a copy of the License at 
http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software 
distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND,
+    either express or implied. See the License for the specific language 
governing permissions
+    and limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.sling</groupId>
+  <artifactId>slingfeature-maven-plugin-test</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0-SNAPSHOT</version>
+
+  <name>Apache Sling Features Maven plugin test</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <extensions>true</extensions>
+        <executions>
+          <execution>
+            <id>analyze</id>
+            <phase>package</phase>
+            <goals>
+              <goal>apis-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <selection>
+            <filesInclude>**/*.json</filesInclude>
+          </selection>
+          <includeResources>
+            <includeResource>*.cnd</includeResource>
+            <includeResource>*.tld</includeResource>
+          </includeResources>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/src/it/apis-jar-wrapper-bundle/src/main/features/main.json 
b/src/it/apis-jar-wrapper-bundle/src/main/features/main.json
new file mode 100644
index 0000000..b1315d4
--- /dev/null
+++ b/src/it/apis-jar-wrapper-bundle/src/main/features/main.json
@@ -0,0 +1,17 @@
+{
+  "id":"org.apache.sling:slingfeature-maven-plugin-test:1.0.0-SNAPSHOT",
+  "bundles":[
+    {
+      "id":"io.wcm.osgi.wrapper:io.wcm.osgi.wrapper.gson:2.8.4-0000",
+      "start-level":"4"
+    }
+  ],
+  "api-regions:JSON|false": [
+    {
+      "name": "base",
+      "exports": [
+        "com.google.gson.stream"
+      ]
+    }
+  ]
+}
diff --git a/src/it/apis-jar-wrapper-bundle/verify.bsh 
b/src/it/apis-jar-wrapper-bundle/verify.bsh
new file mode 100644
index 0000000..d017b0a
--- /dev/null
+++ b/src/it/apis-jar-wrapper-bundle/verify.bsh
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+
+import org.codehaus.plexus.util.*;
+
+    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 '" + file + "' 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 " + file);
+                return false;
+            }
+
+            for (String expectedEntry : new String[] {
+                "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 " + file);
+                    return false;
+                }
+            }
+        } finally {
+            if (jarFile != null) {
+                jarFile.close();
+            }
+        }
+
+        return true;
+    }
+
+    try {
+        return check();
+    } catch(Throwable t) {
+        t.printStackTrace();
+        return false;
+    }
+
+    return true;
diff --git 
a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java 
b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
index 389995e..e23e5ae 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
@@ -295,7 +295,9 @@ public class ApisJarMojo extends 
AbstractIncludingFeatureMojo implements Artifac
         File deflatedBundleDirectory = deflate(deflatedBinDir, bundleFile, 
exportedPackagesAndWrappedBundles);
 
         // check if the bundle wraps other bundles
-        computeWrappedBundles(manifest, deflatedBundleDirectory, apiRegions, 
javadocClasspath, deflatedBinDir, deflatedSourcesDir, checkedOutSourcesDir);
+        if (wrappingBundleManifest == null) { // wrappers of wrappers do not 
exist
+            computeWrappedBundles(manifest, deflatedBundleDirectory, 
apiRegions, javadocClasspath, deflatedBinDir, deflatedSourcesDir, 
checkedOutSourcesDir);
+        }
 
         // renaming potential name-collapsing resources
         renameResources(deflatedBundleDirectory, artifactId);

Reply via email to