Author: pgier
Date: Fri Mar 13 20:06:15 2009
New Revision: 753375

URL: http://svn.apache.org/viewvc?rev=753375&view=rev
Log:
[MSOURCES-13] Adding mojos that build source jars without causing a forked 
lifecycle.

Added:
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml   (with 
props)
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/
    
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java
   (with props)
    
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/resources/
    
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/resources/main.properties
   (with props)
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/
    
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java
   (with props)
    
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/resources/
    
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/resources/test.properties
   (with props)
    maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh   
(with props)
    maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/
    maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml   
(with props)
    maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/
    maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java
   (with props)
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/resources/
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/resources/main.properties
   (with props)
    maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java
   (with props)
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/resources/
    
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/resources/test.properties
   (with props)
    maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh  
 (with props)
    
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
   (with props)
    
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
   (with props)
Modified:
    maven/plugins/trunk/maven-source-plugin/src/site/apt/index.apt
    maven/plugins/trunk/maven-source-plugin/src/site/apt/usage.apt

Added: maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml?rev=753375&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml (added)
+++ maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml Fri Mar 
13 20:06:15 2009
@@ -0,0 +1,54 @@
+<?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>test</groupId>
+  <artifactId>jar</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Test for jar-no-fork</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>@pom.version@</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar-no-fork</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java?rev=753375&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java
 (added)
+++ 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java
 Fri Mar 13 20:06:15 2009
@@ -0,0 +1,4 @@
+public class MyClass
+{
+
+}

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/java/MyClass.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/resources/main.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/resources/main.properties?rev=753375&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/resources/main.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/main/resources/main.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java?rev=753375&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java
 (added)
+++ 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java
 Fri Mar 13 20:06:15 2009
@@ -0,0 +1,4 @@
+public class MyTest
+{
+
+}

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/java/MyTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/resources/test.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/resources/test.properties?rev=753375&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/resources/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/src/test/resources/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh?rev=753375&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh 
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh Fri 
Mar 13 20:06:15 2009
@@ -0,0 +1,53 @@
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+try
+{
+    File jarFile = new File( basedir, "target/jar-1.0-SNAPSHOT-sources.jar" );
+    System.out.println( "Checking for existence of " + jarFile );
+    if ( !jarFile.isFile() )
+    {
+        System.out.println( "FAILURE!" );
+        return false;
+    }
+
+    JarFile jar = new JarFile( jarFile );
+
+    String[] includedEntries = {
+        "META-INF/MANIFEST.MF",
+        "MyClass.java",
+        "main.properties",
+    };
+    for ( String included : includedEntries )
+    {
+        System.out.println( "Checking for existence of " + included );
+        if ( jar.getEntry( included ) == null )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+
+    String[] excludedEntries = {
+        "MyTest.java",
+        "test.properties",
+    };
+    for ( String excluded : excludedEntries )
+    {
+        System.out.println( "Checking for absence of " + excluded );
+        if ( jar.getEntry( excluded ) != null )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/jar-no-fork/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml?rev=753375&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml 
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml Fri 
Mar 13 20:06:15 2009
@@ -0,0 +1,54 @@
+<?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>test</groupId>
+  <artifactId>test-jar</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Test for test-jar-no-fork</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>@pom.version@</version>
+        <executions>
+          <execution>
+            <id>attach-test-sources</id>
+            <goals>
+              <goal>test-jar-no-fork</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java?rev=753375&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java
 (added)
+++ 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java
 Fri Mar 13 20:06:15 2009
@@ -0,0 +1,4 @@
+public class MyClass
+{
+
+}

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/java/MyClass.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/resources/main.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/resources/main.properties?rev=753375&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/resources/main.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/main/resources/main.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java?rev=753375&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java
 (added)
+++ 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java
 Fri Mar 13 20:06:15 2009
@@ -0,0 +1,4 @@
+public class MyTest
+{
+
+}

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/java/MyTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/resources/test.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/resources/test.properties?rev=753375&view=auto
==============================================================================
    (empty)

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/resources/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/src/test/resources/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh?rev=753375&view=auto
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh 
(added)
+++ maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh 
Fri Mar 13 20:06:15 2009
@@ -0,0 +1,53 @@
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+try
+{
+    File jarFile = new File( basedir, 
"target/test-jar-1.0-SNAPSHOT-test-sources.jar" );
+    System.out.println( "Checking for existence of " + jarFile );
+    if ( !jarFile.isFile() )
+    {
+        System.out.println( "FAILURE!" );
+        return false;
+    }
+
+    JarFile jar = new JarFile( jarFile );
+
+    String[] includedEntries = {
+        "META-INF/MANIFEST.MF",
+        "MyTest.java",
+        "test.properties",
+    };
+    for ( String included : includedEntries )
+    {
+        System.out.println( "Checking for existence of " + included );
+        if ( jar.getEntry( included ) == null )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+
+    String[] excludedEntries = {
+        "MyClass.java",
+        "main.properties",
+    };
+    for ( String excluded : excludedEntries )
+    {
+        System.out.println( "Checking for absence of " + excluded );
+        if ( jar.getEntry( excluded ) != null )
+        {
+            System.out.println( "FAILURE!" );
+            return false;
+        }
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/it/test-jar-no-fork/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java?rev=753375&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
 (added)
+++ 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
 Fri Mar 13 20:06:15 2009
@@ -0,0 +1,63 @@
+package org.apache.maven.plugin.source;
+
+/*
+ * 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 org.apache.maven.project.MavenProject;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This goal bundles all the sources into a jar archive.  This goal functions 
the same
+ * as the jar goal but does not fork the build and is suitable for attaching 
+ * to the build lifecycle.
+ *
+ * @author pgier
+ * @version $Id$
+ * @goal jar-no-fork
+ * @phase package
+ * @since 2.1
+ */
+public class SourceJarNoForkMojo
+    extends AbstractSourceJarMojo
+{
+    /** {...@inheritdoc} */
+    protected List getSources( MavenProject p )
+    {
+        return p.getCompileSourceRoots();
+    }
+
+    /** {...@inheritdoc} */
+    protected List getResources( MavenProject p )
+    {
+        if ( excludeResources )
+        {
+            return Collections.EMPTY_LIST;
+        }
+
+        return p.getResources();
+    }
+
+    /** {...@inheritdoc} */
+    protected String getClassifier()
+    {
+        return "sources";
+    }
+}

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java?rev=753375&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
 (added)
+++ 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
 Fri Mar 13 20:06:15 2009
@@ -0,0 +1,61 @@
+package org.apache.maven.plugin.source;
+
+/*
+ * 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 org.apache.maven.project.MavenProject;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This goal bundles all the test sources into a jar archive.  This goal 
functions the same
+ * as the test-jar goal but does not fork the build, and is suitable for 
attaching 
+ * to the build lifecycle.
+ *
+ * @goal test-jar-no-fork
+ * @phase package
+ * @since 2.1
+ */
+public class TestSourceJarNoForkMojo
+    extends AbstractSourceJarMojo
+{
+    /** {...@inheritdoc} */
+    protected List getSources( MavenProject p )
+    {
+        return p.getTestCompileSourceRoots();
+    }
+
+    /** {...@inheritdoc} */
+    protected List getResources( MavenProject p )
+    {
+        if ( excludeResources )
+        {
+            return Collections.EMPTY_LIST;
+        }
+
+        return p.getTestResources();
+    }
+
+    /** {...@inheritdoc} */
+    protected String getClassifier()
+    {
+        return "test-sources";
+    }
+}

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-source-plugin/src/site/apt/index.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/site/apt/index.apt?rev=753375&r1=753374&r2=753375&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-source-plugin/src/site/apt/index.apt Fri Mar 13 
20:06:15 2009
@@ -14,7 +14,7 @@
 
 * Goals Overview
 
-   The Source Plugin has three goals:
+   The Source Plugin has five goals:
 
    * {{{aggregate-mojo.html}source:aggregate}} aggregrates sources for all 
modules in an aggregator project.
 
@@ -23,6 +23,10 @@
    * {{{test-jar-mojo.html}source:test-jar}} on the other hand, is used to 
bundle the test sources of the project into a
      jar archive.
 
+   * {{{jar-no-fork-mojo.html}source:jar-no-fork}} is similar to <<jar>> but 
does not fork the build lifecycle.
+
+   * {{{test-jar-no-fork-mojo.html}source:test-jar-no-fork}} is similar to 
<<test-jar>> but does not fork the build lifecycle.
+
 * Usage
 
   General instructions on how to use the Source Plugin can be found on the 
{{{usage.html}usage page}}. Some more

Modified: maven/plugins/trunk/maven-source-plugin/src/site/apt/usage.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/site/apt/usage.apt?rev=753375&r1=753374&r2=753375&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-source-plugin/src/site/apt/usage.apt Fri Mar 13 
20:06:15 2009
@@ -8,7 +8,8 @@
 
 Usage
 
- The source plugin can be used to create a jar file of the project sources by 
executing the following command:
+ The source plugin can be used to create a jar file of the project sources 
from the command line or by binding
+ the goal to the project's build lifecycle.  To generate the jar from the 
command line, use the following command:
 
 +-----+
 mvn source:jar
@@ -23,7 +24,9 @@
 *Installing the sources along with your artifact
 
   There are two ways to do this. You can either bind this plugin to a phase or
-  you can add it to a profile.
+  you can add it to a profile.  The goals 
{{{jar-no-fork-mojo.html}source:jar-no-fork}} and 
+  {{{test-jar-no-fork-mojo.html}source:test-jar-no-fork}} are preferred for 
binding 
+  the goal to the build lifecycle.
 
 **Installing the sources using a phase binding
 
@@ -43,7 +46,7 @@
             <id>attach-sources</id>
             <phase>verify</phase>
             <goals>
-              <goal>jar</goal>
+              <goal>jar-no-fork</goal>
             </goals>
           </execution>
         </executions>
@@ -78,7 +81,7 @@
               <execution>
                 <id>attach-sources</id>
                 <goals>
-                  <goal>jar</goal>
+                  <goal>jar-no-fork</goal>
                 </goals>
               </execution>
             </executions>


Reply via email to