maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r925763 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/clone-clean/ it/clone-clean/pom.xml it/clone-clean/setup.bsh it/clone-clean/verify.bsh main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
Date Sun, 21 Mar 2010 13:10:44 GMT
Author: bentmann
Date: Sun Mar 21 13:10:44 2010
New Revision: 925763

URL: http://svn.apache.org/viewvc?rev=925763&view=rev
Log:
[MINVOKER-101] provide property to make a clean clone
Submitted by: Robert Scholte

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/
    maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh   (with props)
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml?rev=925763&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml Sun Mar 21 13:10:44
2010
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.invoker</groupId>
+  <artifactId>clone-clean-invocation</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>Test to check for support to launch Maven on a mere directory, i.e.
without a POM</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+          <cloneClean>true</cloneClean>
+          <pomIncludes>
+            <pomInclude>clone-clean</pomInclude>
+          </pomIncludes>
+          <goals>
+            <goal>--version</goal>
+          </goals>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh?rev=925763&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh Sun Mar 21 13:10:44
2010
@@ -0,0 +1,13 @@
+import java.io.*;
+
+try
+{
+    File itRoot = new File( basedir, "target/it/clone-clean" );
+    itRoot.mkdirs();
+    return new File(itRoot, "foobar.log").createNewFile();
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh?rev=925763&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh Sun Mar 21 13:10:44
2010
@@ -0,0 +1,12 @@
+import java.io.*;
+
+try
+{
+    File itRoot = new File( basedir, "target/it/clone-clean" );
+    return !new File( itRoot, "foobar.log" ).exists();
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/clone-clean/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java?rev=925763&r1=925762&r2=925763&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
(original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
Sun Mar 21 13:10:44 2010
@@ -160,6 +160,13 @@ public abstract class AbstractInvokerMoj
      * @since 1.2
      */
     private boolean cloneAllFiles;
+    
+    /**
+     * Ensure the cloneProjectsTo directory is not polluted with files from earlier invoker
runs.  
+     * 
+     * @parameter default-value="false"
+     */
+    private boolean cloneClean;
 
     /**
      * A single POM to build, skipping any scanning parameters and behavior.
@@ -751,7 +758,17 @@ public abstract class AbstractInvokerMoj
     private void cloneProjects( Collection projectPaths )
         throws MojoExecutionException
     {
-        cloneProjectsTo.mkdirs();
+        if ( !cloneProjectsTo.mkdirs() && cloneClean ) 
+        {
+            try
+            {
+                FileUtils.cleanDirectory( cloneProjectsTo );
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Could not clean the cloneProjectsTo directory.
Reason: " + e.getMessage(), e );
+            }
+        }
 
         // determine project directories to clone
         Collection dirs = new LinkedHashSet();



Mime
View raw message