|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +File testToolchains = new File( basedir, 'toolchains.xml' ) |
| 21 | + |
| 22 | +File userToolchains = new File( System.getProperty( 'user.home' ), '.m2/toolchains.xml' ) |
| 23 | +if ( userToolchains.exists() ) |
| 24 | +{ |
| 25 | + System.out.println( "INFO: Copying ${userToolchains.absolutePath} to ${testToolchains.absolutePath}" ) |
| 26 | + testToolchains.text = userToolchains.text |
| 27 | +} |
| 28 | +else |
| 29 | +{ |
| 30 | + System.out.println( "WARNING: File ${userToolchains.absolutePath} not found" ) |
| 31 | + if ( System.getProperty( 'os.name' ).startsWith( 'Windows' ) ) |
| 32 | + { |
| 33 | + String jdk11Windows = 'f:\\jenkins\\tools\\java\\latest11' |
| 34 | + File windowsToolchains = new File( basedir, 'toolchains.windows.xml' ) |
| 35 | + System.out.println( "INFO: Creating ${testToolchains.absolutePath} with jdk:11:oracle=${jdk11Windows}" ) |
| 36 | + |
| 37 | + String placeholder = '@jdk.home@' |
| 38 | + String replacement = jdk11Windows |
| 39 | + // extra escaping of backslashes in the path for Windows |
| 40 | + replacement = replacement.replaceAll("\\\\", "\\\\\\\\") |
| 41 | + testToolchains.text = windowsToolchains.text.replaceAll( placeholder, replacement ) |
| 42 | + System.out.println( "Replaced '${placeholder}' with '${replacement}' in '${testToolchains.absolutePath}'." ) |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +if ( testToolchains.exists() ) |
| 47 | +{ |
| 48 | + def toolchains = new XmlParser().parseText( testToolchains.text ) |
| 49 | + def result = toolchains.children().find { toolchain -> |
| 50 | + toolchain.type.text() == 'jdk' && |
| 51 | + toolchain.provides.version.text() == '11' && |
| 52 | + toolchain.provides.vendor.text() == 'oracle' |
| 53 | + } |
| 54 | + if ( !result ) |
| 55 | + { |
| 56 | + System.out.println( "WARNING: No jdk toolchain for 11:oracle found" ) |
| 57 | + return false |
| 58 | + } |
| 59 | + |
| 60 | + System.out.println( "INFO: Found toolchain: ${result}" ) |
| 61 | + return true |
| 62 | +} |
| 63 | + |
| 64 | +System.out.println( "WARNING: Skipping integration test due to missing toolchain" ) |
| 65 | +return false |
0 commit comments