You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2018/03/29 03:26:23 UTC

[maven-invoker-plugin] branch master updated: MINVOKER-224 (#2)

This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new c272b25  MINVOKER-224 (#2)
c272b25 is described below

commit c272b250c67464184e516f19fcd444bc731ea5ec
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Thu Mar 29 13:26:21 2018 +1000

    MINVOKER-224 (#2)
    
    * [MINVOKER-224] fix Unable to set cloneProjectsTo to null
    
    Signed-off-by: olivier lamy <ol...@apache.org>
    
    * fix its because of changes
    
    Signed-off-by: olivier lamy <ol...@apache.org>
---
 .../invoker.properties                             | 19 ++++++
 .../pom.xml                                        | 11 ++--
 .../src/it/clone-clean}/pom.xml                    | 40 +-----------
 src/it/clone-maven-plugin-packaging/verify.bsh     | 31 +++++++++
 src/it/local-repo-default/pom.xml                  |  1 +
 src/it/not-clone-not-plugin/invoker.properties     | 19 ++++++
 .../pom.xml                                        | 10 ++-
 .../src/it/clone-clean}/pom.xml                    | 40 +-----------
 src/it/not-clone-not-plugin/verify.bsh             | 31 +++++++++
 src/it/script-context/pom.xml                      |  1 +
 src/it/script-errors/pom.xml                       |  1 +
 src/it/script-interpreter-detection/pom.xml        |  1 +
 src/it/selector-conditions/pom.xml                 |  3 +-
 src/it/selector-scripts/pom.xml                    |  1 +
 .../maven/plugins/invoker/AbstractInvokerMojo.java | 76 ++++++++++++----------
 15 files changed, 164 insertions(+), 121 deletions(-)

diff --git a/src/it/clone-maven-plugin-packaging/invoker.properties b/src/it/clone-maven-plugin-packaging/invoker.properties
new file mode 100644
index 0000000..f45dd01
--- /dev/null
+++ b/src/it/clone-maven-plugin-packaging/invoker.properties
@@ -0,0 +1,19 @@
+# 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: Don't clean here to be able to detect test failures
+invoker.goals = initialize
diff --git a/src/it/selector-conditions/pom.xml b/src/it/clone-maven-plugin-packaging/pom.xml
similarity index 85%
copy from src/it/selector-conditions/pom.xml
copy to src/it/clone-maven-plugin-packaging/pom.xml
index 9397897..d3f9f85 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/clone-maven-plugin-packaging/pom.xml
@@ -23,11 +23,11 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.maven.plugins.invoker</groupId>
-  <artifactId>selector-conditions</artifactId>
+  <artifactId>clone-maven-plugin-packaging</artifactId>
   <version>1.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
+  <packaging>maven-plugin</packaging>
 
-  <description>Test to check for selection of builds based on OS and/or JRE.</description>
+  <description>Test to check for cloned project of packaging maven-plugin.</description>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -40,12 +40,11 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@pom.version@</version>
         <configuration>
-          <debug>true</debug>
+          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+          <cloneClean>true</cloneClean>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
-          <preBuildHookScript>prebuild</preBuildHookScript>
-          <postBuildHookScript>postbuild</postBuildHookScript>
           <goals>
             <goal>validate</goal>
           </goals>
diff --git a/src/it/selector-conditions/pom.xml b/src/it/clone-maven-plugin-packaging/src/it/clone-clean/pom.xml
similarity index 52%
copy from src/it/selector-conditions/pom.xml
copy to src/it/clone-maven-plugin-packaging/src/it/clone-clean/pom.xml
index 9397897..267fcdb 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/clone-maven-plugin-packaging/src/it/clone-clean/pom.xml
@@ -21,46 +21,12 @@ 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>selector-conditions</artifactId>
-  <version>1.0-SNAPSHOT</version>
+  <groupId>test</groupId>
+  <artifactId>clone-clean</artifactId>
+  <version>0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
-  <description>Test to check for selection of builds based on OS and/or JRE.</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>
-          <debug>true</debug>
-          <pomIncludes>
-            <pomInclude>*/pom.xml</pomInclude>
-          </pomIncludes>
-          <preBuildHookScript>prebuild</preBuildHookScript>
-          <postBuildHookScript>postbuild</postBuildHookScript>
-          <goals>
-            <goal>validate</goal>
-          </goals>
-        </configuration>
-        <executions>
-          <execution>
-            <id>integration-test</id>
-            <phase>initialize</phase>
-            <goals>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
diff --git a/src/it/clone-maven-plugin-packaging/verify.bsh b/src/it/clone-maven-plugin-packaging/verify.bsh
new file mode 100644
index 0000000..2ee7280
--- /dev/null
+++ b/src/it/clone-maven-plugin-packaging/verify.bsh
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+
+try
+{
+    File itRoot = new File( basedir, "target/it/clone-clean" );
+    return itRoot.exists();
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
diff --git a/src/it/local-repo-default/pom.xml b/src/it/local-repo-default/pom.xml
index d993004..b601efb 100644
--- a/src/it/local-repo-default/pom.xml
+++ b/src/it/local-repo-default/pom.xml
@@ -43,6 +43,7 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@pom.version@</version>
         <configuration>
+          <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
diff --git a/src/it/not-clone-not-plugin/invoker.properties b/src/it/not-clone-not-plugin/invoker.properties
new file mode 100644
index 0000000..f45dd01
--- /dev/null
+++ b/src/it/not-clone-not-plugin/invoker.properties
@@ -0,0 +1,19 @@
+# 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: Don't clean here to be able to detect test failures
+invoker.goals = initialize
diff --git a/src/it/selector-conditions/pom.xml b/src/it/not-clone-not-plugin/pom.xml
similarity index 85%
copy from src/it/selector-conditions/pom.xml
copy to src/it/not-clone-not-plugin/pom.xml
index 9397897..4cf525c 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/not-clone-not-plugin/pom.xml
@@ -23,11 +23,11 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.maven.plugins.invoker</groupId>
-  <artifactId>selector-conditions</artifactId>
+  <artifactId>not-clone-not-a-plugin-invocation</artifactId>
   <version>1.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
+  <packaging>pom</packaging>
 
-  <description>Test to check for selection of builds based on OS and/or JRE.</description>
+  <description>Test to check for not cloning non maven plugin project.</description>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -40,12 +40,10 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@pom.version@</version>
         <configuration>
-          <debug>true</debug>
+          <cloneProjectsTo/>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
-          <preBuildHookScript>prebuild</preBuildHookScript>
-          <postBuildHookScript>postbuild</postBuildHookScript>
           <goals>
             <goal>validate</goal>
           </goals>
diff --git a/src/it/selector-conditions/pom.xml b/src/it/not-clone-not-plugin/src/it/clone-clean/pom.xml
similarity index 52%
copy from src/it/selector-conditions/pom.xml
copy to src/it/not-clone-not-plugin/src/it/clone-clean/pom.xml
index 9397897..267fcdb 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/not-clone-not-plugin/src/it/clone-clean/pom.xml
@@ -21,46 +21,12 @@ 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>selector-conditions</artifactId>
-  <version>1.0-SNAPSHOT</version>
+  <groupId>test</groupId>
+  <artifactId>clone-clean</artifactId>
+  <version>0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
 
-  <description>Test to check for selection of builds based on OS and/or JRE.</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>
-          <debug>true</debug>
-          <pomIncludes>
-            <pomInclude>*/pom.xml</pomInclude>
-          </pomIncludes>
-          <preBuildHookScript>prebuild</preBuildHookScript>
-          <postBuildHookScript>postbuild</postBuildHookScript>
-          <goals>
-            <goal>validate</goal>
-          </goals>
-        </configuration>
-        <executions>
-          <execution>
-            <id>integration-test</id>
-            <phase>initialize</phase>
-            <goals>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
 </project>
diff --git a/src/it/not-clone-not-plugin/verify.bsh b/src/it/not-clone-not-plugin/verify.bsh
new file mode 100644
index 0000000..b219ae5
--- /dev/null
+++ b/src/it/not-clone-not-plugin/verify.bsh
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+
+try
+{
+    File itRoot = new File( basedir, "target/it/clone-clean" );
+    return !itRoot.exists();
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
diff --git a/src/it/script-context/pom.xml b/src/it/script-context/pom.xml
index aed4ce6..6d35a68 100644
--- a/src/it/script-context/pom.xml
+++ b/src/it/script-context/pom.xml
@@ -42,6 +42,7 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@project.version@</version>
         <configuration>
+          <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
diff --git a/src/it/script-errors/pom.xml b/src/it/script-errors/pom.xml
index 6ff883d..124bd90 100644
--- a/src/it/script-errors/pom.xml
+++ b/src/it/script-errors/pom.xml
@@ -43,6 +43,7 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@project.version@</version>
         <configuration>
+          <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
diff --git a/src/it/script-interpreter-detection/pom.xml b/src/it/script-interpreter-detection/pom.xml
index fa46328..b5d5ee1 100644
--- a/src/it/script-interpreter-detection/pom.xml
+++ b/src/it/script-interpreter-detection/pom.xml
@@ -40,6 +40,7 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@pom.version@</version>
         <configuration>
+          <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
           <debug>true</debug>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
diff --git a/src/it/selector-conditions/pom.xml b/src/it/selector-conditions/pom.xml
index 9397897..c73a245 100644
--- a/src/it/selector-conditions/pom.xml
+++ b/src/it/selector-conditions/pom.xml
@@ -25,7 +25,7 @@ under the License.
   <groupId>org.apache.maven.plugins.invoker</groupId>
   <artifactId>selector-conditions</artifactId>
   <version>1.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
+  <packaging>maven-plugin</packaging>
 
   <description>Test to check for selection of builds based on OS and/or JRE.</description>
 
@@ -41,6 +41,7 @@ under the License.
         <version>@pom.version@</version>
         <configuration>
           <debug>true</debug>
+
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
           </pomIncludes>
diff --git a/src/it/selector-scripts/pom.xml b/src/it/selector-scripts/pom.xml
index 160b593..c3be520 100644
--- a/src/it/selector-scripts/pom.xml
+++ b/src/it/selector-scripts/pom.xml
@@ -40,6 +40,7 @@ under the License.
         <artifactId>maven-invoker-plugin</artifactId>
         <version>@pom.version@</version>
         <configuration>
+          <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
           <debug>true</debug>
           <pomIncludes>
             <pomInclude>*/pom.xml</pomInclude>
diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
index debba76..97a20a2 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -19,37 +19,6 @@ package org.apache.maven.plugins.invoker;
  * under the License.
  */
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Profile;
@@ -57,10 +26,10 @@ import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.invoker.model.BuildJob;
-import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Writer;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.invoker.model.BuildJob;
+import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Writer;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.SettingsUtils;
@@ -97,6 +66,39 @@ 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 java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
 import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
 
 /**
@@ -175,7 +177,7 @@ public abstract class AbstractInvokerMojo
      *
      * @since 1.1
      */
-    @Parameter( defaultValue = "${project.build.directory}/its" )
+    @Parameter( property = "invoker.cloneProjectsTo" )
     private File cloneProjectsTo;
 
     // CHECKSTYLE_OFF: LineLength
@@ -683,6 +685,12 @@ public abstract class AbstractInvokerMojo
             cloneProjects( collectedProjects );
             projectsDir = cloneProjectsTo;
         }
+        if ( cloneProjectsTo == null && "maven-plugin".equals( project.getPackaging() ) )
+        {
+            cloneProjectsTo = new File( project.getBuild().getDirectory(), "its" );
+            cloneProjects( collectedProjects );
+            projectsDir = cloneProjectsTo;
+        }
         else
         {
             getLog().warn( "Filtering of parent/child POMs is not supported without cloning the projects" );

-- 
To stop receiving notification emails like this one, please contact
olamy@apache.org.