Moving out of the sandbox for release.

git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@555659 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d5ae90f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,189 @@
+<!--
+    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>
+  <parent>
+    <groupId>org.apache.maven.plugins</groupId>
+    <artifactId>maven-plugins</artifactId>
+    <version>8</version>
+  </parent>
+  
+  <artifactId>maven-patch-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>maven-patch-plugin Maven Mojo</name>
+  <url>http://maven.apache.org</url>
+ 
+  <scm>
+     <connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-patch-plugin</connection>
+     <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-patch-plugin</developerConnection>
+     <url>http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-patch-plugin</url>
+  </scm>
+
+  <dependencies> 
+  
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.1</version>
+    </dependency>
+ 
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-release-plugin</artifactId>
+          <version>2.0-beta-4</version>
+          <configuration>
+            <!-- TODO: Change this when the plugin graduates into /plugins! -->
+            <tagBase>https://svn.apache.org/repos/asf/maven/sandbox/tags</tagBase>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>integration-tests</id>
+      <activation>
+        <property>
+          <name>integration-tests</name>
+          <value>true</value>
+        </property>
+      </activation>
+
+      <properties>
+        <test.remote.repo.url>file://${project.build.testOutputDirectory}/remote-repository</test.remote.repo.url>
+      </properties>
+  
+      <build>
+        <testResources>
+          <testResource>
+            <directory>src/it/projects</directory>
+            <targetPath>projects</targetPath>
+          </testResource>
+          <testResource>
+            <directory>src/it/it-project-parent</directory>
+            <targetPath>it-project-parent</targetPath>
+            <filtering>true</filtering>
+          </testResource>
+          <testResource>
+            <directory>src/it/remote-repository</directory>
+            <targetPath>remote-repository</targetPath>
+          </testResource>
+        </testResources>
+        <plugins>
+          <plugin>
+            <artifactId>maven-clean-plugin</artifactId>
+            <configuration>
+              <filesets>
+                <fileset>
+                  <directory>src/it</directory>
+                  <includes>
+                    <include>**/build.log</include>
+                  </includes>
+                  <excludes>
+                    <exclude>**/autoskip/skip-when-patch-tracking-file-present/target/**</exclude>
+                  </excludes>
+                </fileset>
+              </filesets>
+            </configuration>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-component-it-plugin</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <executions>
+              <execution>
+                <id>stage-plugin</id>
+                <goals>
+                  <goal>stage</goal>
+                </goals>
+                <configuration>
+                  <pluginVersion>testing</pluginVersion>
+                  <repositoryDirectory>${project.build.directory}/local-repository</repositoryDirectory>
+                  <skipUnitTests>true</skipUnitTests>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-invoker-plugin</artifactId>
+            <version>1.1-SNAPSHOT</version>
+            <executions>
+              <execution>
+                <id>setup-integration-test-parent</id>
+                <phase>pre-integration-test</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <suppressSummaries>true</suppressSummaries>
+                  <goals>
+                    <goal>install</goal>
+                  </goals>
+                  <localRepositoryPath>${project.build.directory}/local-repository</localRepositoryPath>
+                  <pom>${project.build.testOutputDirectory}/it-project-parent/pom.xml</pom>
+                  <streamLogs>true</streamLogs>
+                </configuration>
+              </execution>
+              <execution>
+                <id>integration-test</id>
+                <phase>integration-test</phase>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+                <configuration>
+                  <debug>true</debug>
+                  <projectsDirectory>${project.build.testOutputDirectory}/projects</projectsDirectory>
+                  <pomIncludes>
+                    <pomInclude>**/pom.xml</pomInclude>
+                  </pomIncludes>
+                  <pomExcludes>
+                    <pomExclude>**/child*/pom.xml</pomExclude>
+                    <pomExclude>**/module*/pom.xml</pomExclude>
+                  </pomExcludes>
+                  <postBuildHookScript>verify.bsh</postBuildHookScript>
+                  <localRepositoryPath>${project.build.directory}/local-repository</localRepositoryPath>
+                </configuration>
+              </execution>
+           </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+  
+</project>
\ No newline at end of file
diff --git a/src/it/it-project-parent/pom.xml b/src/it/it-project-parent/pom.xml
new file mode 100644
index 0000000..a9fd69b
--- /dev/null
+++ b/src/it/it-project-parent/pom.xml
@@ -0,0 +1,55 @@
+<!--
+    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.codehaus.mojo.patch.it</groupId>
+  <artifactId>it-project-parent</artifactId>
+  <packaging>pom</packaging>
+  <version>1</version>
+  <name>it-project-parent</name>
+
+  <repositories>
+    <repository>
+      <id>integration.test.repo</id>
+      <url>${test.remote.repo.url}</url>
+    </repository>
+  </repositories>
+
+  <distributionManagement>
+    <repository>
+      <id>integration.test.repo</id>
+      <url>${test.remote.repo.url}</url>
+    </repository>
+  </distributionManagement>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>patch-maven-plugin</artifactId>
+        <version>testing</version>
+
+        <configuration>
+          <patchingEnabled>true</patchingEnabled>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/apply/apply-single-patch/goals.txt b/src/it/projects/apply/apply-single-patch/goals.txt
new file mode 100644
index 0000000..781cecf
--- /dev/null
+++ b/src/it/projects/apply/apply-single-patch/goals.txt
@@ -0,0 +1 @@
+clean initialize
\ No newline at end of file
diff --git a/src/it/projects/apply/apply-single-patch/pom.xml b/src/it/projects/apply/apply-single-patch/pom.xml
new file mode 100644
index 0000000..d186070
--- /dev/null
+++ b/src/it/projects/apply/apply-single-patch/pom.xml
@@ -0,0 +1,77 @@
+<!--
+    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>
+  
+  <parent>
+    <groupId>org.codehaus.mojo.patch.it</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <artifactId>apply-single-patch</artifactId>
+  <name>apply-single-patch</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>patch-maven-plugin</artifactId>
+        
+        <configuration>
+          <skipResolve>true</skipResolve>
+          <targetDirectory>${basedir}</targetDirectory>
+          <patches>
+            <patch>first.patch</patch>
+          </patches>
+        </configuration>
+
+        <executions>
+          <execution>
+            <id>resolve-patches</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>resolve-patches</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>apply-patches</id>
+            
+            <!--  putting it ahead of generate-sources, since this should patch any model files, etc. -->
+            <phase>initialize</phase>
+            
+            <goals>
+              <goal>apply</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/apply/apply-single-patch/src/main/java/org/apache/maven/shared/App.java b/src/it/projects/apply/apply-single-patch/src/main/java/org/apache/maven/shared/App.java
new file mode 100644
index 0000000..dbbc84c
--- /dev/null
+++ b/src/it/projects/apply/apply-single-patch/src/main/java/org/apache/maven/shared/App.java
@@ -0,0 +1,32 @@
+package org.apache.maven.shared;
+
+/*
+    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 App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/src/it/projects/apply/apply-single-patch/src/patches/first.patch b/src/it/projects/apply/apply-single-patch/src/patches/first.patch
new file mode 100644
index 0000000..5c6f211
--- /dev/null
+++ b/src/it/projects/apply/apply-single-patch/src/patches/first.patch
@@ -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.
+#
+Index: target/test.txt
+===================================================================
+--- target/test.txt	(revision 0)
++++ target/test.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+\ No newline at end of file
+
diff --git a/src/it/projects/apply/apply-single-patch/src/test/java/org/apache/maven/shared/AppTest.java b/src/it/projects/apply/apply-single-patch/src/test/java/org/apache/maven/shared/AppTest.java
new file mode 100644
index 0000000..9acff71
--- /dev/null
+++ b/src/it/projects/apply/apply-single-patch/src/test/java/org/apache/maven/shared/AppTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.shared;
+
+/*
+    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 for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}
diff --git a/src/it/projects/apply/apply-single-patch/verify.bsh b/src/it/projects/apply/apply-single-patch/verify.bsh
new file mode 100644
index 0000000..ab21419
--- /dev/null
+++ b/src/it/projects/apply/apply-single-patch/verify.bsh
@@ -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.
+*/
+
+import java.io.*;
+
+File testFile = new File( basedir, "target/test.txt" );
+
+System.out.println( "Does " + testFile + " exist? " + testFile.exists() );
+
+return testFile.exists();
diff --git a/src/it/projects/apply/apply-two-patches-in-order/goals.txt b/src/it/projects/apply/apply-two-patches-in-order/goals.txt
new file mode 100644
index 0000000..781cecf
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/goals.txt
@@ -0,0 +1 @@
+clean initialize
\ No newline at end of file
diff --git a/src/it/projects/apply/apply-two-patches-in-order/pom.xml b/src/it/projects/apply/apply-two-patches-in-order/pom.xml
new file mode 100644
index 0000000..d3aff8e
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/pom.xml
@@ -0,0 +1,81 @@
+<!--
+    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>
+  
+  <parent>
+    <groupId>org.codehaus.mojo.patch.it</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <artifactId>apply-two-patches-in-order</artifactId>
+  <name>apply-two-patches-in-order</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>patch-maven-plugin</artifactId>
+        
+        <configuration>
+          <skipResolve>true</skipResolve>
+          <targetDirectory>${basedir}</targetDirectory>
+          <patches>
+            <patch>first.patch</patch>
+            <patch>second.patch</patch>
+          </patches>
+        </configuration>
+
+        <executions>
+          <execution>
+            <id>resolve-patches</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>resolve-patches</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>apply-patches</id>
+            
+            <!--  putting it ahead of generate-sources, since this should patch any model files, etc. -->
+            <phase>initialize</phase>
+            
+            <goals>
+              <goal>apply</goal>
+            </goals>
+            
+            <configuration>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/apply/apply-two-patches-in-order/src/main/java/org/apache/maven/shared/App.java b/src/it/projects/apply/apply-two-patches-in-order/src/main/java/org/apache/maven/shared/App.java
new file mode 100644
index 0000000..dbbc84c
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/src/main/java/org/apache/maven/shared/App.java
@@ -0,0 +1,32 @@
+package org.apache.maven.shared;
+
+/*
+    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 App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/src/it/projects/apply/apply-two-patches-in-order/src/patches/first.patch b/src/it/projects/apply/apply-two-patches-in-order/src/patches/first.patch
new file mode 100644
index 0000000..5c6f211
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/src/patches/first.patch
@@ -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.
+#
+Index: target/test.txt
+===================================================================
+--- target/test.txt	(revision 0)
++++ target/test.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+\ No newline at end of file
+
diff --git a/src/it/projects/apply/apply-two-patches-in-order/src/patches/second.patch b/src/it/projects/apply/apply-two-patches-in-order/src/patches/second.patch
new file mode 100644
index 0000000..a543692
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/src/patches/second.patch
@@ -0,0 +1,24 @@
+#
+#  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.
+#
+--- target/test.txt	2006-12-20 15:31:03.000000000 -0500
++++ target/test.txt	2006-12-20 15:32:33.000000000 -0500
+@@ -1 +1 @@
+-This is a test.
+\ No newline at end of file
++This is another test.
diff --git a/src/it/projects/apply/apply-two-patches-in-order/src/test/java/org/apache/maven/shared/AppTest.java b/src/it/projects/apply/apply-two-patches-in-order/src/test/java/org/apache/maven/shared/AppTest.java
new file mode 100644
index 0000000..9acff71
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/src/test/java/org/apache/maven/shared/AppTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.shared;
+
+/*
+    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 for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}
diff --git a/src/it/projects/apply/apply-two-patches-in-order/verify.bsh b/src/it/projects/apply/apply-two-patches-in-order/verify.bsh
new file mode 100644
index 0000000..ab21419
--- /dev/null
+++ b/src/it/projects/apply/apply-two-patches-in-order/verify.bsh
@@ -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.
+*/
+
+import java.io.*;
+
+File testFile = new File( basedir, "target/test.txt" );
+
+System.out.println( "Does " + testFile + " exist? " + testFile.exists() );
+
+return testFile.exists();
diff --git a/src/it/projects/autoskip/skip-when-patch-enum-missing/goals.txt b/src/it/projects/autoskip/skip-when-patch-enum-missing/goals.txt
new file mode 100644
index 0000000..781cecf
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-enum-missing/goals.txt
@@ -0,0 +1 @@
+clean initialize
\ No newline at end of file
diff --git a/src/it/projects/autoskip/skip-when-patch-enum-missing/pom.xml b/src/it/projects/autoskip/skip-when-patch-enum-missing/pom.xml
new file mode 100644
index 0000000..b45b872
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-enum-missing/pom.xml
@@ -0,0 +1,74 @@
+<!--
+    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>
+  
+  <parent>
+    <groupId>org.codehaus.mojo.patch.it</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <artifactId>apply-single-patch</artifactId>
+  <name>apply-single-patch</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>patch-maven-plugin</artifactId>
+        
+        <configuration>
+          <skipResolve>true</skipResolve>
+          <targetDirectory>${basedir}</targetDirectory>
+        </configuration>
+
+        <executions>
+          <execution>
+            <id>resolve-patches</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>resolve-patches</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>apply-patches</id>
+            
+            <!--  putting it ahead of generate-sources, since this should patch any model files, etc. -->
+            <phase>initialize</phase>
+            
+            <goals>
+              <goal>apply</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/autoskip/skip-when-patch-enum-missing/src/main/java/org/apache/maven/shared/App.java b/src/it/projects/autoskip/skip-when-patch-enum-missing/src/main/java/org/apache/maven/shared/App.java
new file mode 100644
index 0000000..dbbc84c
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-enum-missing/src/main/java/org/apache/maven/shared/App.java
@@ -0,0 +1,32 @@
+package org.apache.maven.shared;
+
+/*
+    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 App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/src/it/projects/autoskip/skip-when-patch-enum-missing/src/patches/first.patch b/src/it/projects/autoskip/skip-when-patch-enum-missing/src/patches/first.patch
new file mode 100644
index 0000000..5c6f211
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-enum-missing/src/patches/first.patch
@@ -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.
+#
+Index: target/test.txt
+===================================================================
+--- target/test.txt	(revision 0)
++++ target/test.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+\ No newline at end of file
+
diff --git a/src/it/projects/autoskip/skip-when-patch-enum-missing/src/test/java/org/apache/maven/shared/AppTest.java b/src/it/projects/autoskip/skip-when-patch-enum-missing/src/test/java/org/apache/maven/shared/AppTest.java
new file mode 100644
index 0000000..9acff71
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-enum-missing/src/test/java/org/apache/maven/shared/AppTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.shared;
+
+/*
+    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 for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}
diff --git a/src/it/projects/autoskip/skip-when-patch-enum-missing/verify.bsh b/src/it/projects/autoskip/skip-when-patch-enum-missing/verify.bsh
new file mode 100644
index 0000000..df81555
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-enum-missing/verify.bsh
@@ -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.
+*/
+
+import java.io.*;
+
+File testFile = new File( basedir, "target/test.txt" );
+
+System.out.println( "Does " + testFile + " exist? " + testFile.exists() );
+
+return !testFile.exists();
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/goals.txt b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/goals.txt
new file mode 100644
index 0000000..7f6ea1c
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/goals.txt
@@ -0,0 +1 @@
+initialize
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/pom.xml b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/pom.xml
new file mode 100644
index 0000000..8f35ea5
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/pom.xml
@@ -0,0 +1,70 @@
+<!--
+    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>
+  
+  <parent>
+    <groupId>org.codehaus.mojo.patch.it</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <artifactId>skip-when-patch-tracking-file-present</artifactId>
+  <name>skip-when-patch-tracking-file-present</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>patch-maven-plugin</artifactId>
+        
+        <configuration>
+          <skipResolve>true</skipResolve>
+          <patches>
+            <patch>first.patch</patch>
+            <patch>second.patch</patch>
+          </patches>
+        </configuration>
+
+        <executions>
+          <execution>
+            <id>apply-patches</id>
+            
+            <!--  putting it ahead of generate-sources, since this should patch any model files, etc. -->
+            <phase>initialize</phase>
+            
+            <goals>
+              <goal>apply</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/main/java/org/apache/maven/shared/App.java b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/main/java/org/apache/maven/shared/App.java
new file mode 100644
index 0000000..dbbc84c
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/main/java/org/apache/maven/shared/App.java
@@ -0,0 +1,32 @@
+package org.apache.maven.shared;
+
+/*
+    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 App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/patches/first.patch b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/patches/first.patch
new file mode 100644
index 0000000..5c6f211
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/patches/first.patch
@@ -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.
+#
+Index: target/test.txt
+===================================================================
+--- target/test.txt	(revision 0)
++++ target/test.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+\ No newline at end of file
+
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/patches/second.patch b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/patches/second.patch
new file mode 100644
index 0000000..d042bd5
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/patches/second.patch
@@ -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.
+#
+Index: target/test2.txt
+===================================================================
+--- target/test2.txt	(revision 0)
++++ target/test2.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+\ No newline at end of file
+
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/test/java/org/apache/maven/shared/AppTest.java b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/test/java/org/apache/maven/shared/AppTest.java
new file mode 100644
index 0000000..9acff71
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/src/test/java/org/apache/maven/shared/AppTest.java
@@ -0,0 +1,57 @@
+package org.apache.maven.shared;
+
+/*
+    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 for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}
diff --git a/src/it/projects/autoskip/skip-when-patch-tracking-file-present/verify.bsh b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/verify.bsh
new file mode 100644
index 0000000..10f29c3
--- /dev/null
+++ b/src/it/projects/autoskip/skip-when-patch-tracking-file-present/verify.bsh
@@ -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.
+*/
+
+import java.io.*;
+
+File testFile = new File( basedir, "target/test2.txt" );
+
+System.out.println( "Does " + testFile + " exist? " + testFile.exists() );
+
+return !testFile.exists();
diff --git a/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
new file mode 100644
index 0000000..9302b87
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
@@ -0,0 +1,593 @@
+package org.apache.maven.plugin.patch;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+//import org.codehaus.plexus.util.cli.shell.BourneShell;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * Apply one or more patches to project sources.
+ *
+ * @goal apply
+ * @phase process-sources
+ */
+public class ApplyMojo
+    extends AbstractMojo
+{
+
+    public static final List PATCH_FAILURE_WATCH_PHRASES;
+
+    public static final List DEFAULT_IGNORED_PATCHES;
+
+    public static final List DEFAULT_IGNORED_PATCH_PATTERNS;
+
+    static
+    {
+        List watches = new ArrayList();
+
+        watches.add( "fail" );
+        watches.add( "skip" );
+        watches.add( "reject" );
+
+        PATCH_FAILURE_WATCH_PHRASES = watches;
+
+        List ignored = new ArrayList();
+
+        ignored.add( ".svn" );
+        ignored.add( "CVS" );
+
+        DEFAULT_IGNORED_PATCHES = ignored;
+
+        List ignoredPatterns = new ArrayList();
+
+        ignoredPatterns.add( ".svn/**" );
+        ignoredPatterns.add( "CVS/**" );
+
+        DEFAULT_IGNORED_PATCH_PATTERNS = ignoredPatterns;
+    }
+
+    /**
+     * Whether to exclude default ignored patch items, such as .svn or CVS directories.
+     *
+     * @parameter default-value="true"
+     */
+    private boolean useDefaultIgnores;
+
+    /**
+     * The list of patch file names (without directory information), supplying the order in which patches should be
+     * applied. (relative to 'patchSourceDir')
+     *
+     * @parameter
+     */
+    protected List patches;
+
+    /**
+     * Whether to skip this mojo's execution.
+     *
+     * @parameter default-value="false" alias="patch.apply.skip"
+     */
+    private boolean skipApplication;
+
+    /**
+     * Flag to enable/disable optimization file from being written. This file tracks the patches that were applied the
+     * last time this mojo actually executed. It is required for cases where project-sources optimizations are enabled,
+     * since project-sources will not be re-unpacked if they are at least as fresh as the source archive. If we avoid
+     * re-unpacking project sources, we need to make sure we don't reapply patches. This flag is true by default. <br/>
+     * <b>NOTE:</b> If the list of patches changes and this flag is enabled, a `mvn clean` must be executed before the
+     * next build, to remove the tracking file.
+     *
+     * @parameter default-value="true"
+     */
+    private boolean optimizations;
+
+    /**
+     * This is the tracking file used to maintain a list of the patches applied to the unpacked project sources which
+     * are currently in the target directory. If this file is present, and project-source unpacking is optimized
+     * (meaning it won't re-unpack unless the project-sources archive is newer), this mojo will not execute and no
+     * patches will be applied in the current build.
+     *
+     * @parameter default-value="${project.build.directory}/optimization-files/patches-applied.txt"
+     */
+    private File patchTrackingFile;
+
+    /**
+     * The target directory for applying patches. Files in this directory will be modified.
+     *
+     * @parameter alias="patchTargetDir" default-value="${project.build.sourceDirectory}"
+     * @required
+     */
+    private File targetDirectory;
+
+    /**
+     * true if the desired behavior is to fail the build on the first failed patch detected
+     *
+     * @parameter default-value="true"
+     */
+    private boolean failFast;
+    
+    /**
+     * setting natural order processing to true will all patches in a directory to be processed in an natural order
+     * alleviating the need to declare patches directly in the project file.
+     *
+     * @parameter default-value="false"
+     */
+    private boolean naturalOrderProcessing;
+
+    /**
+     * When the strictPatching flag is set, this parameter is useful to mark certain contents of the patch-source
+     * directory that should be ignored without causing the build to fail.
+     *
+     * @parameter
+     */
+    private List ignoredPatches;
+
+    /**
+     * Flag that, when set to true, will make sure that all patches included in the 'patches' list must be present and
+     * describe the full contents of the patch directory. If strictPatching is set to true, and the patches list has a
+     * value that does not correspond to a file in the patch directory, the build will fail. If strictPatching is set to
+     * true, and the patch directory contains files not listed in the patches parameter, the build will fail. If set to
+     * false, only the patches listed in the patches parameter that have corresponding files will be applied; the rest
+     * will be ignored. Default value for this parameter is false.
+     *
+     * @parameter default-value="false"
+     * @required
+     */
+    private boolean strictPatching;
+
+    /**
+     * The number of directories to be stripped from patch file paths, before applying, starting from the leftmost, or
+     * root-est.
+     *
+     * @parameter
+     */
+    private int strip = 0;
+
+    /**
+     * Whether to ignore whitespaces when applying the patches.
+     *
+     * @parameter
+     */
+    private boolean ignoreWhitespace = true;
+
+    /**
+     * Whether to treat these patches as having reversed source and dest in the patch syntax.
+     *
+     * @parameter
+     */
+    private boolean reverse = false;
+
+    /**
+     * Whether to make backups of the original files before modding them.
+     *
+     * @parameter
+     */
+    private boolean backups = false;
+
+    /**
+     * List of phrases to watch for in patch-command output. If one is found, it will cause the build to fail. All
+     * phrases should be lower-case ONLY.
+     *
+     * @parameter
+     */
+    private List failurePhrases = PATCH_FAILURE_WATCH_PHRASES;
+
+    /**
+     * The original file which will be modified by the patch. Mutually exclusive with workDir.
+     *
+     * @parameter
+     */
+    private File originalFile;
+
+    /**
+     * The file which is the original file, plus modifications from the patch. Mutually exclusive with workDir.
+     *
+     * @parameter
+     */
+    private File destFile;
+
+    /**
+     * The single patch file to apply. Mutually exclusive with 'patches'.
+     *
+     * @parameter
+     */
+    private File patchFile;
+
+    /**
+     * @parameter default-value="src/main/patches"
+     * @required
+     */
+    private File patchDirectory;
+
+    /**
+     * Apply the patches. Give preference to patchFile over patchSourceDir/patches, and preference to originalFile over
+     * workDir.
+     */
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        boolean patchDirEnabled = ( ( patches != null ) && !patches.isEmpty() ) || naturalOrderProcessing;
+        boolean patchFileEnabled = patchFile != null;
+
+    	// if patches is null or empty, and naturalOrderProcessing is not true then disable patching
+    	if ( !patchFileEnabled && !patchDirEnabled )
+        {
+            getLog().info( "Patching is disabled for this project." );
+            return;
+        }
+
+        if ( skipApplication )
+        {
+            getLog().info( "Skipping patchfile application (per configuration)." );
+            return;
+        }
+
+        patchTrackingFile.getParentFile().mkdirs();
+
+        Map patchesToApply = null;
+
+        try
+        {
+            if ( patchFileEnabled )
+            {
+                patchesToApply = Collections.singletonMap( patchFile.getName(), createPatchCommand( patchFile ) );
+            }
+            else
+            {
+                List foundPatchFiles = FileUtils.getFileNames( patchDirectory, "*", null, false );
+
+                patchesToApply = findPatchesToApply(foundPatchFiles, patchDirectory );
+
+                checkStrictPatchCompliance(foundPatchFiles);
+            }
+
+			String output = applyPatches(patchesToApply);
+
+			checkForWatchPhrases(output);
+
+			writeTrackingFile(patchesToApply);
+		}
+        catch (IOException ioe)
+		{
+			throw new MojoExecutionException( "unable to obtain list of patch files", ioe);
+		}
+    }
+
+    private Map findPatchesToApply( List foundPatchFiles, File patchSourceDir )
+        throws MojoFailureException
+    {
+        Map patchesApplied = new LinkedHashMap();
+
+        if ( naturalOrderProcessing )
+        {
+        	patches = new ArrayList( foundPatchFiles ) ;
+        	Collections.sort( patches );
+        }
+
+        String alreadyAppliedPatches = "";
+
+        try
+        {
+            if ( optimizations && patchTrackingFile.exists() )
+            {
+                alreadyAppliedPatches = FileUtils.fileRead( patchTrackingFile );
+            }
+        }
+        catch (IOException ioe)
+        {
+            throw new MojoFailureException( "unable to read patch tracking file: " + ioe.getMessage() );
+        }
+
+        for ( Iterator it = patches.iterator(); it.hasNext(); )
+        {
+            String patch = (String) it.next();
+
+            if ( alreadyAppliedPatches.indexOf( patch ) == -1 )
+            {
+                File patchFile = new File( patchSourceDir, patch );
+
+                getLog().debug( "Looking for patch: " + patch + " in: " + patchFile );
+
+                if ( !patchFile.exists() )
+                {
+                    if ( strictPatching )
+                    {
+                        throw new MojoFailureException(
+                                                        this,
+                                                        "Patch operation cannot proceed.",
+                                                        "Cannot find specified patch: \'"
+                                                                        + patch
+                                                                        + "\' in patch-source directory: \'"
+                                                                        + patchSourceDir
+                                                                        + "\'.\n\nEither fix this error, or relax strictPatching." );
+                    }
+                    else
+                    {
+                        getLog().info( "Skipping patch: " + patch + " listed in the patches parameter; it is missing." );
+                    }
+                }
+                else
+                {
+                    foundPatchFiles.remove( patch );
+
+                    patchesApplied.put( patch, createPatchCommand( patchFile ) );
+                }
+            }
+        }
+
+
+        return patchesApplied;
+    }
+
+    private void checkStrictPatchCompliance( List foundPatchFiles )
+        throws MojoExecutionException
+    {
+        if ( strictPatching )
+        {
+            List ignored = new ArrayList();
+
+            if ( ignoredPatches != null )
+            {
+                ignored.addAll( ignoredPatches );
+            }
+
+            if ( useDefaultIgnores )
+            {
+                ignored.addAll( DEFAULT_IGNORED_PATCHES );
+            }
+
+            List limbo = new ArrayList( foundPatchFiles );
+
+            for ( Iterator it = ignored.iterator(); it.hasNext(); )
+            {
+                String ignoredFile = (String) it.next();
+
+                limbo.remove( ignoredFile );
+            }
+
+            if ( !limbo.isEmpty() )
+            {
+                StringBuffer extraFileBuffer = new StringBuffer();
+
+                extraFileBuffer.append( "Found " + limbo.size() + " unlisted patch files:" );
+
+                for ( Iterator it = foundPatchFiles.iterator(); it.hasNext(); )
+                {
+                    String patch = (String) it.next();
+
+                    extraFileBuffer.append( "\n  \'" ).append( patch ).append( '\'' );
+                }
+
+                extraFileBuffer.append( "\n\nEither remove these files, add them to the patches configuration list, or relax strictPatching." );
+
+                throw new MojoExecutionException( extraFileBuffer.toString() );
+            }
+        }
+    }
+
+    private String applyPatches( Map patchesApplied )
+        throws MojoExecutionException
+    {
+        final StringWriter outputWriter = new StringWriter();
+
+        StreamConsumer consumer = new StreamConsumer()
+        {
+            public void consumeLine( String line )
+            {
+                if ( getLog().isDebugEnabled() )
+                {
+                    getLog().debug( line );
+                }
+
+                outputWriter.write( line + "\n" );
+            }
+        };
+
+        // used if failFast is false
+        String failedPatches = null;
+        
+        for ( Iterator it = patchesApplied.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Entry) it.next();
+            String patchName = (String) entry.getKey();
+            Commandline cli = (Commandline) entry.getValue();
+
+            try
+            {
+                getLog().info( "Applying patch: " + patchName );
+                int result = executeCommandLine( cli, consumer, consumer );
+
+                getLog().info( "patch command returned: " + result );
+                
+                if ( result != 0 )
+                {
+                    if ( failFast )
+                    {
+                        throw new MojoExecutionException( "Patch command failed (exit value != 0) for " + patchName + ". Please see debug output for more information." );
+                    }
+                    else
+                    {
+                        if ( failedPatches == null )
+                        {
+                            failedPatches = new String();
+                        }
+                        failedPatches = failedPatches + patchName + "\n";
+                    }
+                }
+            }
+            catch ( CommandLineException e )
+            {
+                throw new MojoExecutionException( "Failed to apply patch: " + patchName
+                                + ". See debug output for more information.", e );
+            }
+        }
+        
+        if ( failedPatches != null )
+        {
+           getLog().info( "Failed applying one or more patches:" );
+           getLog().info( failedPatches );
+           throw new MojoExecutionException( "Patch command failed for one or more patches. Please see console and debug output for more information." );
+        }
+
+        return outputWriter.toString();
+    }
+
+    private int executeCommandLine( Commandline cli, StreamConsumer out, StreamConsumer err )
+        throws CommandLineException
+    {
+        if ( getLog().isDebugEnabled() )
+        {
+            getLog().debug( "Executing:\n" + cli + "\n" );
+        }
+
+        getLog().info( Commandline.toString( cli.getShellCommandline() ) );
+        
+        return CommandLineUtils.executeCommandLine( cli, out, err );
+    }
+
+    private void writeTrackingFile( Map patchesApplied )
+        throws MojoExecutionException
+    {
+        FileWriter writer = null;
+        try
+        {
+            boolean appending = patchTrackingFile.exists();
+
+            writer = new FileWriter( patchTrackingFile, appending );
+
+            for ( Iterator it = patchesApplied.keySet().iterator(); it.hasNext(); )
+            {
+                if ( appending )
+                {
+                    writer.write( System.getProperty( "line.separator" ) );
+                }
+
+                String patch = (String) it.next();
+                writer.write( patch );
+
+                if ( it.hasNext() )
+                {
+                    writer.write( System.getProperty( "line.separator" ) );
+                }
+            }
+
+            writer.flush();
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Failed to write patch-tracking file: " + patchTrackingFile, e );
+        }
+        finally
+        {
+            IOUtil.close( writer );
+        }
+    }
+
+    private void checkForWatchPhrases( String output )
+        throws MojoExecutionException
+    {
+        for ( Iterator it = failurePhrases.iterator(); it.hasNext(); )
+        {
+            String phrase = (String) it.next();
+
+            if ( output.indexOf( phrase ) > -1 )
+            {
+                throw new MojoExecutionException( "Failed to apply patches (detected watch-phrase: \'" + phrase
+                                + "\' in output). "
+                                + "If this is in error, configure the patchFailureWatchPhrases parameter." );
+            }
+        }
+    }
+
+    /**
+     * Add a new Patch task to the Ant calling mechanism. Give preference to originalFile/destFile, then workDir, and
+     * finally ${basedir}.
+     */
+    private Commandline createPatchCommand( File patchFile )
+    {
+        Commandline cli = new Commandline();
+        //cli.setShell( new BourneShell() );
+
+        cli.setExecutable( "patch" );
+
+        cli.setWorkingDirectory( targetDirectory.getAbsolutePath() );
+
+        if ( originalFile != null )
+        {
+            cli.createArgument().setLine( originalFile.getAbsolutePath() );
+            //cli.createArg().setLine( originalFile.getAbsolutePath() );
+
+            if ( destFile != null )
+            {
+                cli.createArgument().setLine( "-o " + destFile.getAbsolutePath() );
+                //cli.createArg().setLine( "-o " + destFile.getAbsolutePath() );
+            }
+
+            cli.createArgument().setValue( patchFile.getAbsolutePath() );
+            //cli.createArg().setLine( patchFile.getAbsolutePath() );
+        }
+
+        cli.createArgument().setLine( "-p" + strip  );
+        //cli.createArg().setLine( "-p" + strip );
+
+        if ( ignoreWhitespace )
+        {
+            cli.createArgument().setValue( "-l" );
+            //cli.createArg().setLine( "-l" );
+        }
+
+        if ( reverse )
+        {
+            cli.createArgument().setValue( "-R" );
+            //cli.createArg().setLine( "-R" );
+        }
+
+        if ( backups )
+        {
+            cli.createArgument().setValue( "-b" );
+            //cli.createArg().setLine( "-b" );
+        }
+
+        cli.createArgument().setLine( "-i " +  patchFile.getAbsolutePath() );
+        //cli.createArg().setLine( " < " + patchFile.getAbsolutePath() );
+
+        return cli;
+    }
+
+}
diff --git a/src/site/apt/examples/multiple.apt b/src/site/apt/examples/multiple.apt
new file mode 100644
index 0000000..0f08a36
--- /dev/null
+++ b/src/site/apt/examples/multiple.apt
@@ -0,0 +1,84 @@
+ ------

+ Delete Additional Files Not Exposed to Maven

+ ------

+ John Casey

+ Jesse McConnell

+ ------

+ 22 June 2007

+ ------

+

+~~ 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.

+

+~~ NOTE: For help with the syntax of this file, see:

+~~ http://maven.apache.org/guides/mini/guide-apt-format.html

+

+Patch Multiple Files from Multiple Directories

+

+  The <<<maven-patch-plugin>>> can be configured apply sets of patches from multiple directories.

+  In the example below, the plugin is setup to apply all the patches in a bugfix directory with 

+  optimization (will not reapply the same patch) and also from an enhancements directory.  This 

+  scenario might crop up if you don't have commit access to a projects source yet need to apply 

+  bugfix and enhancement patches.  The two different patch source directories are shown purely as 

+  an example of what can be configured.

+

++--------

+<build>

+  [...]

+          <plugin>

+            <groupId>org.apache.maven.plugins</groupId>

+            <artifactId>maven-patch-plugin</artifactId>

+            <version>1.0-SNAPSHOT</version>

+            <configuration>

+               <patchTargetDir>${moduleDirectory}</patchTargetDir>

+               <skipApplication>false</skipApplication>

+            </configuration>

+            <executions>

+               <execution>

+                  <id>bugfix-patches</id>

+                  <configuration>

+                     <patchDirectory>src/main/patches/bugfix</patchDirecto

+ry>

+                     <patchTrackingFile>${project.build.directory}/optimization-

+files/bugfix/patches-applied.txt</patchTrackingFile>

+                     <naturalOrderProcessing>true</naturalOrderProcessing>

+                  </configuration>

+                  <phase>process-sources</phase>

+                  <goals>

+                     <goal>apply</goal>

+                  </goals>

+               </execution>

+               <execution>

+                  <id>enhancement-patches</id>

+                  <configuration>

+                     <patchDirectory>src/main/patches/enhancement</patchDirector

+y>

+                     <patchTrackingFile>${project.build.directory}/optimization-

+files/enhancement/patches-applied.txt</patchTrackingFile>

+                     <naturalOrderProcessing>true</naturalOrderProcessing>

+                  </configuration>

+                  <phase>process-sources</phase>

+                  <goals>

+                     <goal>apply</goal>

+                  </goals>

+               </execution>

+            </executions>

+          </plugin>

+    

+  [...]

+</build>

++---------

diff --git a/src/site/apt/examples/single.apt b/src/site/apt/examples/single.apt
new file mode 100644
index 0000000..4fd0131
--- /dev/null
+++ b/src/site/apt/examples/single.apt
@@ -0,0 +1,57 @@
+ ------

+ Delete Additional Files Not Exposed to Maven

+ ------

+ John Casey

+ Jesse McConnell

+ ------

+ 22 June 2007

+ ------

+

+~~ 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.

+

+~~ NOTE: For help with the syntax of this file, see:

+~~ http://maven.apache.org/guides/mini/guide-apt-format.html

+

+Patch a Single File

+

+  The <<<maven-patch-plugin>>> can be configured to apply a single patch to a file as specified:

+

++--------

+<build>

+  [...]

+

+      <plugin>

+        <artifactId>maven-patch-plugin</artifactId>

+        <configuration>

+          <patches>

+            <patch>mylittle.patch</patch>

+          </patches>

+        </configuration>

+        <executions>

+          <execution>

+            <id>patch</id>

+            <phase>process-sources</phase>

+            <goals>

+              <goal>apply</goal>

+            </goals>

+          </execution>

+        </executions>

+      </plugin>

+  [...]

+</build>

++---------

diff --git a/src/site/apt/faq.apt b/src/site/apt/faq.apt
new file mode 100644
index 0000000..d3ea6fc
--- /dev/null
+++ b/src/site/apt/faq.apt
@@ -0,0 +1,50 @@
+ ------
+ Frequently Asked Questions
+ ------
+ John Casey
+ Jesse McConnell
+ ------
+ 22 June 2007
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Frequently Asked Questions
+
+  [[1]] {{{#1.} What would a patch plugin even be used for?}}
+
+* Answers
+
+  {1.} In certain environments direct source modification is not 
+   allowed so to make alterations to the source you need some patch 
+   application process.  This plugin seeks to address those situations.
+   
+  [[2]] {{{#2.} Why won't this work on windows?}}
+
+* Answers
+
+  {1.} This patch wraps the gnu patch tool, which must be in your path
+    in order to function properly.  You might able to get this plugin working 
+    within cygwin.
+    
+  {2.} If you would like to add windows support to this plugin, please do and 
+    submit modifications through the normal project mechansims.
+      
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
new file mode 100644
index 0000000..ad0912a
--- /dev/null
+++ b/src/site/apt/index.apt
@@ -0,0 +1,52 @@
+ ------
+ Maven Patch Plugin
+ ------
+ John Casey
+ Jesse McConnell
+ ------
+ 22 June 2007
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Overview
+
+  The patch plugin is used to apply patches to source files.
+
+* Goals Overview
+
+  The patch plugin has a single goal that can apply either a single declared patch or a directory of patches. Application of an entire patch directory can be configured with various patch-inclusion, -exclusion, and -ordering options.
+
+* Usage
+
+  Instructions on the basic usage of the patch plugin can be found
+  {{{usage.html}here}}.
+
+* Examples
+
+  To provide you with better understanding on some usages of the patch plugin,
+  you can take a look into the following examples:
+
+  * {{{examples/single.html}How to patch from a single file.}}
+
+  * {{{examples/multiple.html}How to patch from a directory of patches.}}
+
+  []
\ No newline at end of file
diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt
new file mode 100644
index 0000000..5bbdc79
--- /dev/null
+++ b/src/site/apt/usage.apt
@@ -0,0 +1,69 @@
+ ------
+ Usage
+ ------
+ John Casey
+ Jesse McConnell
+ ------
+ 22 June 2007
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Introduction
+
+  The maven-patch-plugin attempts to use the gnu patch tool to apply patch files
+  to source code.  It can be configured to apply patch files from any number of 
+  directories with a number of different policies including strict patching where 
+  you must declare all patchs in the plugin configuration to a natural order processing
+  which will apply all patching in a directory following a natural string sorted order.
+
+  This plugin is most commonly used during the process-sources phase of the maven lifecycle.
+
++-----
+  mvn process-sources
++-----
+
++-----
+<project>
+  [...]
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-patch-plugin</artifactId>
+        <configuration>
+          <patches>
+            <patch>mylittle.patch</patch>
+          </patches>
+        </configuration>
+        <executions>
+          <execution>
+            <id>patch</id>
+            <goals>
+              <goal>apply</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  [...]
+</project>
++-----
\ No newline at end of file
diff --git a/src/site/site.xml b/src/site/site.xml
new file mode 100644
index 0000000..4c72ae5
--- /dev/null
+++ b/src/site/site.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+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>
+  <body>
+    <menu name="Overview">
+      <item name="Introduction" href="index.html"/>
+      <item name="Goals" href="plugin-info.html"/>
+      <item name="Usage" href="usage.html"/>
+      <item name="FAQ" href="faq.html"/>
+    </menu>
+    <menu name="Examples">
+      <item name="Single Patch" href="examples/single.html"/>
+      <item name="Multiple Patch" href="examples/multiple.html"/>
+    </menu>
+  </body>
+</project>