You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/09/04 20:26:15 UTC
svn commit: r1165080 - in /webservices/commons/trunk/modules/axiom: ./
modules/axiom-buildutils/ modules/axiom-buildutils/src/
modules/axiom-buildutils/src/main/ modules/axiom-buildutils/src/main/java/
modules/axiom-buildutils/src/main/java/org/ module...
Author: veithen
Date: Sun Sep 4 18:26:15 2011
New Revision: 1165080
URL: http://svn.apache.org/viewvc?rev=1165080&view=rev
Log:
Automatically adjust the OSGi metadata of axiom-impl and axiom-dom during the execution of maven-shade-plugin.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/ (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/pom.xml (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/
webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/OSGiManifestResourceTransformer.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-parent/pom.xml
webservices/commons/trunk/modules/axiom/pom.xml
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Sep 4 18:26:15 2011
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Added: webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/pom.xml?rev=1165080&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/pom.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/pom.xml Sun Sep 4 18:26:15 2011
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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>
+ <parent>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-parent</artifactId>
+ <version>1.2.13-SNAPSHOT</version>
+ <relativePath>../axiom-parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>axiom-buildutils</artifactId>
+ <name>Axiom Build Utilities</name>
+ <description>
+ Contains utility classes used during the build.
+ </description>
+ <!-- This needs to be set explicitly because the project structure implies that the Maven calculated defaults are wrong -->
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/axiom/modules/axiom-buildutils</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/axiom/modules/axiom-buildutils</developerConnection>
+ <url>http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-buildutils</url>
+ </scm>
+ <!-- This also needs to be set explicitly because the Maven calculated URL would point to nowhere -->
+ <url>http://ws.apache.org/axiom/</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>${shade.plugin.version}</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/OSGiManifestResourceTransformer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/OSGiManifestResourceTransformer.java?rev=1165080&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/OSGiManifestResourceTransformer.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/OSGiManifestResourceTransformer.java Sun Sep 4 18:26:15 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.buildutils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.apache.maven.plugins.shade.resource.ResourceTransformer;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Resource transformer that modifies the OSGi metadata in the manifest. It is designed for
+ * scenarios where maven-shade-plugin is used to include one or more OSGi bundles into a shaded
+ * artifact which is itself an OSGi bundle. It transforms the manifest of the shaded bundle such
+ * that:
+ * <ul>
+ * <li><tt>Import-Package</tt> entries satisfied by the included bundle are removed.
+ * <li><tt>Import-Package</tt> entries from included bundles are added to the
+ * <tt>Import-Package</tt> attribute of the shaded bundle.
+ * <ul>
+ */
+public class OSGiManifestResourceTransformer implements ResourceTransformer {
+ private Manifest shadedManifest;
+
+ public boolean canTransformResource(String resource) {
+ return resource.equals(JarFile.MANIFEST_NAME);
+ }
+
+ public void processResource(String resource, InputStream is, List relocators) throws IOException {
+ // We know that the first invocation of processResource is for the project's
+ // manifest (see the existing ManifestResourceTransformer's source code)
+ if (shadedManifest == null) {
+ shadedManifest = new Manifest(is);
+ } else {
+ Manifest manifest = new Manifest(is);
+ Attributes includedAttributes = manifest.getMainAttributes();
+ Attributes shadedAttributes = shadedManifest.getMainAttributes();
+ Set shadedImportPackages = new LinkedHashSet(Arrays.asList(
+ shadedAttributes.getValue("Import-Package").split(",")));
+ shadedImportPackages.removeAll(Arrays.asList(
+ includedAttributes.getValue("Export-Package").split(",")));
+ shadedImportPackages.addAll(Arrays.asList(
+ includedAttributes.getValue("Import-Package").split(",")));
+ shadedAttributes.putValue("Import-Package",
+ StringUtils.join(shadedImportPackages.iterator(), ","));
+ }
+ is.close();
+ }
+
+ public boolean hasTransformedResource() {
+ return shadedManifest != null;
+ }
+
+ public void modifyOutputStream(JarOutputStream os) throws IOException {
+ os.putNextEntry(new JarEntry(JarFile.MANIFEST_NAME));
+ shadedManifest.write(os);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-buildutils/src/main/java/org/apache/axiom/buildutils/OSGiManifestResourceTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/pom.xml?rev=1165080&r1=1165079&r2=1165080&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/pom.xml Sun Sep 4 18:26:15 2011
@@ -27,8 +27,10 @@
</parent>
<artifactId>axiom-common-impl</artifactId>
<name>Axiom Common Implementation Classes</name>
- <!-- This is a simple JAR, not a bundle. Classes will be included in axiom-impl and axiom-dom by maven-shade-plugin. -->
- <packaging>jar</packaging>
+ <!-- Although axiom-common-impl will never be used as a bundle itself, we still need the OSGi metadata
+ so that we can generate a correct manifest when the classes are included in axiom-impl and
+ axiom-dom by maven-shade-plugin. -->
+ <packaging>bundle</packaging>
<description>Contains implementation classes shared by LLOM and DOOM.</description>
<!-- This needs to be set explicitly because the project structure implies that the Maven calculated defaults are wrong -->
<scm>
@@ -50,4 +52,21 @@
<scope>test</scope>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <excludeDependencies>true</excludeDependencies>
+ <instructions>
+ <_nouses>true</_nouses>
+ <Export-Package>*;-noimport:=true</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml?rev=1165080&r1=1165079&r2=1165080&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml Sun Sep 4 18:26:15 2011
@@ -133,15 +133,6 @@
<instructions>
<_nouses>true</_nouses>
<Private-Package>org.apache.axiom.*</Private-Package>
- <Import-Package>
- <!-- These classes are included by maven-shade-plugin; don't import them. -->
- !org.apache.axiom.om.impl.common*,
- <!-- Packages used by axiom-common-impl and not detected by maven-bundle-plugin -->
- org.xml.sax,
- javax.xml.transform,
- org.apache.axiom.util.stax.xop,
- *
- </Import-Package>
</instructions>
</configuration>
</plugin>
@@ -184,9 +175,19 @@
<shadedPattern>org.apache.axiom.om.impl.dom</shadedPattern>
</relocation>
</relocations>
+ <transformers>
+ <transformer implementation="org.apache.axiom.buildutils.OSGiManifestResourceTransformer" />
+ </transformers>
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axiom-buildutils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<!-- Attach a JAR with the test classes so that we can reuse them in other modules
(see http://maven.apache.org/guides/mini/guide-attached-tests.html). -->
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml?rev=1165080&r1=1165079&r2=1165080&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml Sun Sep 4 18:26:15 2011
@@ -127,15 +127,6 @@
<instructions>
<_nouses>true</_nouses>
<Private-Package>org.apache.axiom.*</Private-Package>
- <Import-Package>
- <!-- These classes are included by maven-shade-plugin; don't import them. -->
- !org.apache.axiom.om.impl.common*,
- <!-- Packages used by axiom-common-impl and not detected by maven-bundle-plugin -->
- org.xml.sax,
- javax.xml.transform,
- org.apache.axiom.util.stax.xop,
- *
- </Import-Package>
</instructions>
</configuration>
</plugin>
@@ -163,9 +154,19 @@
<shadedPattern>org.apache.axiom.om.impl.llom</shadedPattern>
</relocation>
</relocations>
+ <transformers>
+ <transformer implementation="org.apache.axiom.buildutils.OSGiManifestResourceTransformer" />
+ </transformers>
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axiom-buildutils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<!-- Attach a JAR with the test classes so that we can reuse them in other modules
(see http://maven.apache.org/guides/mini/guide-attached-tests.html). -->
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-parent/pom.xml?rev=1165080&r1=1165079&r2=1165080&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-parent/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-parent/pom.xml Sun Sep 4 18:26:15 2011
@@ -279,7 +279,7 @@
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
- <version>1.4</version>
+ <version>${shade.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
@@ -460,5 +460,6 @@
<stax.impl.artifact>stax</stax.impl.artifact>
<stax.impl.version>1.2.0</stax.impl.version>
-->
+ <shade.plugin.version>1.4</shade.plugin.version>
</properties>
</project>
Modified: webservices/commons/trunk/modules/axiom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/pom.xml?rev=1165080&r1=1165079&r2=1165080&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/pom.xml Sun Sep 4 18:26:15 2011
@@ -545,6 +545,7 @@
</distributionManagement>
<modules>
<module>modules/axiom-parent</module>
+ <module>modules/axiom-buildutils</module>
<module>modules/axiom-testutils</module>
<module>modules/axiom-jaxen-testsuite</module>
<module>modules/axiom-api</module>