maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r882989 - in /maven/plugins/trunk/maven-shade-plugin: ./ src/it/reloc-enum-ref-from-anno/ src/it/reloc-enum-ref-from-anno/src/ src/it/reloc-enum-ref-from-anno/src/main/ src/it/reloc-enum-ref-from-anno/src/main/java/ src/it/reloc-enum-ref-fr...
Date Sat, 21 Nov 2009 20:45:34 GMT
Author: bentmann
Date: Sat Nov 21 20:45:33 2009
New Revision: 882989

URL: http://svn.apache.org/viewvc?rev=882989&view=rev
Log:
[MSHADE-64] Relocating does not work, when an annotation references an enum

Added:
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties
  (with props)
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml   (with
props)
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java
  (with props)
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java
  (with props)
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/
    maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java
  (with props)
Modified:
    maven/plugins/trunk/maven-shade-plugin/pom.xml
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java

Modified: maven/plugins/trunk/maven-shade-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/pom.xml?rev=882989&r1=882988&r2=882989&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-shade-plugin/pom.xml Sat Nov 21 20:45:33 2009
@@ -93,12 +93,12 @@
     <dependency>
       <groupId>asm</groupId>
       <artifactId>asm</artifactId>
-      <version>3.1</version>
+      <version>3.2</version>
     </dependency>
     <dependency>
       <groupId>asm</groupId>
       <artifactId>asm-commons</artifactId>
-      <version>3.1</version>
+      <version>3.2</version>
     </dependency>
     <dependency>
       <groupId>jdom</groupId>
@@ -143,7 +143,7 @@
         <plugins>
           <plugin>
             <artifactId>maven-invoker-plugin</artifactId>
-            <version>1.4</version>
+            <version>1.5</version>
             <configuration>
               <debug>true</debug>
               <projectsDirectory>src/it</projectsDirectory>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties?rev=882989&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties
(added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties
Sat Nov 21 20:45:33 2009
@@ -0,0 +1 @@
+invoker.java.version = 1.5+

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml?rev=882989&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml Sat Nov
21 20:45:33 2009
@@ -0,0 +1,108 @@
+<?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>
+
+  <groupId>org.apache.maven.its.shade.rerfa</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>MSHADE-64</name>
+  <description>
+    Test that enum references in annotations are properly relocated.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.1</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>shade</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <createDependencyReducedPom>false</createDependencyReducedPom>
+              <relocations>
+                <relocation>
+                  <pattern>relocated</pattern>
+                  <shadedPattern>hidden</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.1.1</version>
+        <executions>
+          <execution>
+            <id>run</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+            <configuration>
+              <executable>java</executable>
+              <arguments>
+                <argument>-classpath</argument>
+                <argument>${project.build.directory}/test-1.0.jar</argument>
+                <argument>Main</argument>
+              </arguments>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.3.1</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java?rev=882989&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java
(added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java
Sat Nov 21 20:45:33 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+@MyAnno( relocated.MyEnum.YES )
+public class Main
+{
+
+    public static void main( String[] args )
+        throws Exception
+    {
+        MyAnno anno = Main.class.getAnnotation( MyAnno.class );
+        System.out.println( "ANNO: " + anno.value() );
+        if ( !relocated.MyEnum.YES.equals( anno.value() ) )
+        {
+            throw new IllegalStateException( "unexpected value: " + anno.value() );
+        }
+    }
+
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/Main.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java?rev=882989&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java
(added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java
Sat Nov 21 20:45:33 2009
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+@java.lang.annotation.Retention( java.lang.annotation.RetentionPolicy.RUNTIME )
+public @interface MyAnno
+{
+
+    relocated.MyEnum value();
+
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/MyAnno.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java?rev=882989&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java
(added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java
Sat Nov 21 20:45:33 2009
@@ -0,0 +1,27 @@
+package relocated;
+
+/*
+ * 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.
+ */
+
+public enum MyEnum
+{
+
+    YES, NO
+
+}

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/reloc-enum-ref-from-anno/src/main/java/relocated/MyEnum.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java?rev=882989&r1=882988&r2=882989&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
(original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
Sat Nov 21 20:45:33 2009
@@ -337,17 +337,32 @@
         public String map( String name )
         {
             String value = name;
+
+            String prefix = "";
+            String suffix = "";
+
+            Matcher m = classPattern.matcher( name );
+            if ( m.matches() )
+            {
+                prefix = m.group( 1 ) + "L";
+                suffix = ";";
+                name = m.group( 2 );
+            }
+
             for ( Iterator i = relocators.iterator(); i.hasNext(); )
             {
                 Relocator r = (Relocator) i.next();
 
                 if ( r.canRelocatePath( name ) )
                 {
-                    value = r.relocatePath( name );
+                    value = prefix + r.relocatePath( name ) + suffix;
                     break;
                 }
             }
+
             return value;
         }
+
     }
+
 }



Mime
View raw message