Author: nicolas
Date: Sat Dec 15 09:27:08 2007
New Revision: 604458

URL: http://svn.apache.org/viewvc?rev=604458&view=rev
Log:
MJAR-90 : when maven runs with maven.test.skip=true, the installed test-jar is 
empty.
 + Add a skip parameter
 + override execute to skip the test-jar packaging
 + it test

Added:
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/   (with props)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/pom.xml
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/java/
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/java/Foo.java
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/java/
    
maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/java/FooTest.java
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/verify.bsh
Modified:
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-60/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-30-01/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-30-02/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-30-03/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-71-01/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-71-02/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-80-01/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-80-02/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/mjar-80-03/   (props changed)
    maven/plugins/trunk/maven-jar-plugin/src/it/project-004/   (props changed)
    
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-60/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-30-01/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-30-02/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-30-03/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-71-01/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-71-02/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-80-01/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-80-02/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-80-03/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Added: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/pom.xml?rev=604458&view=auto
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/pom.xml (added)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/pom.xml Sat Dec 15 
09:27:08 2007
@@ -0,0 +1,63 @@
+<?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.plugins</groupId>
+  <artifactId>maven-jar-plugin-test-mjar-90</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>jar</packaging>
+  <description>Test skip.</description>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>@pom.version@</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <skip>true</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.3</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/java/Foo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/java/Foo.java?rev=604458&view=auto
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/java/Foo.java 
(added)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/main/java/Foo.java 
Sat Dec 15 09:27:08 2007
@@ -0,0 +1,31 @@
+
+/*
+ * 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.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class Foo
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}

Added: 
maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/java/FooTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/java/FooTest.java?rev=604458&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/java/FooTest.java 
(added)
+++ 
maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/src/test/java/FooTest.java 
Sat Dec 15 09:27:08 2007
@@ -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.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test
+ */
+public class FooTest 
+    extends TestCase
+{
+    public void testFoo()
+    {
+        assertTrue( true );
+    }
+}

Added: maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/verify.bsh?rev=604458&view=auto
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/verify.bsh (added)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/mjar-90/verify.bsh Sat Dec 15 
09:27:08 2007
@@ -0,0 +1,57 @@
+
+/*
+ * 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 java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File target = new File( basedir, "target" );
+    if ( !target.exists() || !target.isDirectory() )
+    {
+        System.err.println( "target file is missing or not a directory." );
+        return false;
+    }
+    
+    File artifact = new File ( target, 
"maven-jar-plugin-test-mjar-90-99.0.jar" );
+    if ( !artifact.exists() || artifact.isDirectory() )
+    {
+        System.err.println( "artifact file is missing or a directory." );
+        return false;
+    }     
+    
+    File testArtifact = new File ( target, 
"maven-jar-plugin-test-mjar-90-99.0-tests.jar" );
+    if ( testArtifact.exists() )
+    {
+        System.err.println( "testArtifact file has been created with 
maven.Test.skip=true." );
+        return false;
+    }    
+}
+catch( Throwable e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+return result;

Propchange: maven/plugins/trunk/maven-jar-plugin/src/it/project-004/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 15 09:27:08 2007
@@ -0,0 +1,2 @@
+build.log
+target

Modified: 
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java?rev=604458&r1=604457&r2=604458&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
 Sat Dec 15 09:27:08 2007
@@ -20,6 +20,7 @@
  */
 
 import java.io.File;
+import org.apache.maven.plugin.MojoExecutionException;
 
 /**
  * Build a JAR of the test classes for the current project.
@@ -34,6 +35,15 @@
 public class TestJarMojo
     extends AbstractJarMojo
 {
+
+    /**
+     * Set this to 'true' to bypass unit tests entirely.
+     * Its use is NOT RECOMMENDED, but quite convenient on occasion.
+     *
+     * @parameter expression="${maven.test.skip}"
+     */
+    private boolean skip;
+
     /**
      * Directory containing the test classes.
      *
@@ -61,5 +71,18 @@
     protected File getClassesDirectory()
     {
         return testClassesDirectory;
+    }
+       
+       public void execute()
+        throws MojoExecutionException
+    {
+        if ( skip )
+        {
+            getLog().info( "Skipping packaging of the test-jar" );
+        }
+        else
+        {
+            super.execute();
+        }
     }
 }


Reply via email to