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

adangel pushed a commit to branch mpmd-304
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git


The following commit(s) were added to refs/heads/mpmd-304 by this push:
     new b537610  Create a custom selector script for toolchains
b537610 is described below

commit b537610e9b84a450b9abdd155d2e5537105740fe
Author: Andreas Dangel <[email protected]>
AuthorDate: Sun Oct 4 11:44:00 2020 +0200

    Create a custom selector script for toolchains
---
 .../MPMD-304-toolchain-support/invoker.properties  | 15 +++--
 src/it/MPMD-304-toolchain-support/selector.groovy  | 65 ++++++++++++++++++++++
 src/it/MPMD-304-toolchain-support/setup.groovy     | 28 ----------
 .../{toolchains.xml => toolchains.windows.xml}     |  2 +-
 4 files changed, 77 insertions(+), 33 deletions(-)

diff --git a/src/it/MPMD-304-toolchain-support/invoker.properties 
b/src/it/MPMD-304-toolchain-support/invoker.properties
index 48b2e9d..198db8b 100644
--- a/src/it/MPMD-304-toolchain-support/invoker.properties
+++ b/src/it/MPMD-304-toolchain-support/invoker.properties
@@ -15,11 +15,18 @@
 # specific language governing permissions and limitations
 # under the License.
 
-invoker.java.version = 11+
+invoker.java.version = 1.7+
 
-# available toolchains:
+# available toolchains under linux:
 # 
https://github.com/apache/infrastructure-p6/blob/production/modules/build_nodes/files/toolchains.xml
 # the jdk toolchain "11:oracle" is selected in pom.xml
-invoker.toolchain.jdk.version = 11
-invoker.toolchain.jdk.vendor = oracle
+
+# since the toolchains are only configured under linux slaves
+# we don't use invoker selections here, but selector.groovy
+#invoker.toolchain.jdk.version = 11
+#invoker.toolchain.jdk.vendor = oracle
+
+# the file toolchains.xml will be created by selector.groovy
+# - for linux, ${user.home}/.m2/toolchains.xml will be copied
+# - for windows, a new file will be created using toolchains.windows.xml, see 
selector.groovy
 invoker.goals = clean verify --toolchains toolchains.xml
diff --git a/src/it/MPMD-304-toolchain-support/selector.groovy 
b/src/it/MPMD-304-toolchain-support/selector.groovy
new file mode 100644
index 0000000..55abd8b
--- /dev/null
+++ b/src/it/MPMD-304-toolchain-support/selector.groovy
@@ -0,0 +1,65 @@
+/*
+ * 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 testToolchains = new File( basedir, 'toolchains.xml' )
+
+File userToolchains = new File( System.getProperty( 'user.home' ), 
'.m2/toolchains.xml' )
+if ( userToolchains.exists() )
+{
+    System.out.println( "INFO: Copying ${userToolchains.absolutePath} to 
${testToolchains.absolutePath}" )
+    testToolchains.text = userToolchains.text
+}
+else
+{
+    System.out.println( "WARNING: File ${userToolchains.absolutePath} not 
found" )
+    if ( System.getProperty( 'os.name' ).startsWith( 'Windows' ) )
+    {
+        String jdk11Windows = 'f:\\jenkins\\tools\\java\\latest11'
+        File windowsToolchains = new File( basedir, 'toolchains.windows.xml' )
+        System.out.println( "INFO: Creating ${testToolchains.absolutePath} 
with jdk:11:oracle=${jdk11Windows}" )
+
+        String placeholder = '@jdk.home@'
+        String replacement = jdk11Windows
+        // extra escaping of backslashes in the path for Windows
+        replacement = replacement.replaceAll("\\\\", "\\\\\\\\")
+        testToolchains.text = windowsToolchains.text.replaceAll( placeholder, 
replacement )
+        System.out.println( "Replaced '${placeholder}' with '${replacement}' 
in '${testToolchains.absolutePath}'." )
+    }
+}
+
+if ( testToolchains.exists() )
+{
+    def toolchains = new XmlParser().parseText( testToolchains.text )
+    def result = toolchains.children().find { toolchain ->
+            toolchain.type.text() == 'jdk' &&
+            toolchain.provides.version.text() == '11' &&
+            toolchain.provides.vendor.text() == 'oracle'
+    }
+    if ( !result )
+    {
+        System.out.println( "WARNING: No jdk toolchain for 11:oracle found" )
+        return false
+    }
+
+    System.out.println( "INFO: Found toolchain: ${result}" )
+    return true
+}
+
+System.out.println( "WARNING: Skipping integration test due to missing 
toolchain" )
+return false
diff --git a/src/it/MPMD-304-toolchain-support/setup.groovy 
b/src/it/MPMD-304-toolchain-support/setup.groovy
deleted file mode 100644
index d10a4b5..0000000
--- a/src/it/MPMD-304-toolchain-support/setup.groovy
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 toolchains = new File( basedir, 'toolchains.xml' )
-String placeholder = '@jdk.home@'
-String replacement = System.getProperty( 'java.home' )
-// extra escaping of backslashes in the path for Windows
-replacement = replacement.replaceAll("\\\\", "\\\\\\\\")
-toolchains.text = toolchains.text.replaceAll( placeholder, replacement )
-System.out.println( "Replaced '${placeholder}' with '${replacement}' in 
'${toolchains.absolutePath}'." )
-
-return true
diff --git a/src/it/MPMD-304-toolchain-support/toolchains.xml 
b/src/it/MPMD-304-toolchain-support/toolchains.windows.xml
similarity index 94%
rename from src/it/MPMD-304-toolchain-support/toolchains.xml
rename to src/it/MPMD-304-toolchain-support/toolchains.windows.xml
index bc2acd6..e3acb90 100644
--- a/src/it/MPMD-304-toolchain-support/toolchains.xml
+++ b/src/it/MPMD-304-toolchain-support/toolchains.windows.xml
@@ -29,7 +29,7 @@ under the License.
             <vendor>oracle</vendor>
         </provides>
         <configuration>
-            <!-- this placeholder will be replaced by setup.groovy -->
+            <!-- this placeholder will be replaced by selector.groovy -->
             <jdkHome>@jdk.home@</jdkHome>
         </configuration>
     </toolchain>

Reply via email to