Author: krosenvold
Date: Mon Nov 10 18:40:34 2014
New Revision: 1637956

URL: http://svn.apache.org/r1637956
Log:
[MASSEMBLY-730]Fix and  Testcase

Added:
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/pom.xml
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/assembly/
    
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/assembly/JarWithDependenciesTest.java
Modified:
    maven/plugins/trunk/maven-assembly-plugin/pom.xml

Modified: maven/plugins/trunk/maven-assembly-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/pom.xml?rev=1637956&r1=1637955&r2=1637956&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/pom.xml Mon Nov 10 18:40:34 2014
@@ -156,7 +156,7 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-io</artifactId>
-      <version>2.3.3</version>
+      <version>2.3.4</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/pom.xml?rev=1637956&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/pom.xml
 Mon Nov 10 18:40:34 2014
@@ -0,0 +1,130 @@
+<!--
+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>
+
+       <groupId>fr.husta.test</groupId>
+       <artifactId>issue-mvn-assembly-plugin-730</artifactId>
+       <version>0.0.1-SNAPSHOT</version>
+
+       <prerequisites>
+               <maven>3.0</maven>
+       </prerequisites>
+
+       <properties>
+               
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+       </properties>
+
+       <build>
+               <finalName>${project.artifactId}</finalName>
+
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.1</version>
+                               <configuration>
+                                       <!-- 
http://maven.apache.org/plugins/maven-compiler-plugin/ -->
+                                       <source>1.6</source>
+                                       <target>1.6</target>
+                               </configuration>
+                       </plugin>
+
+                       <plugin>
+                               <artifactId>maven-jar-plugin</artifactId>
+                               <version>2.5</version>
+                       </plugin>
+
+                       <plugin>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <version>${testVersion}</version>
+                               <!-- <version>2.4.1</version> -->
+                               <configuration>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <id>test-pkg</id>
+                                               <phase>package</phase>
+                                               <goals>
+                                                       <goal>single</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <descriptorRefs>
+                                                               
<descriptorRef>jar-with-dependencies</descriptorRef>
+                                                       </descriptorRefs>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <version>2.18</version>
+                               <configuration>
+                                       <skip>true</skip>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               
<id>unit-tests-after-packaging</id>
+                                               <phase>package</phase>
+                                               <goals>
+                                                       <goal>test</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <skip>false</skip>
+                                                       <includes>
+                                                               
<include>**/*Test.java</include>
+                                                       </includes>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+               </plugins>
+       </build>
+
+       <dependencies>
+
+               <!-- PostgreSQL JDBC 4.0 Driver -->
+               <dependency>
+                       <groupId>org.postgresql</groupId>
+                       <artifactId>postgresql</artifactId>
+                       <version>9.3-1102-jdbc4</version>
+               </dependency>
+
+               <!-- Tests -->
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.11</version>
+                       <scope>test</scope>
+               </dependency>
+
+               <dependency>
+                       <groupId>commons-io</groupId>
+                       <artifactId>commons-io</artifactId>
+                       <version>2.4</version>
+                       <scope>test</scope>
+               </dependency>
+
+       </dependencies>
+
+</project>

Added: 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/assembly/JarWithDependenciesTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/assembly/JarWithDependenciesTest.java?rev=1637956&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/assembly/JarWithDependenciesTest.java
 (added)
+++ 
maven/plugins/trunk/maven-assembly-plugin/src/it/projects/bugs/massembly-730/src/test/java/fr/husta/test/assembly/JarWithDependenciesTest.java
 Mon Nov 10 18:40:34 2014
@@ -0,0 +1,57 @@
+package fr.husta.test.assembly;
+/*
+ * 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 static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+
+public class JarWithDependenciesTest
+{
+
+    @Test
+    public void checkMetaInfContent() throws IOException
+    {
+        // check META-INF/services/java.sql.Driver exists
+        JarFile jar = new 
JarFile("target/issue-mvn-assembly-plugin-730-jar-with-dependencies.jar");
+        JarEntry entry = jar.getJarEntry("META-INF/services/java.sql.Driver");
+        if (entry == null)
+        {
+            fail("the file 'META-INF/services/java.sql.Driver' should exist in 
jar-with-dependencies");
+        }
+
+        // Content should be "org.postgresql.Driver"
+        InputStream is = jar.getInputStream(entry);
+        String content = IOUtils.toString(is, "UTF-8");
+        System.out.println("JDBC Driver found : " + content.substring(0, 
content.indexOf("\n")));
+        assertEquals("org.postgresql.Driver", content.substring(0, 
content.indexOf("\n")));
+
+        // if test fails and content == "sun.jdbc.odbc.JdbcOdbcDriver",
+        // it means it comes from 
jre/lib/resources.jar!/META-INF/services/java.sql.Driver (which is unwanted)
+
+    }
+
+}


Reply via email to