1*2167191dSAndroid Build Coastguard Worker/* 2*2167191dSAndroid Build Coastguard Worker * Copyright 2021 The JSpecify Authors. 3*2167191dSAndroid Build Coastguard Worker * 4*2167191dSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*2167191dSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*2167191dSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*2167191dSAndroid Build Coastguard Worker * 8*2167191dSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*2167191dSAndroid Build Coastguard Worker * 10*2167191dSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*2167191dSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*2167191dSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*2167191dSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*2167191dSAndroid Build Coastguard Worker * limitations under the License. 15*2167191dSAndroid Build Coastguard Worker */ 16*2167191dSAndroid Build Coastguard Worker 17*2167191dSAndroid Build Coastguard Worker/** 18*2167191dSAndroid Build Coastguard Worker * This build configuration generates two integration test tasks: integrationTest and integrationTestOnJava8. 19*2167191dSAndroid Build Coastguard Worker * These tasks share the integrationTest sourceSets, which contains test cases implemented with the JUnit Jupiter API. 20*2167191dSAndroid Build Coastguard Worker */ 21*2167191dSAndroid Build Coastguard Worker 22*2167191dSAndroid Build Coastguard WorkersourceSets { 23*2167191dSAndroid Build Coastguard Worker // The source set for integration test that depends on the generated multi-release jar file 24*2167191dSAndroid Build Coastguard Worker integrationTest { 25*2167191dSAndroid Build Coastguard Worker java { 26*2167191dSAndroid Build Coastguard Worker srcDirs = ['src/integrationTest/java'] 27*2167191dSAndroid Build Coastguard Worker } 28*2167191dSAndroid Build Coastguard Worker compileClasspath += tasks.jar.outputs.files // need to depend on not classes dirs but a jar file 29*2167191dSAndroid Build Coastguard Worker runtimeClasspath += tasks.jar.outputs.files 30*2167191dSAndroid Build Coastguard Worker } 31*2167191dSAndroid Build Coastguard Worker} 32*2167191dSAndroid Build Coastguard Worker 33*2167191dSAndroid Build Coastguard Workerconfigurations { 34*2167191dSAndroid Build Coastguard Worker integrationTestImplementation.extendsFrom implementation 35*2167191dSAndroid Build Coastguard Worker integrationTestRuntimeOnly.extendsFrom runtimeOnly 36*2167191dSAndroid Build Coastguard Worker} 37*2167191dSAndroid Build Coastguard Worker 38*2167191dSAndroid Build Coastguard Workerdependencies { 39*2167191dSAndroid Build Coastguard Worker integrationTestImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" 40*2167191dSAndroid Build Coastguard Worker integrationTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" 41*2167191dSAndroid Build Coastguard Worker integrationTestRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.0' 42*2167191dSAndroid Build Coastguard Worker errorprone "com.google.errorprone:error_prone_core:${errorproneVersion}" 43*2167191dSAndroid Build Coastguard Worker} 44*2167191dSAndroid Build Coastguard Worker 45*2167191dSAndroid Build Coastguard Workertasks.named('compileIntegrationTestJava', JavaCompile).configure { 46*2167191dSAndroid Build Coastguard Worker // compiled tests will run with both Java 8 and 9+ 47*2167191dSAndroid Build Coastguard Worker options.release = 8 48*2167191dSAndroid Build Coastguard Worker} 49*2167191dSAndroid Build Coastguard Worker 50*2167191dSAndroid Build Coastguard Workerdef integrationTestOnJava8 = tasks.register("integrationTestOnJava8", Test) 51*2167191dSAndroid Build Coastguard WorkerintegrationTestOnJava8.configure { 52*2167191dSAndroid Build Coastguard Worker group 'Verification' 53*2167191dSAndroid Build Coastguard Worker description 'Runs the integration tests with JDK8, to verify the support for Java without jigsaw.' 54*2167191dSAndroid Build Coastguard Worker 55*2167191dSAndroid Build Coastguard Worker classpath = sourceSets.integrationTest.runtimeClasspath 56*2167191dSAndroid Build Coastguard Worker testClassesDirs = sourceSets.integrationTest.output.classesDirs 57*2167191dSAndroid Build Coastguard Worker useJUnitPlatform() 58*2167191dSAndroid Build Coastguard Worker 59*2167191dSAndroid Build Coastguard Worker javaLauncher = javaToolchains.launcherFor { 60*2167191dSAndroid Build Coastguard Worker languageVersion = JavaLanguageVersion.of(8) 61*2167191dSAndroid Build Coastguard Worker } 62*2167191dSAndroid Build Coastguard Worker} 63*2167191dSAndroid Build Coastguard Worker 64*2167191dSAndroid Build Coastguard Workerdef integrationTest = tasks.register("integrationTest", Test) 65*2167191dSAndroid Build Coastguard WorkerintegrationTest.configure { 66*2167191dSAndroid Build Coastguard Worker group 'Verification' 67*2167191dSAndroid Build Coastguard Worker description 'Runs the integration tests with JDK9+, to verify the support for Java without jigsaw.' 68*2167191dSAndroid Build Coastguard Worker 69*2167191dSAndroid Build Coastguard Worker classpath = sourceSets.integrationTest.runtimeClasspath 70*2167191dSAndroid Build Coastguard Worker testClassesDirs = sourceSets.integrationTest.output.classesDirs 71*2167191dSAndroid Build Coastguard Worker useJUnitPlatform() 72*2167191dSAndroid Build Coastguard Worker} 73*2167191dSAndroid Build Coastguard Worker 74*2167191dSAndroid Build Coastguard Workertasks.named('check').configure { 75*2167191dSAndroid Build Coastguard Worker dependsOn integrationTest 76*2167191dSAndroid Build Coastguard Worker dependsOn integrationTestOnJava8 77*2167191dSAndroid Build Coastguard Worker} 78