Author: rfscholte
Date: Fri Jul  7 21:06:34 2017
New Revision: 1801215

URL: http://svn.apache.org/viewvc?rev=1801215&view=rev
Log:
[MINVOKER-149] Possibility to have different settings.xml per IT

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/invoker.properties
    maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/
    maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/invoker.properties
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/pom.xml
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/postbuild.groovy
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings-override.xml
    
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings.xml
Modified:
    
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
    
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/invoker.properties?rev=1801215&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/invoker.properties
 Fri Jul  7 21:06:34 2017
@@ -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.
+
+# See https://issues.apache.org/jira/browse/MNG-5224
+invoker.maven.version = 3.0-,3.0.4+

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/pom.xml?rev=1801215&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/pom.xml 
(added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/pom.xml 
Fri Jul  7 21:06:34 2017
@@ -0,0 +1,59 @@
+<?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>settings-merge</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>Test to check that the settings.xml from the calling process is 
merged with the
+  one specified for m-invoker-p.</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>@project.version@</version>
+        <configuration>
+          <settingsFile>src/it/settings.xml</settingsFile>
+          <mergeUserSettings>true</mergeUserSettings>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/invoker.properties?rev=1801215&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/invoker.properties
 Fri Jul  7 21:06:34 2017
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.settingsFile =src/it/settings-override.xml
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/pom.xml?rev=1801215&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/pom.xml
 Fri Jul  7 21:06:34 2017
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>project</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <enforcer.fail>true</enforcer.fail>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>1.0.1</version>
+        <executions>
+          <execution>
+            <id>verify-properties</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <alwaysFail/>
+              </rules>
+              <fail>${enforcer.fail}</fail>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/postbuild.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/postbuild.groovy?rev=1801215&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/postbuild.groovy
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/project/postbuild.groovy
 Fri Jul  7 21:06:34 2017
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+File interpolatedCustomSettings = new File( basedir, 
"../interpolated-settings-override.xml" )
+assert interpolatedCustomSettings.isFile()

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings-override.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings-override.xml?rev=1801215&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings-override.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings-override.xml
 Fri Jul  7 21:06:34 2017
@@ -0,0 +1,34 @@
+<?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.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-properties</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <enforcer.fail>false</enforcer.fail>
+      </properties>
+    </profile>
+  </profiles>
+</settings>

Added: 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings.xml?rev=1801215&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings.xml
 (added)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/it/settings-override/src/it/settings.xml
 Fri Jul  7 21:06:34 2017
@@ -0,0 +1,34 @@
+<?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.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-properties</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <enforcer.fail>true</enforcer.fail>
+      </properties>
+    </profile>
+  </profiles>
+</settings>

Modified: 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java?rev=1801215&r1=1801214&r2=1801215&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
 Fri Jul  7 21:06:34 2017
@@ -524,6 +524,10 @@ public abstract class AbstractInvokerMoj
      * # A boolean value controlling the debug logging level of Maven, , 
defaults to &quot;false&quot;
      * # Since plugin version 1.8
      * invoker.debug = true
+     * 
+     * # Path to an alternate <code>settings.xml</code> to use for Maven 
invocation with this IT.
+     * # Since plugin version 3.0.1
+     * invoker.settingsFile = ../
      * </pre>
      *
      * @since 1.2
@@ -1162,7 +1166,7 @@ public abstract class AbstractInvokerMoj
         // interpolate settings file
         // -----------------------------------------------
 
-        File interpolatedSettingsFile = interpolateSettings();
+        File interpolatedSettingsFile = interpolateSettings( settingsFile );
 
         final File mergedSettingsFile = mergeSettings( 
interpolatedSettingsFile );
 
@@ -1246,11 +1250,12 @@ public abstract class AbstractInvokerMoj
 
     /**
      * Interpolate settings.xml file.
+     * @param settingsFile a settings file
      * 
      * @return The interpolated settings.xml file.
      * @throws MojoExecutionException in case of a problem.
      */
-    private File interpolateSettings()
+    private File interpolateSettings( File settingsFile )
         throws MojoExecutionException
     {
         File interpolatedSettingsFile = null;
@@ -1827,7 +1832,18 @@ public abstract class AbstractInvokerMoj
 
                 request.setOffline( false );
 
-                request.setUserSettingsFile( settingsFile );
+                String customSettingsFile = invokerProperties.getSettingsFile( 
invocationIndex );
+                if ( customSettingsFile != null )
+                {
+                    File interpolateSettingsFile = interpolateSettings( new 
File( customSettingsFile ) );
+                    File mergeSettingsFile = mergeSettings( 
interpolateSettingsFile );
+                    
+                    request.setUserSettingsFile( mergeSettingsFile );
+                }
+                else
+                {
+                    request.setUserSettingsFile( settingsFile );
+                }
 
                 Properties systemProperties =
                     getSystemProperties( basedir, 
invokerProperties.getSystemPropertiesFile( invocationIndex ) );

Modified: 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java?rev=1801215&r1=1801214&r2=1801215&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
 (original)
+++ 
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
 Fri Jul  7 21:06:34 2017
@@ -48,7 +48,8 @@ class InvokerProperties
         NON_RECURSIVE( "invoker.nonRecursive" ),
         OFFLINE( "invoker.offline" ),
         SYSTEM_PROPERTIES_FILE( "invoker.systemPropertiesFile" ),
-        DEBUG( "invoker.debug" );
+        DEBUG( "invoker.debug" ),
+        SETTINGS_FILE ( "invoker.settingsFile" );
 
         private final String key;
 
@@ -325,7 +326,7 @@ class InvokerProperties
     /**
      * Gets the path to the properties file used to set the system properties 
for the specified invocation.
      *
-     * @param index The index of the invocation for which to check the exit 
code, must not be negative.
+     * @param index The index of the invocation, must not be negative.
      * @return The path to the properties file or <code>null</code> if not set.
      */
     public String getSystemPropertiesFile( int index )
@@ -334,6 +335,17 @@ class InvokerProperties
     }
 
     /**
+     * Gets the settings file used for the specified invocation.
+     * 
+     * @param index The index of the invocation, must not be negative.
+     * @return the value for the settings file or <code>null</code> if not set.
+     */
+    public String getSettingsFile( int index )
+    {
+        return get( InvocationProperty.SETTINGS_FILE, index );
+    }
+
+    /**
      * Gets a value from the invoker properties. The invoker properties are 
intended to describe the invocation settings
      * for multiple builds of the same project. For this reason, the 
properties are indexed. First, a property named
      * <code>key.index</code> will be queried. If this property does not 
exist, the value of the property named


Reply via email to