ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1795751 - in /webservices/axiom/trunk: axiom-api/ axiom-api/src/main/java/org/apache/axiom/util/base64/ buildutils/shade-osgi/src/main/java/org/apache/axiom/buildutils/shade/osgi/ code-coverage/ components/ components/base64-utils/ compone...
Date Sun, 21 May 2017 22:46:46 GMT
Author: veithen
Date: Sun May 21 22:46:46 2017
New Revision: 1795751

URL: http://svn.apache.org/viewvc?rev=1795751&view=rev
Log:
Move the Base64 related code into a separate module for reuse by code that doesn't depend
on axiom-api.

Added:
    webservices/axiom/trunk/components/base64-utils/   (with props)
    webservices/axiom/trunk/components/base64-utils/pom.xml   (with props)
    webservices/axiom/trunk/components/base64-utils/src/
    webservices/axiom/trunk/components/base64-utils/src/main/
    webservices/axiom/trunk/components/base64-utils/src/main/java/
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/Base64Constants.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64Constants.java
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/Base64DecodingOutputStreamWriter.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64DecodingOutputStreamWriter.java
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/Base64EncodingOutputStream.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingOutputStream.java
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/Base64EncodingStringBufferOutputStream.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingStringBufferOutputStream.java
    webservices/axiom/trunk/components/base64-utils/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java
      - copied unchanged from r1795750, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java
Removed:
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64Constants.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64DecodingOutputStreamWriter.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingOutputStream.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingStringBufferOutputStream.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java
Modified:
    webservices/axiom/trunk/axiom-api/pom.xml
    webservices/axiom/trunk/buildutils/shade-osgi/src/main/java/org/apache/axiom/buildutils/shade/osgi/OSGiManifestResourceTransformer.java
    webservices/axiom/trunk/code-coverage/pom.xml
    webservices/axiom/trunk/components/pom.xml

Modified: webservices/axiom/trunk/axiom-api/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/pom.xml?rev=1795751&r1=1795750&r2=1795751&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/pom.xml (original)
+++ webservices/axiom/trunk/axiom-api/pom.xml Sun May 21 22:46:46 2017
@@ -35,6 +35,12 @@
 
     <dependencies>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>base64-utils</artifactId>
+            <version>${project.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
         </dependency>
@@ -239,6 +245,36 @@
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <artifactId>maven-shade-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <artifactSet>
+                        <includes>
+                            <include>${project.groupId}:base64-utils</include>
+                        </includes>
+                    </artifactSet>
+                    <transformers>
+                        <transformer implementation="org.apache.axiom.buildutils.shade.osgi.OSGiManifestResourceTransformer"
/>
+                    </transformers>
+                    <createDependencyReducedPom>false</createDependencyReducedPom>
+                    <createSourcesJar>true</createSourcesJar>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>${project.groupId}</groupId>
+                        <artifactId>shade-osgi</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

Modified: webservices/axiom/trunk/buildutils/shade-osgi/src/main/java/org/apache/axiom/buildutils/shade/osgi/OSGiManifestResourceTransformer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/buildutils/shade-osgi/src/main/java/org/apache/axiom/buildutils/shade/osgi/OSGiManifestResourceTransformer.java?rev=1795751&r1=1795750&r2=1795751&view=diff
==============================================================================
--- webservices/axiom/trunk/buildutils/shade-osgi/src/main/java/org/apache/axiom/buildutils/shade/osgi/OSGiManifestResourceTransformer.java
(original)
+++ webservices/axiom/trunk/buildutils/shade-osgi/src/main/java/org/apache/axiom/buildutils/shade/osgi/OSGiManifestResourceTransformer.java
Sun May 21 22:46:46 2017
@@ -21,7 +21,10 @@ package org.apache.axiom.buildutils.shad
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -50,36 +53,38 @@ import org.osgi.framework.BundleExceptio
  */
 public class OSGiManifestResourceTransformer implements ResourceTransformer {
     private Manifest originalManifest;
-    private final Set<String> importedPackages = new LinkedHashSet<String>();
+    private final List<ManifestElement> packageImports = new ArrayList<ManifestElement>();
     private final Set<String> packagesExportedFromIncludedJARs = new LinkedHashSet<String>();
     
     public boolean canTransformResource(String resource) {
         return resource.equals(JarFile.MANIFEST_NAME);
     }
 
-    private static List<String> extractPackages(Attributes attributes, String header)
throws IOException {
-        String value = attributes.getValue(header);
+    private static List<ManifestElement> parseAttribute(Attributes attributes, String
attributeName) throws IOException {
+        String value = attributes.getValue(attributeName);
         if (value == null) {
             return Collections.emptyList();
         } else {
-            ManifestElement[] elements;
             try {
-                elements = ManifestElement.parseHeader("Export-Package", value);
+                return Arrays.asList(ManifestElement.parseHeader(attributeName, value));
             } catch (BundleException ex) {
                 throw new IOException("Invalid bundle manifest", ex);
             }
-            List<String> result = new ArrayList<String>(elements.length);
-            for (ManifestElement element : elements) {
-                result.add(element.getValue());
-            }
-            return result;
         }
     }
+
+    private static List<String> extractPackages(Attributes attributes, String attributeName)
throws IOException {
+        List<String> result = new ArrayList<String>();
+        for (ManifestElement element : parseAttribute(attributes, attributeName)) {
+            result.add(element.getValue());
+        }
+        return result;
+    }
     
     public void processResource(String resource, InputStream is, List<Relocator> relocators)
throws IOException {
         Manifest manifest = new Manifest(is);
         Attributes attributes = manifest.getMainAttributes();
-        importedPackages.addAll(extractPackages(attributes, "Import-Package"));
+        packageImports.addAll(parseAttribute(attributes, "Import-Package"));
         // We know that the first invocation of processResource is for the project's
         // manifest (see the existing ManifestResourceTransformer's source code)
         if (originalManifest == null) {
@@ -95,9 +100,15 @@ public class OSGiManifestResourceTransfo
     }
 
     public void modifyOutputStream(JarOutputStream os) throws IOException {
-        importedPackages.removeAll(packagesExportedFromIncludedJARs);
+        Set<String> importedPackages = new HashSet<>();
+        for (Iterator<ManifestElement> it = packageImports.iterator(); it.hasNext();
) {
+            String importedPackage = it.next().getValue();
+            if (packagesExportedFromIncludedJARs.contains(importedPackage) || !importedPackages.add(importedPackage))
{
+                it.remove();
+            }
+        }
         originalManifest.getMainAttributes().putValue("Import-Package",
-                StringUtils.join(importedPackages.iterator(), ","));
+                StringUtils.join(packageImports.iterator(), ","));
         os.putNextEntry(new JarEntry(JarFile.MANIFEST_NAME));
         originalManifest.write(os);
     }

Modified: webservices/axiom/trunk/code-coverage/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/code-coverage/pom.xml?rev=1795751&r1=1795750&r2=1795751&view=diff
==============================================================================
--- webservices/axiom/trunk/code-coverage/pom.xml (original)
+++ webservices/axiom/trunk/code-coverage/pom.xml Sun May 21 22:46:46 2017
@@ -47,6 +47,18 @@
         
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>base64-utils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>base64-utils</artifactId>
+            <version>${project.version}</version>
+            <classifier>sources</classifier>
+        </dependency>
+        
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>axiom-api</artifactId>
             <version>${project.version}</version>
         </dependency>

Propchange: webservices/axiom/trunk/components/base64-utils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun May 21 22:46:46 2017
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Added: webservices/axiom/trunk/components/base64-utils/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/components/base64-utils/pom.xml?rev=1795751&view=auto
==============================================================================
--- webservices/axiom/trunk/components/base64-utils/pom.xml (added)
+++ webservices/axiom/trunk/components/base64-utils/pom.xml Sun May 21 22:46:46 2017
@@ -0,0 +1,33 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ws.commons.axiom</groupId>
+        <artifactId>components</artifactId>
+        <version>1.3.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>base64-utils</artifactId>
+    <packaging>bundle</packaging>
+
+    <url>http://ws.apache.org/axiom/</url>
+</project>

Propchange: webservices/axiom/trunk/components/base64-utils/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/components/pom.xml?rev=1795751&r1=1795750&r2=1795751&view=diff
==============================================================================
--- webservices/axiom/trunk/components/pom.xml (original)
+++ webservices/axiom/trunk/components/pom.xml Sun May 21 22:46:46 2017
@@ -32,6 +32,7 @@
     <url>http://ws.apache.org/axiom/</url>
 
     <modules>
+        <module>base64-utils</module>
         <module>core-streams</module>
         <module>xml-utils</module>
     </modules>



Mime
View raw message