Author: olamy
Date: Wed Jan  2 14:48:58 2008
New Revision: 608274

URL: http://svn.apache.org/viewvc?rev=608274&view=rev
Log:
[MJAR-82] Class-Path manifest entry should support maven repository layout
add an it for this feature

Added:
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/
      - copied from r608250, 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-60/
Modified:
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/pom.xml
    
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/src/main/java/myproject/HelloWorld.java
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/verify.bsh

Modified: maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/pom.xml?rev=608274&r1=608250&r2=608274&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/pom.xml (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/pom.xml Wed Jan  2 
14:48:58 2008
@@ -20,8 +20,8 @@
 <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.plugins</groupId>
-  <artifactId>MJAR-60</artifactId>
-  <name>MJAR-60</name>
+  <artifactId>MJAR-82</artifactId>
+  <name>MJAR-82</name>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
 
@@ -36,14 +36,34 @@
             <manifest>
               <mainClass>myproject.HelloWorld</mainClass>
               <addClasspath>true</addClasspath>
-              <classpathPrefix>lib</classpathPrefix>
+              
<classpathMavenRepositoryLayout>true</classpathMavenRepositoryLayout>
+              <!--<classpathPrefix></classpathPrefix>-->
             </manifest>
-            <manifestEntries>
-              <Class-Path>config/</Class-Path>
-            </manifestEntries>
           </archive>
         </configuration>
       </plugin>
     </plugins>
   </build>
+  <dependencies>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.3</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>1.4.3</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-component-api</artifactId>   
+      <version>1.0-alpha-15</version>   
+    </dependency>     
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>   
+      <version>1.0-alpha-15</version>   
+    </dependency>   
+  </dependencies>
 </project>

Modified: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/src/main/java/myproject/HelloWorld.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/src/main/java/myproject/HelloWorld.java?rev=608274&r1=608250&r2=608274&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/src/main/java/myproject/HelloWorld.java
 (original)
+++ 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/src/main/java/myproject/HelloWorld.java
 Wed Jan  2 14:48:58 2008
@@ -1,5 +1,10 @@
 package myproject;
 
+import org.apache.commons.lang.*;
+import org.codehaus.plexus.context.*;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.*;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -31,6 +36,14 @@
      */
     public static void main( String[] args )
     {
-        System.out.println( "Hi!" );
+        String empty = null;
+        Context context = new DefaultContext();
+        ConsoleLogger consoleLogger = new ConsoleLogger( Logger.LEVEL_INFO, 
"console" );
+        consoleLogger.info( "great it works" );
+        if (StringUtils.isEmpty( empty ))
+        {
+            System.exit( 0 );
+        }
+        System.exit( 1 );
     } 
 }

Modified: maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/verify.bsh?rev=608274&r1=608250&r2=608274&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/verify.bsh (original)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-82/verify.bsh Wed Jan  2 
14:48:58 2008
@@ -22,6 +22,7 @@
 import java.util.*;
 import java.util.jar.*;
 import org.codehaus.plexus.util.*;
+import org.codehaus.plexus.util.cli.*;
 
 boolean result = true;
 
@@ -34,38 +35,34 @@
         return false;
     }
     
-    File artifact = new File ( target, "MJAR-60-1.0-SNAPSHOT.jar" );
+    File artifact = new File ( target, "MJAR-82-1.0-SNAPSHOT.jar" );
     if ( !artifact.exists() || artifact.isDirectory() )
     {
         System.err.println( "artifact file is missing or a directory." );
         return false;
     }    
+        
+    String localRepoPath = 
basedir.getParentFile().getParentFile().getParentFile().getPath() + 
"/target/local-repo";
+    Commandline commandline = new Commandline();
+    commandline.setExecutable( "java" );
+    commandline.setWorkingDirectory( localRepoPath );
+    commandline.createArg().setLine( "-jar MJAR-82-1.0-SNAPSHOT.jar" );     
+    CommandLineUtils.StringStreamConsumer consumer = new 
CommandLineUtils.StringStreamConsumer();
+    int res = CommandLineUtils.executeCommandLine( commandline, consumer, 
consumer );
+    String output = consumer.getOutput();
+    System.out.println( "res " + res );
+    System.out.println( output );
+    if ( res != 0 )
+    {
+        System.err.println( "commandline execution return code != 0 " + res );
+        return false;          
+    }    
     
-    JarFile jar = new JarFile( artifact );
-    Enumeration jarEntries = jar.entries();
-    while ( jarEntries.hasMoreElements() )
+    if ( output.indexOf("great it works") < 0 )
     {
-        JarEntry entry = (JarEntry) jarEntries.nextElement();
-        if ( !entry.isDirectory() )
-        {
-            // Only compare files
-            if ( entry.getName().equals ("META-INF/MANIFEST.MF") )
-            {
-               String manifest = IOUtil.toString ( jar.getInputStream ( entry 
) );
-               int index = manifest.indexOf ( "Class-Path: config/" );
-               if ( index <= 0 )
-               {       
-                       System.err.println ( "MANIFEST doens t contains : 
Class-Path: config/" );
-                       return false; 
-               }
-               return true;
-            }
-        }
+        System.err.println( "output not contains great it works" );
+        return false;          
     }
-       System.err.println ( "MANIFEST.MF not found" );
-       return false;
-        
-    
 }
 catch( Throwable e )
 {


Reply via email to