Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 4 | |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 5 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 6 | import net.ltgt.gradle.errorprone.CheckSeverity |
Jean-Marie Henaff | 34d85f7 | 2017-06-14 10:32:04 +0200 | [diff] [blame] | 7 | import org.gradle.internal.os.OperatingSystem |
Ian Zerny | b2d27c4 | 2019-02-20 09:09:41 +0100 | [diff] [blame] | 8 | import tasks.DownloadDependency |
Ivan Gavrilovic | 635c7e5 | 2017-12-01 15:10:45 +0000 | [diff] [blame] | 9 | import tasks.GetJarsFromConfiguration |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 10 | import utils.Utils |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 11 | |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 12 | buildscript { |
| 13 | repositories { |
Rico Wind | 23a0511 | 2019-03-27 08:00:44 +0100 | [diff] [blame] | 14 | maven { |
| 15 | url 'http://storage.googleapis.com/r8-deps/maven_mirror/' |
| 16 | } |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 17 | mavenCentral() |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 18 | maven { |
| 19 | url "https://plugins.gradle.org/m2/" |
| 20 | } |
Morten Krogh-Jespersen | 68cc4b6 | 2019-03-21 10:32:17 +0100 | [diff] [blame] | 21 | jcenter() |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 22 | } |
| 23 | dependencies { |
| 24 | classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | plugins { |
| 29 | id "net.ltgt.errorprone" version "0.7" |
| 30 | } |
| 31 | |
| 32 | apply plugin: 'java' |
| 33 | apply plugin: 'idea' |
| 34 | |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 35 | ext { |
| 36 | androidSupportVersion = '25.4.0' |
clementbera | 45cea0a | 2019-04-09 09:26:57 +0200 | [diff] [blame] | 37 | asmVersion = '7.1' |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 38 | espressoVersion = '3.0.0' |
| 39 | fastutilVersion = '7.2.0' |
| 40 | guavaVersion = '23.0' |
| 41 | joptSimpleVersion = '4.6' |
Mads Ager | 48dd79e | 2018-05-15 09:13:55 +0200 | [diff] [blame] | 42 | gsonVersion = '2.7' |
Morten Krogh-Jespersen | 94ff676 | 2019-03-20 14:45:23 +0100 | [diff] [blame] | 43 | junitVersion = '4.13-beta-2' |
Jinseong Jeon | e11145f | 2018-12-13 10:57:29 -0800 | [diff] [blame] | 44 | mockitoVersion = '2.10.0' |
Jinseong Jeon | 46146f4 | 2018-12-16 23:26:14 -0800 | [diff] [blame] | 45 | kotlinVersion = '1.3.11' |
Jinseong Jeon | b6fe4fe | 2018-12-03 00:49:13 -0800 | [diff] [blame] | 46 | kotlinExtMetadataJVMVersion = '0.0.4' |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 47 | smaliVersion = '2.2b4' |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 48 | errorproneVersion = '2.3.2' |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 49 | } |
| 50 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 51 | apply from: 'copyAdditionalJctfCommonFiles.gradle' |
| 52 | |
| 53 | repositories { |
Rico Wind | 23a0511 | 2019-03-27 08:00:44 +0100 | [diff] [blame] | 54 | maven { |
| 55 | url 'http://storage.googleapis.com/r8-deps/maven_mirror/' |
| 56 | } |
Yohann Roussel | 126f687 | 2017-08-03 16:25:32 +0200 | [diff] [blame] | 57 | maven { url 'https://maven.google.com' } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 58 | mavenCentral() |
Morten Krogh-Jespersen | e45b0f9 | 2019-03-21 09:56:19 +0100 | [diff] [blame] | 59 | maven { url 'https://kotlin.bintray.com/kotlinx' } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 60 | } |
| 61 | |
Jinseong Jeon | 05064e1 | 2018-07-03 00:21:12 -0700 | [diff] [blame] | 62 | if (project.hasProperty('with_code_coverage')) { |
| 63 | apply plugin: 'jacoco' |
| 64 | } |
| 65 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 66 | // Custom source set for example tests and generated tests. |
| 67 | sourceSets { |
| 68 | test { |
| 69 | java { |
| 70 | srcDirs = [ |
clementbera | 0fe940d | 2019-04-23 12:45:18 +0200 | [diff] [blame] | 71 | 'src/test/java', |
| 72 | 'build/generated/test/java', |
| 73 | ] |
| 74 | } |
| 75 | } |
Yohann Roussel | bb57162 | 2017-11-09 10:47:36 +0100 | [diff] [blame] | 76 | apiUsageSample { |
| 77 | java { |
Mathias Rav | e3f3c52 | 2018-05-30 08:22:17 +0200 | [diff] [blame] | 78 | srcDirs = ['src/test/apiUsageSample', 'src/main/java'] |
| 79 | include 'com/android/tools/apiusagesample/*.java' |
| 80 | include 'com/android/tools/r8/BaseCompilerCommandParser.java' |
| 81 | include 'com/android/tools/r8/D8CommandParser.java' |
| 82 | include 'com/android/tools/r8/R8CommandParser.java' |
| 83 | include 'com/android/tools/r8/utils/FlagFile.java' |
Yohann Roussel | bb57162 | 2017-11-09 10:47:36 +0100 | [diff] [blame] | 84 | } |
Yohann Roussel | bb57162 | 2017-11-09 10:47:36 +0100 | [diff] [blame] | 85 | } |
Morten Krogh-Jespersen | 7bc93dc | 2019-01-29 09:53:08 +0100 | [diff] [blame] | 86 | cfSegments { |
| 87 | java { |
| 88 | srcDirs = ['third_party/classlib/java', 'src/cf_segments/java'] |
| 89 | } |
| 90 | output.resourcesDir = 'build/classes/cfSegments' |
| 91 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 92 | debugTestResources { |
| 93 | java { |
| 94 | srcDirs = ['src/test/debugTestResources'] |
| 95 | } |
| 96 | output.resourcesDir = 'build/classes/debugTestResources' |
| 97 | } |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 98 | debugTestResourcesJava8 { |
| 99 | java { |
| 100 | srcDirs = ['src/test/debugTestResourcesJava8'] |
| 101 | } |
| 102 | output.resourcesDir = 'build/classes/debugTestResourcesJava8' |
| 103 | } |
Sebastien Hertz | 1d7702b | 2017-08-18 09:07:27 +0200 | [diff] [blame] | 104 | debugTestResourcesKotlin { |
| 105 | java { |
| 106 | srcDirs = ['src/test/debugTestResourcesKotlin'] |
| 107 | } |
| 108 | output.resourcesDir = 'build/classes/debugTestResourcesKotlin' |
| 109 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 110 | examples { |
| 111 | java { |
Ivan Gavrilovic | 664f34d | 2018-11-09 10:02:40 -0800 | [diff] [blame] | 112 | srcDirs = ['src/test/examples'] |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 113 | } |
| 114 | output.resourcesDir = 'build/classes/examples' |
| 115 | } |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 116 | examplesJava9 { |
| 117 | java { |
| 118 | srcDirs = [ |
| 119 | 'src/test/examplesJava9' |
| 120 | ] |
| 121 | } |
| 122 | } |
| 123 | examplesJava11 { |
| 124 | java { |
| 125 | srcDirs = [ |
| 126 | 'src/test/examplesJava11' |
| 127 | ] |
| 128 | } |
| 129 | } |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 130 | examplesKotlin { |
| 131 | java { |
| 132 | srcDirs = ['src/test/examplesKotlin'] |
| 133 | } |
| 134 | output.resourcesDir = 'build/classes/examplesKotlin' |
| 135 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 136 | examplesAndroidN { |
| 137 | java { |
| 138 | srcDirs = ['src/test/examplesAndroidN'] |
| 139 | } |
| 140 | output.resourcesDir = 'build/classes/examplesAndroidN' |
| 141 | } |
| 142 | examplesAndroidO { |
| 143 | java { |
| 144 | srcDirs = ['src/test/examplesAndroidO'] |
| 145 | } |
| 146 | output.resourcesDir = 'build/classes/examplesAndroidO' |
| 147 | } |
Mikaël Peltier | 7b7b53a | 2017-10-09 13:33:21 +0200 | [diff] [blame] | 148 | examplesAndroidP { |
| 149 | java { |
| 150 | srcDirs = ['src/test/examplesAndroidP'] |
| 151 | } |
| 152 | output.resourcesDir = 'build/classes/examplesAndroidP' |
| 153 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 154 | jctfCommon { |
| 155 | java { |
| 156 | srcDirs = [ |
| 157 | 'third_party/jctf/Harness/src', |
| 158 | 'third_party/jctf/LibTests/src/com/google/jctf/test/categories', |
| 159 | 'third_party/jctf/LibTests/src/com/google/jctf/test/helper', |
| 160 | 'third_party/jctf/LibTests/src/com/google/jctf/testHelpers', |
| 161 | 'third_party/jctf/LibTests/src/org', |
| 162 | 'build/additionalJctfCommonFiles' |
| 163 | ] |
| 164 | } |
| 165 | resources { |
| 166 | srcDirs = ['third_party/jctf/LibTests/resources'] |
| 167 | } |
| 168 | } |
| 169 | jctfTests { |
| 170 | java { |
| 171 | srcDirs = [ |
| 172 | 'third_party/jctf/LibTests/src/com/google/jctf/test/lib', |
| 173 | // 'third_party/jctf/VMTests/src', |
| 174 | ] |
| 175 | } |
| 176 | } |
Sebastien Hertz | d331377 | 2018-01-16 14:12:37 +0100 | [diff] [blame] | 177 | kotlinR8TestResources { |
| 178 | java { |
| 179 | srcDirs = ['src/test/kotlinR8TestResources'] |
| 180 | } |
| 181 | output.resourcesDir = 'build/classes/kotlinR8TestResources' |
| 182 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 183 | } |
| 184 | |
Ivan Gavrilovic | 22790f3 | 2018-11-07 17:34:38 -0800 | [diff] [blame] | 185 | // Ensure importing into IntelliJ IDEA use the same output directories as Gradle. In tests we |
| 186 | // use the output path for tests (ultimately through ToolHelper.getClassPathForTests()) and |
| 187 | // therefore these paths need to be the same. See https://youtrack.jetbrains.com/issue/IDEA-175172 |
| 188 | // for context. |
| 189 | idea { |
| 190 | sourceSets.all { SourceSet sources -> |
| 191 | module { |
| 192 | if (sources.name == "main") { |
| 193 | sourceDirs += sources.java.srcDirs |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 194 | outputDir sources.output.classesDirs[0] |
Ivan Gavrilovic | 22790f3 | 2018-11-07 17:34:38 -0800 | [diff] [blame] | 195 | } else { |
| 196 | testSourceDirs += sources.java.srcDirs |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 197 | testOutputDir sources.output.classesDirs[0] |
Ivan Gavrilovic | 22790f3 | 2018-11-07 17:34:38 -0800 | [diff] [blame] | 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
Yohann Roussel | 126f687 | 2017-08-03 16:25:32 +0200 | [diff] [blame] | 203 | configurations { |
| 204 | supportLibs |
| 205 | } |
| 206 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 207 | dependencies { |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 208 | implementation "net.sf.jopt-simple:jopt-simple:$joptSimpleVersion" |
| 209 | implementation "com.google.code.gson:gson:$gsonVersion" |
Mads Ager | 0aa4805 | 2017-09-15 12:39:15 +0200 | [diff] [blame] | 210 | // Include all of guava when compiling the code, but exclude annotations that we don't |
| 211 | // need from the packaging. |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 212 | compileOnly("com.google.guava:guava:$guavaVersion") |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 213 | implementation("com.google.guava:guava:$guavaVersion", { |
Mads Ager | 0aa4805 | 2017-09-15 12:39:15 +0200 | [diff] [blame] | 214 | exclude group: 'com.google.errorprone' |
| 215 | exclude group: 'com.google.code.findbugs' |
| 216 | exclude group: 'com.google.j2objc' |
| 217 | exclude group: 'org.codehaus.mojo' |
| 218 | }) |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 219 | implementation group: 'it.unimi.dsi', name: 'fastutil', version: fastutilVersion |
| 220 | implementation "org.jetbrains.kotlinx:kotlinx-metadata-jvm:$kotlinExtMetadataJVMVersion" |
| 221 | implementation group: 'org.ow2.asm', name: 'asm', version: asmVersion |
| 222 | implementation group: 'org.ow2.asm', name: 'asm-commons', version: asmVersion |
| 223 | implementation group: 'org.ow2.asm', name: 'asm-tree', version: asmVersion |
| 224 | implementation group: 'org.ow2.asm', name: 'asm-analysis', version: asmVersion |
| 225 | implementation group: 'org.ow2.asm', name: 'asm-util', version: asmVersion |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 226 | testCompile sourceSets.examples.output |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 227 | testCompile "junit:junit:$junitVersion" |
| 228 | testCompile group: 'org.smali', name: 'smali', version: smaliVersion |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 229 | testCompile files('third_party/jasmin/jasmin-2.4.jar') |
| 230 | testCompile files('third_party/jdwp-tests/apache-harmony-jdwp-tests-host.jar') |
Jean-Marie Henaff | ce162f3 | 2017-10-04 10:39:27 +0200 | [diff] [blame] | 231 | testCompile files('third_party/ddmlib/ddmlib.jar') |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 232 | jctfCommonCompile "junit:junit:$junitVersion" |
| 233 | jctfTestsCompile "junit:junit:$junitVersion" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 234 | jctfTestsCompile sourceSets.jctfCommon.output |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 235 | examplesAndroidOCompile group: 'org.ow2.asm', name: 'asm', version: asmVersion |
| 236 | examplesAndroidPCompile group: 'org.ow2.asm', name: 'asm', version: asmVersion |
Stephan Herhut | 52cb102 | 2017-10-24 15:10:41 +0200 | [diff] [blame] | 237 | // Import Guava for @Nullable annotation |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 238 | examplesCompile "com.google.guava:guava:$guavaVersion" |
Jinseong Jeon | e11145f | 2018-12-13 10:57:29 -0800 | [diff] [blame] | 239 | examplesCompile "junit:junit:$junitVersion" |
| 240 | examplesCompile "org.mockito:mockito-core:$mockitoVersion" |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 241 | supportLibs "com.android.support:support-v4:$androidSupportVersion" |
| 242 | supportLibs "junit:junit:$junitVersion" |
| 243 | supportLibs "com.android.support.test.espresso:espresso-core:$espressoVersion" |
Yohann Roussel | bb57162 | 2017-11-09 10:47:36 +0100 | [diff] [blame] | 244 | apiUsageSampleCompile sourceSets.main.output |
Tamas Kenez | b865eee | 2018-12-03 16:50:45 +0100 | [diff] [blame] | 245 | apiUsageSampleCompile "com.google.guava:guava:$guavaVersion" |
Sebastien Hertz | 143ed11 | 2018-02-13 14:26:41 +0100 | [diff] [blame] | 246 | debugTestResourcesKotlinCompileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" |
| 247 | examplesKotlinCompileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" |
| 248 | kotlinR8TestResourcesCompileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 249 | errorprone("com.google.errorprone:error_prone_core:$errorproneVersion") |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 250 | } |
| 251 | |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 252 | def r8LibPath = "$buildDir/libs/r8lib.jar" |
Morten Krogh-Jespersen | cae32a7 | 2019-01-11 11:02:19 +0100 | [diff] [blame] | 253 | def r8LibExludeDepsPath = "$buildDir/libs/r8lib-exclude-deps.jar" |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 254 | def r8LibGeneratedKeepRulesPath = "$buildDir/generated/keep.txt" |
Morten Krogh-Jespersen | cae32a7 | 2019-01-11 11:02:19 +0100 | [diff] [blame] | 255 | def r8LibGeneratedKeepRulesExcludeDepsPath = "$buildDir/generated/keep-exclude-deps.txt" |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 256 | def r8LibTestPath = "$buildDir/classes/r8libtest" |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 257 | |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 258 | def osString = OperatingSystem.current().isLinux() ? "linux" : |
| 259 | OperatingSystem.current().isMacOsX() ? "mac" : "windows" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 260 | |
| 261 | def cloudDependencies = [ |
| 262 | "tests" : [ |
mikaelpeltier | c2aa665 | 2017-10-06 12:53:37 +0200 | [diff] [blame] | 263 | "2017-10-04/art", |
Rico Wind | 132bfb4 | 2019-03-08 09:27:36 +0100 | [diff] [blame] | 264 | "2016-12-19/art" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 265 | ], |
| 266 | "third_party": [ |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 267 | "android_cts_baseline", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 268 | "android_jar/lib-v14", |
Stephan Herhut | b3aca8b | 2017-12-22 14:14:53 +0100 | [diff] [blame] | 269 | "android_jar/lib-v15", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 270 | "android_jar/lib-v19", |
| 271 | "android_jar/lib-v21", |
Stephan Herhut | d48be0d | 2018-01-04 15:33:10 +0100 | [diff] [blame] | 272 | "android_jar/lib-v22", |
| 273 | "android_jar/lib-v23", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 274 | "android_jar/lib-v24", |
| 275 | "android_jar/lib-v25", |
| 276 | "android_jar/lib-v26", |
Søren Gjesse | c2ffae8 | 2018-12-21 12:20:18 +0100 | [diff] [blame] | 277 | "android_jar/lib-v27", |
| 278 | "android_jar/lib-v28", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 279 | "core-lambda-stubs", |
| 280 | "dart-sdk", |
| 281 | "ddmlib", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 282 | "gradle/gradle", |
Morten Krogh-Jespersen | 72f5dff | 2018-10-12 15:27:39 +0200 | [diff] [blame] | 283 | "jacoco", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 284 | "jasmin", |
| 285 | "jctf", |
Morten Krogh-Jespersen | 4187e16 | 2019-03-25 13:19:17 +0100 | [diff] [blame] | 286 | "junit", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 287 | "jdwp-tests", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 288 | "kotlin", |
Mathias Rav | 5285faf | 2018-03-20 14:16:32 +0100 | [diff] [blame] | 289 | "openjdk/openjdk-rt-1.8", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 290 | "proguard/proguard5.2.1", |
| 291 | "proguard/proguard6.0.1", |
Mathias Rav | 891831f | 2018-04-26 14:51:18 +0200 | [diff] [blame] | 292 | "r8", |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 293 | ], |
| 294 | // All dex-vms have a fixed OS of Linux, as they are only supported on Linux, and will be run in a Docker |
| 295 | // container on other platforms where supported. |
| 296 | "tools" : [ |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 297 | "linux/art", |
| 298 | "linux/art-5.1.1", |
| 299 | "linux/art-6.0.1", |
| 300 | "linux/art-7.0.0", |
Søren Gjesse | 1528c02 | 2018-11-23 15:14:05 +0100 | [diff] [blame] | 301 | "linux/art-8.1.0", |
Søren Gjesse | fe7c011 | 2018-12-03 12:33:12 +0100 | [diff] [blame] | 302 | "linux/art-9.0.0", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 303 | "linux/dalvik", |
Stephan Herhut | 02f0f9d | 2018-01-04 10:27:31 +0100 | [diff] [blame] | 304 | "linux/dalvik-4.0.4", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 305 | "${osString}/dx", |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 306 | ] |
| 307 | ] |
| 308 | |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 309 | def cloudSystemDependencies = [ |
| 310 | linux: [ |
clementbera | 81738ec | 2019-04-11 11:32:31 +0200 | [diff] [blame] | 311 | "third_party": ["openjdk/openjdk-9.0.4/linux", |
clementbera | b4fa18d | 2019-04-12 09:09:40 +0200 | [diff] [blame] | 312 | "openjdk/jdk8/linux-x86", |
| 313 | "openjdk/jdk-11/Linux"], |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 314 | ], |
| 315 | osx: [ |
clementbera | 81738ec | 2019-04-11 11:32:31 +0200 | [diff] [blame] | 316 | "third_party": ["openjdk/openjdk-9.0.4/osx", |
clementbera | b4fa18d | 2019-04-12 09:09:40 +0200 | [diff] [blame] | 317 | "openjdk/jdk8/darwin-x86", |
| 318 | "openjdk/jdk-11/Mac"], |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 319 | ], |
| 320 | windows: [ |
clementbera | b4fa18d | 2019-04-12 09:09:40 +0200 | [diff] [blame] | 321 | "third_party": ["openjdk/openjdk-9.0.4/windows", |
| 322 | "openjdk/jdk-11/Windows"], |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 323 | ], |
| 324 | ] |
| 325 | |
| 326 | if (OperatingSystem.current().isWindows()) { |
| 327 | cloudSystemDependencies.windows.each { entry -> |
| 328 | cloudDependencies.get(entry.key).addAll(entry.value) |
| 329 | } |
| 330 | } else if (OperatingSystem.current().isLinux()) { |
| 331 | cloudSystemDependencies.linux.each { entry -> |
| 332 | cloudDependencies.get(entry.key).addAll(entry.value) |
| 333 | } |
| 334 | } else if (OperatingSystem.current().isMacOsX()) { |
| 335 | cloudSystemDependencies.osx.each { entry -> |
| 336 | cloudDependencies.get(entry.key).addAll(entry.value) |
| 337 | } |
| 338 | } else { |
| 339 | println "WARNING: Unsupported system: " + OperatingSystem.current() |
| 340 | } |
| 341 | |
| 342 | def getDownloadDepsTaskName(entryKey, entryFile) { |
| 343 | return "download_deps_${entryKey}_${entryFile.replace('/', '_').replace('\\', '_')}" |
| 344 | } |
| 345 | |
Ian Zerny | b2d27c4 | 2019-02-20 09:09:41 +0100 | [diff] [blame] | 346 | def getFetchDepsTaskName(entryKey, entryFile) { |
| 347 | return "fetch_deps_${entryKey}_${entryFile.replace('/', '_').replace('\\', '_')}" |
| 348 | } |
| 349 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 350 | cloudDependencies.each { entry -> |
| 351 | entry.value.each { entryFile -> |
Ian Zerny | b2d27c4 | 2019-02-20 09:09:41 +0100 | [diff] [blame] | 352 | task "${getDownloadDepsTaskName(entry.key, entryFile)}"(type: DownloadDependency) { |
| 353 | type DownloadDependency.Type.GOOGLE_STORAGE |
| 354 | dependency "${entry.key}/${entryFile}" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | def x20Dependencies = [ |
| 360 | "third_party": [ |
Rico Wind | c346c4a | 2018-10-23 08:04:16 +0200 | [diff] [blame] | 361 | "benchmarks/kotlin-benches", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 362 | "chrome", |
Morten Krogh-Jespersen | 7bc93dc | 2019-01-29 09:53:08 +0100 | [diff] [blame] | 363 | "classlib", |
Morten Krogh-Jespersen | 480784d | 2019-02-05 08:10:46 +0100 | [diff] [blame] | 364 | "cf_segments", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 365 | "desugar/desugar_20180308", |
Ian Zerny | bd2fdcc | 2019-03-22 13:57:21 +0100 | [diff] [blame] | 366 | "internal/issue-127524985", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 367 | "framework", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 368 | "gmail/gmail_android_170604.16", |
Søren Gjesse | b552e84 | 2018-09-28 12:17:29 +0200 | [diff] [blame] | 369 | "gmail/gmail_android_180826.15", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 370 | "gmscore/gmscore_v10", |
| 371 | "gmscore/gmscore_v9", |
| 372 | "gmscore/latest", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 373 | "gmscore/v4", |
| 374 | "gmscore/v5", |
| 375 | "gmscore/v6", |
| 376 | "gmscore/v7", |
| 377 | "gmscore/v8", |
Christoffer Quist Adamsen | a2a5877 | 2018-10-03 09:47:46 +0200 | [diff] [blame] | 378 | "nest/nest_20180926_7c6cfb", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 379 | "photos/2017-06-06", |
Rico Wind | f72fa15 | 2018-10-22 15:41:03 +0200 | [diff] [blame] | 380 | "proguard/proguard_internal_159423826", |
| 381 | "proguardsettings", |
Sebastien Hertz | f83b590 | 2017-10-02 11:55:41 +0200 | [diff] [blame] | 382 | "youtube/youtube.android_12.10", |
| 383 | "youtube/youtube.android_12.17", |
| 384 | "youtube/youtube.android_12.22", |
Søren Gjesse | fe2de55 | 2018-09-24 16:31:10 +0200 | [diff] [blame] | 385 | "youtube/youtube.android_13.37", |
Rico Wind | 5acd2b6 | 2019-05-10 08:29:01 +0200 | [diff] [blame] | 386 | "youtube/youtube.android_14.19" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 387 | ], |
| 388 | ] |
| 389 | |
| 390 | x20Dependencies.each { entry -> |
| 391 | entry.value.each { entryFile -> |
Ian Zerny | b2d27c4 | 2019-02-20 09:09:41 +0100 | [diff] [blame] | 392 | task "${getDownloadDepsTaskName(entry.key, entryFile)}"(type: DownloadDependency) { |
| 393 | type DownloadDependency.Type.X20 |
| 394 | dependency "${entry.key}/${entryFile}" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
Rico Wind | 897bb71 | 2017-05-23 10:44:29 +0200 | [diff] [blame] | 399 | task downloadProguard { |
| 400 | cloudDependencies.each { entry -> |
| 401 | entry.value.each { entryFile -> |
| 402 | if (entryFile.contains("proguard")) { |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 403 | dependsOn "${getDownloadDepsTaskName(entry.key, entryFile)}" |
Rico Wind | 897bb71 | 2017-05-23 10:44:29 +0200 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
Rico Wind | f6c74ce | 2018-12-04 08:50:55 +0100 | [diff] [blame] | 409 | task downloadOpenJDKrt { |
| 410 | cloudDependencies.each { entry -> |
| 411 | entry.value.each { entryFile -> |
| 412 | if (entryFile.contains("openjdk-rt")) { |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 413 | dependsOn "${getDownloadDepsTaskName(entry.key, entryFile)}" |
Rico Wind | f6c74ce | 2018-12-04 08:50:55 +0100 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
Tamas Kenez | 427205b | 2017-06-29 15:57:09 +0200 | [diff] [blame] | 419 | task downloadDx { |
| 420 | cloudDependencies.each { entry -> |
| 421 | entry.value.each { entryFile -> |
Tamas Kenez | cea7c20 | 2017-10-13 10:53:32 +0200 | [diff] [blame] | 422 | if (entryFile.endsWith("/dx")) { |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 423 | dependsOn "${getDownloadDepsTaskName(entry.key, entryFile)}" |
Tamas Kenez | 427205b | 2017-06-29 15:57:09 +0200 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | } |
| 427 | } |
| 428 | |
Tamas Kenez | 0e10c56 | 2017-06-08 10:00:34 +0200 | [diff] [blame] | 429 | task downloadAndroidCts { |
| 430 | cloudDependencies.each { entry -> |
| 431 | entry.value.each { entryFile -> |
| 432 | if (entryFile.contains("android_cts_baseline")) { |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 433 | dependsOn "${getDownloadDepsTaskName(entry.key, entryFile)}" |
Tamas Kenez | 0e10c56 | 2017-06-08 10:00:34 +0200 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 439 | task downloadDeps { |
| 440 | cloudDependencies.each { entry -> |
| 441 | entry.value.each { entryFile -> |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 442 | dependsOn "${getDownloadDepsTaskName(entry.key, entryFile)}" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | if (!project.hasProperty('no_internal')) { |
| 446 | x20Dependencies.each { entry -> |
| 447 | entry.value.each { entryFile -> |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 448 | dependsOn "${getDownloadDepsTaskName(entry.key, entryFile)}" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 449 | } |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | allprojects { |
| 455 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 456 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 457 | } |
| 458 | |
Rico Wind | 266336c | 2019-02-25 10:11:38 +0100 | [diff] [blame] | 459 | // TODO(ricow): Remove debug prints |
| 460 | println("NOTE: Current operating system: " + OperatingSystem.current()) |
| 461 | println("NOTE: Current operating system isWindows: " + OperatingSystem.current().isWindows()) |
| 462 | |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 463 | // Check if running with the JDK location from tools/jdk.py. |
| 464 | if (OperatingSystem.current().isWindows()) { |
| 465 | println "NOTE: Running with JDK: " + org.gradle.internal.jvm.Jvm.current().javaHome |
| 466 | } else { |
| 467 | def javaHomeOut = new StringBuilder() |
| 468 | def javaHomeErr = new StringBuilder() |
| 469 | def javaHomeProc = './tools/jdk.py'.execute() |
| 470 | javaHomeProc.waitForProcessOutput(javaHomeOut, javaHomeErr) |
| 471 | def jdkHome = new File(javaHomeOut.toString().trim()) |
| 472 | if (!jdkHome.exists()) { |
| 473 | println "WARNING: Failed to find the ./tools/jdk.py specified JDK: " + jdkHome |
| 474 | } else if (jdkHome != org.gradle.internal.jvm.Jvm.current().javaHome) { |
| 475 | println("WARNING: Gradle is running in a non-pinned Java" |
| 476 | + ". Gradle Java Home: " + org.gradle.internal.jvm.Jvm.current().javaHome |
| 477 | + ". Expected: " + jdkHome) |
Rico Wind | 266336c | 2019-02-25 10:11:38 +0100 | [diff] [blame] | 478 | } else { |
| 479 | println("NOTE: Running with jdk from tools/jdk.py: " + jdkHome) |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 480 | } |
Mads Ager | c7d14d3 | 2018-09-27 11:09:46 +0200 | [diff] [blame] | 481 | } |
| 482 | |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 483 | sourceSets.configureEach { sourceSet -> |
| 484 | tasks.named(sourceSet.compileJavaTaskName).configure { |
| 485 | // Default disable errorprone (enabled and setup below). |
| 486 | options.errorprone.enabled = false |
| 487 | options.compilerArgs << '-Xlint:unchecked' |
Ian Zerny | 09135aa | 2019-02-12 16:03:34 +0100 | [diff] [blame] | 488 | // Run all compilation tasks in a forked subprocess. |
| 489 | options.fork = true |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 490 | // Javac often runs out of stack space when compiling the tests. |
| 491 | // Increase the stack size for the javac process. |
Ian Zerny | 09135aa | 2019-02-12 16:03:34 +0100 | [diff] [blame] | 492 | options.forkOptions.jvmArgs << "-Xss4m" |
Ian Zerny | 26307fb | 2019-03-06 15:18:17 +0100 | [diff] [blame] | 493 | // Test compilation is sometimes hitting the default limit at 1g, increase it. |
| 494 | options.forkOptions.jvmArgs << "-Xmx2g" |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 495 | // Set the bootclass path so compilation is consistent with 1.8 target compatibility. |
| 496 | options.forkOptions.jvmArgs << "-Xbootclasspath/a:third_party/openjdk/openjdk-rt-1.8/rt.jar" |
| 497 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 498 | } |
| 499 | |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 500 | tasks.named(sourceSets.examplesJava9.compileJavaTaskName).get().configure { |
| 501 | def jdkDir = 'third_party/openjdk/openjdk-9.0.4/' |
clementbera | 0fe940d | 2019-04-23 12:45:18 +0200 | [diff] [blame] | 502 | options.fork = true |
| 503 | options.forkOptions.jvmArgs = [] |
| 504 | if (OperatingSystem.current().isLinux()) { |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 505 | options.forkOptions.javaHome = file(jdkDir + 'linux') |
clementbera | 0fe940d | 2019-04-23 12:45:18 +0200 | [diff] [blame] | 506 | } else if (OperatingSystem.current().isMacOsX()) { |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 507 | options.forkOptions.javaHome = file(jdkDir + 'osx') |
clementbera | 0fe940d | 2019-04-23 12:45:18 +0200 | [diff] [blame] | 508 | } else { |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 509 | options.forkOptions.javaHome = file(jdkDir + 'windows') |
| 510 | } |
| 511 | sourceCompatibility = JavaVersion.VERSION_1_9 |
| 512 | targetCompatibility = JavaVersion.VERSION_1_9 |
| 513 | } |
| 514 | |
| 515 | tasks.named(sourceSets.examplesJava11.compileJavaTaskName).get().configure { |
| 516 | def jdkDir = 'third_party/openjdk/jdk-11/' |
| 517 | options.fork = true |
| 518 | options.forkOptions.jvmArgs = [] |
| 519 | if (OperatingSystem.current().isLinux()) { |
| 520 | options.forkOptions.javaHome = file(jdkDir + 'Linux') |
| 521 | } else if (OperatingSystem.current().isMacOsX()) { |
| 522 | options.forkOptions.javaHome = file(jdkDir + 'Mac') |
| 523 | } else { |
| 524 | options.forkOptions.javaHome = file(jdkDir + 'Windows') |
clementbera | 0fe940d | 2019-04-23 12:45:18 +0200 | [diff] [blame] | 525 | } |
| 526 | sourceCompatibility = JavaVersion.VERSION_11 |
| 527 | targetCompatibility = JavaVersion.VERSION_11 |
| 528 | } |
| 529 | |
| 530 | |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 531 | if (!project.hasProperty('without_error_prone') && |
| 532 | // Don't enable error prone on Java 8 as the plugin setup does not support it. |
| 533 | !org.gradle.internal.jvm.Jvm.current().javaVersion.java8) { |
Mikaël Peltier | c9c1e8f | 2017-10-17 15:45:42 +0200 | [diff] [blame] | 534 | compileJava { |
| 535 | // Enable error prone for D8/R8 sources. |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 536 | options.errorprone.enabled = true |
| 537 | options.errorprone.disableAllChecks = true |
| 538 | options.errorprone.check('ClassCanBeStatic', CheckSeverity.ERROR) |
| 539 | options.errorprone.check('OperatorPrecedence', CheckSeverity.ERROR) |
| 540 | options.errorprone.check('RemoveUnusedImports', CheckSeverity.ERROR) |
| 541 | options.errorprone.check('MissingOverride', CheckSeverity.ERROR) |
| 542 | options.errorprone.check('IntLongMath', CheckSeverity.ERROR) |
| 543 | options.errorprone.check('EqualsHashCode', CheckSeverity.ERROR) |
| 544 | options.errorprone.check('InconsistentOverloads', CheckSeverity.ERROR) |
| 545 | options.errorprone.check('ArrayHashCode', CheckSeverity.ERROR) |
| 546 | options.errorprone.check('EqualsIncompatibleType', CheckSeverity.ERROR) |
| 547 | options.errorprone.check('NonOverridingEquals', CheckSeverity.ERROR) |
| 548 | options.errorprone.check('FallThrough', CheckSeverity.ERROR) |
| 549 | options.errorprone.check('MissingCasesInEnumSwitch', CheckSeverity.ERROR) |
| 550 | options.errorprone.check('MissingDefault', CheckSeverity.ERROR) |
| 551 | options.errorprone.check('MultipleTopLevelClasses', CheckSeverity.ERROR) |
| 552 | options.errorprone.check('NarrowingCompoundAssignment', CheckSeverity.ERROR) |
| 553 | options.errorprone.check('BoxedPrimitiveConstructor', CheckSeverity.ERROR) |
| 554 | options.errorprone.check('LogicalAssignment', CheckSeverity.ERROR) |
| 555 | options.errorprone.check('FloatCast', CheckSeverity.ERROR) |
| 556 | options.errorprone.check('ReturnValueIgnored', CheckSeverity.ERROR) |
Mikaël Peltier | c9c1e8f | 2017-10-17 15:45:42 +0200 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 560 | compileJctfCommonJava { |
| 561 | dependsOn 'copyAdditionalJctfCommonFiles' |
| 562 | options.compilerArgs = ['-Xlint:none'] |
| 563 | } |
| 564 | |
| 565 | compileJctfTestsJava { |
| 566 | dependsOn 'jctfCommonClasses' |
| 567 | options.compilerArgs = ['-Xlint:none'] |
| 568 | } |
| 569 | |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 570 | task consolidatedLicense { |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 571 | def license = new File(new File(buildDir, 'generatedLicense'), 'LICENSE') |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 572 | |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 573 | inputs.files files('LICENSE', 'LIBRARY-LICENSE') + fileTree(dir: 'library-licensing') |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 574 | def runtimeClasspath = configurations.findByName("runtimeClasspath") |
| 575 | inputs.files { runtimeClasspath.getResolvedConfiguration().files } |
| 576 | |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 577 | outputs.files license |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 578 | |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 579 | doLast { |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 580 | def dependencies = [] |
| 581 | runtimeClasspath.resolvedConfiguration.resolvedArtifacts.each { |
| 582 | def identifier = (ModuleComponentIdentifier) it.id.componentIdentifier |
| 583 | dependencies.add("${identifier.group}:${identifier.module}") |
| 584 | } |
| 585 | def libraryLicenses = file('LIBRARY-LICENSE').text |
| 586 | dependencies.each { |
| 587 | if (!libraryLicenses.contains("- artifact: $it")) { |
| 588 | throw new GradleException("No license for $it in LIBRARY_LICENSE") |
| 589 | } |
| 590 | } |
| 591 | |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 592 | license.getParentFile().mkdirs() |
| 593 | license.createNewFile() |
| 594 | license.text = "This file lists all licenses for code distributed.\n" |
| 595 | license.text += "All non-library code has the following 3-Clause BSD license.\n" |
| 596 | license.text += "\n" |
| 597 | license.text += "\n" |
| 598 | license.text += file('LICENSE').text |
| 599 | license.text += "\n" |
| 600 | license.text += "\n" |
| 601 | license.text += "Summary of distributed libraries:\n" |
| 602 | license.text += "\n" |
Mads Ager | d1d0da9 | 2018-12-10 13:56:50 +0100 | [diff] [blame] | 603 | license.text += libraryLicenses |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 604 | license.text += "\n" |
| 605 | license.text += "\n" |
| 606 | license.text += "Licenses details:\n" |
| 607 | fileTree(dir: 'library-licensing').getFiles().stream().sorted().forEach { file -> |
| 608 | license.text += "\n" |
| 609 | license.text += "\n" |
| 610 | license.text += file.text |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | |
Morten Krogh-Jespersen | 00699af | 2018-10-09 10:54:42 +0200 | [diff] [blame] | 615 | static mergeServiceFiles(ShadowJar task) { |
Jinseong Jeon | 40ceab0 | 2018-07-09 14:25:31 -0700 | [diff] [blame] | 616 | // Everything under META-INF is not included by default. |
| 617 | // Should include before 'relocate' so that the service file path and its content |
| 618 | // are properly relocated as well. |
| 619 | task.mergeServiceFiles { |
| 620 | include 'META-INF/services/*' |
| 621 | } |
Morten Krogh-Jespersen | 00699af | 2018-10-09 10:54:42 +0200 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | static configureRelocations(ShadowJar task) { |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 625 | task.relocate('com.google.common', 'com.android.tools.r8.com.google.common') |
Mads Ager | 48dd79e | 2018-05-15 09:13:55 +0200 | [diff] [blame] | 626 | task.relocate('com.google.gson', 'com.android.tools.r8.com.google.gson') |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 627 | task.relocate('com.google.thirdparty', 'com.android.tools.r8.com.google.thirdparty') |
| 628 | task.relocate('joptsimple', 'com.android.tools.r8.joptsimple') |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 629 | task.relocate('org.objectweb.asm', 'com.android.tools.r8.org.objectweb.asm') |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 630 | task.relocate('it.unimi.dsi.fastutil', 'com.android.tools.r8.it.unimi.dsi.fastutil') |
Søren Gjesse | 7c56085 | 2018-06-20 16:27:21 +0200 | [diff] [blame] | 631 | task.relocate('kotlin', 'com.android.tools.r8.jetbrains.kotlin') |
| 632 | task.relocate('kotlinx', 'com.android.tools.r8.jetbrains.kotlinx') |
| 633 | task.relocate('org.jetbrains', 'com.android.tools.r8.org.jetbrains') |
Søren Gjesse | 06ed132 | 2018-06-21 11:15:07 +0200 | [diff] [blame] | 634 | task.relocate('org.intellij', 'com.android.tools.r8.org.intellij') |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 635 | } |
| 636 | |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 637 | task repackageDepsNoRelocate(type: ShadowJar) { |
| 638 | configurations = [project.configurations.runtimeClasspath] |
| 639 | mergeServiceFiles(it) |
| 640 | exclude { it.getRelativePath().getPathString() == "module-info.class" } |
| 641 | exclude { it.getRelativePath().getPathString().startsWith("META-INF/maven/") } |
Morten Krogh-Jespersen | 54f196e | 2019-01-14 16:10:08 +0100 | [diff] [blame] | 642 | baseName 'deps-not-relocated' |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 643 | } |
| 644 | |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 645 | task repackageDeps(type: ShadowJar) { |
Mads Ager | 6477281 | 2018-12-10 14:21:10 +0100 | [diff] [blame] | 646 | configurations = [project.configurations.runtimeClasspath] |
Morten Krogh-Jespersen | 00699af | 2018-10-09 10:54:42 +0200 | [diff] [blame] | 647 | mergeServiceFiles(it) |
| 648 | if (!project.hasProperty('lib_no_relocate')) { |
| 649 | configureRelocations(it) |
| 650 | } |
Ivan Gavrilovic | 2afc0cc | 2018-07-09 14:31:55 +0100 | [diff] [blame] | 651 | exclude { it.getRelativePath().getPathString() == "module-info.class" } |
Jinseong Jeon | 40ceab0 | 2018-07-09 14:25:31 -0700 | [diff] [blame] | 652 | exclude { it.getRelativePath().getPathString().startsWith("META-INF/maven/") } |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 653 | baseName 'deps' |
| 654 | } |
| 655 | |
| 656 | task repackageSources(type: ShadowJar) { |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 657 | from sourceSets.main.output |
Morten Krogh-Jespersen | 00699af | 2018-10-09 10:54:42 +0200 | [diff] [blame] | 658 | mergeServiceFiles(it) |
| 659 | if (!project.hasProperty('lib_no_relocate')) { |
| 660 | configureRelocations(it) |
| 661 | } |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 662 | baseName 'sources' |
| 663 | } |
| 664 | |
Morten Krogh-Jespersen | 764f23a | 2018-12-10 15:47:11 +0100 | [diff] [blame] | 665 | task r8WithRelocatedDeps(type: ShadowJar) { |
Morten Krogh-Jespersen | e47021f | 2018-10-10 11:08:23 +0200 | [diff] [blame] | 666 | from consolidatedLicense.outputs.files |
Morten Krogh-Jespersen | 764f23a | 2018-12-10 15:47:11 +0100 | [diff] [blame] | 667 | baseName 'r8_with_relocated_deps' |
Morten Krogh-Jespersen | e47021f | 2018-10-10 11:08:23 +0200 | [diff] [blame] | 668 | classifier = null |
| 669 | version = null |
| 670 | manifest { |
| 671 | attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife' |
| 672 | } |
| 673 | from repackageSources.outputs.files |
Morten Krogh-Jespersen | 764f23a | 2018-12-10 15:47:11 +0100 | [diff] [blame] | 674 | from repackageDeps.outputs.files |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 675 | configureRelocations(it) |
Ian Zerny | 80533c9 | 2019-01-24 10:32:09 +0100 | [diff] [blame] | 676 | exclude "META-INF/*.kotlin_module" |
Morten Krogh-Jespersen | e47021f | 2018-10-10 11:08:23 +0200 | [diff] [blame] | 677 | } |
| 678 | |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 679 | task r8WithoutDeps(type: ShadowJar) { |
| 680 | from consolidatedLicense.outputs.files |
| 681 | baseName 'r8_without_deps' |
| 682 | classifier = null |
| 683 | version = null |
| 684 | manifest { |
| 685 | attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife' |
| 686 | } |
| 687 | from sourceSets.main.output |
| 688 | } |
| 689 | |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 690 | task R8(type: ShadowJar) { |
Yohann Roussel | 7f47c03 | 2017-09-14 12:19:06 +0200 | [diff] [blame] | 691 | from consolidatedLicense.outputs.files |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 692 | baseName 'r8' |
Mikaël Peltier | e5e5472 | 2017-08-18 12:01:59 +0200 | [diff] [blame] | 693 | classifier = null |
| 694 | version = null |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 695 | manifest { |
Mathias Rav | dd6a6de | 2018-05-18 10:18:33 +0200 | [diff] [blame] | 696 | attributes 'Main-Class': 'com.android.tools.r8.SwissArmyKnife' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 697 | } |
| 698 | // In order to build without dependencies, pass the exclude_deps property using: |
| 699 | // gradle -Pexclude_deps R8 |
| 700 | if (!project.hasProperty('exclude_deps')) { |
Gautam Korlam | ad356f2 | 2017-12-04 21:45:30 -0800 | [diff] [blame] | 701 | from repackageSources.outputs.files |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 702 | from repackageDeps.outputs.files |
Gautam Korlam | ad356f2 | 2017-12-04 21:45:30 -0800 | [diff] [blame] | 703 | } else { |
| 704 | from sourceSets.main.output |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 705 | } |
Ian Zerny | 80533c9 | 2019-01-24 10:32:09 +0100 | [diff] [blame] | 706 | exclude "META-INF/*.kotlin_module" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 707 | } |
| 708 | |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 709 | task R8NoManifestNoDeps(type: ShadowJar) { |
| 710 | from consolidatedLicense.outputs.files |
| 711 | baseName 'r8nomanifest-exclude-deps' |
| 712 | classifier = null |
| 713 | version = null |
| 714 | from sourceSets.main.output |
| 715 | } |
| 716 | |
Tamas Kenez | 8224fbc | 2018-12-10 09:57:56 +0100 | [diff] [blame] | 717 | task R8NoManifest(type: ShadowJar) { |
| 718 | from consolidatedLicense.outputs.files |
| 719 | baseName 'r8nomanifest' |
| 720 | classifier = null |
| 721 | version = null |
| 722 | // In order to build without dependencies, pass the exclude_deps property using: |
| 723 | // gradle -Pexclude_deps R8 |
| 724 | if (!project.hasProperty('exclude_deps')) { |
| 725 | from repackageSources.outputs.files |
| 726 | from repackageDeps.outputs.files |
| 727 | } else { |
| 728 | from sourceSets.main.output |
| 729 | } |
Ian Zerny | 80533c9 | 2019-01-24 10:32:09 +0100 | [diff] [blame] | 730 | exclude "META-INF/*.kotlin_module" |
Tamas Kenez | 8224fbc | 2018-12-10 09:57:56 +0100 | [diff] [blame] | 731 | } |
| 732 | |
Ivan Gavrilovic | 4876d2a | 2017-11-30 18:57:48 +0000 | [diff] [blame] | 733 | task D8(type: ShadowJar) { |
Mathias Rav | dd6a6de | 2018-05-18 10:18:33 +0200 | [diff] [blame] | 734 | from R8.outputs.files |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 735 | baseName 'd8' |
| 736 | manifest { |
mikaelpeltier | 8093931 | 2017-08-17 15:00:09 +0200 | [diff] [blame] | 737 | attributes 'Main-Class': 'com.android.tools.r8.D8' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 738 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 739 | } |
| 740 | |
Mathias Rav | dd6a6de | 2018-05-18 10:18:33 +0200 | [diff] [blame] | 741 | task CompatDx(type: ShadowJar) { |
| 742 | from R8.outputs.files |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 743 | baseName 'compatdx' |
| 744 | manifest { |
| 745 | attributes 'Main-Class': 'com.android.tools.r8.compatdx.CompatDx' |
| 746 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 747 | } |
| 748 | |
Mathias Rav | dd6a6de | 2018-05-18 10:18:33 +0200 | [diff] [blame] | 749 | task CompatProguard(type: ShadowJar) { |
| 750 | from R8.outputs.files |
Søren Gjesse | 1d21da7 | 2017-09-01 12:05:38 +0200 | [diff] [blame] | 751 | baseName 'compatproguard' |
| 752 | manifest { |
| 753 | attributes 'Main-Class': 'com.android.tools.r8.compatproguard.CompatProguard' |
| 754 | } |
Lars Bak | 44cef52 | 2017-08-10 16:02:39 +0200 | [diff] [blame] | 755 | } |
| 756 | |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 757 | def baseR8CommandLine(args = []) { |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 758 | // Execute r8 commands against a stable r8 with relocated dependencies. |
Rico Wind | cfb6551 | 2019-02-27 12:57:34 +0100 | [diff] [blame] | 759 | return [org.gradle.internal.jvm.Jvm.current().getJavaExecutable(), |
| 760 | "-ea", "-jar", r8WithRelocatedDeps.outputs.files[0]] + args |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 761 | } |
| 762 | |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 763 | def r8CfCommandLine(input, output, pgconf, args = [], libs = []) { |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 764 | return baseR8CommandLine([ |
| 765 | "--classfile", "--release", |
| 766 | input, |
| 767 | "--output", output, |
| 768 | "--pg-conf", pgconf, |
| 769 | "--pg-map-output", output + ".map", |
| 770 | "--lib", "third_party/openjdk/openjdk-rt-1.8/rt.jar" |
| 771 | ] + args + libs.collectMany { ["--lib", it] }) |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | def r8LibCreateTask(name, pgConf, r8Task, output, args = [], libs = []) { |
| 775 | return tasks.create("r8Lib${name}", Exec) { |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 776 | inputs.files ([pgConf, r8WithRelocatedDeps.outputs, r8Task.outputs]) |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 777 | outputs.file output |
| 778 | dependsOn downloadOpenJDKrt |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 779 | dependsOn r8WithRelocatedDeps |
| 780 | dependsOn r8Task |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 781 | commandLine r8CfCommandLine(r8Task.outputs.files[0], output, pgConf, args, libs) |
| 782 | workingDir = projectDir |
| 783 | } |
| 784 | } |
| 785 | |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 786 | task testJar(type: ShadowJar, dependsOn: testClasses) { |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 787 | baseName = "r8tests" |
| 788 | from sourceSets.test.output |
| 789 | } |
| 790 | |
Morten Krogh-Jespersen | cae32a7 | 2019-01-11 11:02:19 +0100 | [diff] [blame] | 791 | task testJarNoDeps(type: ShadowJar, dependsOn: testClasses) { |
| 792 | baseName = "r8tests-exclude-deps" |
| 793 | from sourceSets.test.output |
| 794 | } |
| 795 | |
| 796 | def generateR8LibKeepRules(name, r8Source, testSource, output) { |
| 797 | return tasks.create("generateR8LibKeepRules_" + name, Exec) { |
| 798 | doFirst { |
| 799 | standardOutput new FileOutputStream(output) |
| 800 | } |
| 801 | dependsOn r8WithRelocatedDeps |
| 802 | dependsOn r8Source |
| 803 | dependsOn testSource |
| 804 | dependsOn downloadOpenJDKrt |
| 805 | inputs.files ([r8WithRelocatedDeps.outputs, r8Source.outputs, testSource.outputs]) |
| 806 | outputs.file output |
| 807 | commandLine baseR8CommandLine([ |
| 808 | "printuses", |
| 809 | "--keeprules", |
| 810 | "third_party/openjdk/openjdk-rt-1.8/rt.jar", |
| 811 | r8Source.outputs.files[0], |
| 812 | testSource.outputs.files[0]]) |
| 813 | workingDir = projectDir |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 814 | } |
Morten Krogh-Jespersen | 4aa109f | 2018-12-21 13:27:51 +0100 | [diff] [blame] | 815 | } |
| 816 | |
Morten Krogh-Jespersen | cc5c7d0 | 2019-01-10 19:57:15 +0100 | [diff] [blame] | 817 | task R8LibApiOnly { |
| 818 | dependsOn r8LibCreateTask("Api", "src/main/keep.txt", R8NoManifest, r8LibPath) |
| 819 | outputs.file r8LibPath |
| 820 | } |
| 821 | |
Morten Krogh-Jespersen | b39fbe5 | 2018-12-17 14:58:48 +0100 | [diff] [blame] | 822 | task R8Lib { |
Morten Krogh-Jespersen | cae32a7 | 2019-01-11 11:02:19 +0100 | [diff] [blame] | 823 | def genRulesTask = generateR8LibKeepRules( |
| 824 | "Main", |
| 825 | R8NoManifest, |
| 826 | testJar, |
| 827 | r8LibGeneratedKeepRulesPath) |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 828 | dependsOn r8LibCreateTask( |
| 829 | "Main", |
| 830 | "src/main/keep.txt", |
| 831 | R8NoManifest, |
| 832 | r8LibPath, |
Morten Krogh-Jespersen | cae32a7 | 2019-01-11 11:02:19 +0100 | [diff] [blame] | 833 | ["--pg-conf", genRulesTask.outputs.files[0]] |
| 834 | ).dependsOn(genRulesTask) |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 835 | outputs.file r8LibPath |
Tamas Kenez | f960e9c | 2018-12-03 16:13:29 +0100 | [diff] [blame] | 836 | } |
| 837 | |
Morten Krogh-Jespersen | cae32a7 | 2019-01-11 11:02:19 +0100 | [diff] [blame] | 838 | task R8LibNoDeps { |
| 839 | def genRulesTask = generateR8LibKeepRules( |
| 840 | "NoDeps", |
| 841 | R8NoManifestNoDeps, |
| 842 | testJarNoDeps, |
| 843 | r8LibGeneratedKeepRulesExcludeDepsPath |
| 844 | ) |
| 845 | dependsOn r8LibCreateTask( |
| 846 | "NoDeps", |
| 847 | "src/main/keep.txt", |
| 848 | R8NoManifestNoDeps, |
| 849 | r8LibExludeDepsPath, |
| 850 | ["--pg-conf", genRulesTask.outputs.files[0]], |
| 851 | repackageDepsNoRelocate.outputs.files |
| 852 | ).dependsOn(repackageDepsNoRelocate, genRulesTask) |
| 853 | outputs.file r8LibExludeDepsPath |
| 854 | } |
| 855 | |
Morten Krogh-Jespersen | b39fbe5 | 2018-12-17 14:58:48 +0100 | [diff] [blame] | 856 | task CompatDxLib { |
| 857 | dependsOn r8LibCreateTask( |
| 858 | "CompatDx", "src/main/keep-compatdx.txt", CompatDx, "build/libs/compatdxlib.jar") |
Tamas Kenez | f960e9c | 2018-12-03 16:13:29 +0100 | [diff] [blame] | 859 | } |
| 860 | |
Morten Krogh-Jespersen | b39fbe5 | 2018-12-17 14:58:48 +0100 | [diff] [blame] | 861 | task CompatProguardLib { |
| 862 | dependsOn r8LibCreateTask( |
| 863 | "CompatPg", |
| 864 | "src/main/keep-compatproguard.txt", |
| 865 | CompatProguard, |
| 866 | "build/libs/compatproguardlib.jar") |
Tamas Kenez | f960e9c | 2018-12-03 16:13:29 +0100 | [diff] [blame] | 867 | } |
| 868 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 869 | task sourceJar(type: Jar, dependsOn: classes) { |
| 870 | classifier = 'src' |
| 871 | from sourceSets.main.allSource |
| 872 | } |
| 873 | |
| 874 | task jctfCommonJar(type: Jar) { |
| 875 | from sourceSets.jctfCommon.output |
| 876 | baseName 'jctfCommon' |
| 877 | } |
| 878 | |
| 879 | artifacts { |
| 880 | archives sourceJar |
| 881 | } |
| 882 | |
| 883 | task createArtTests(type: Exec) { |
| 884 | def outputDir = "build/generated/test/java/com/android/tools/r8/art" |
Mads Ager | 7e5bd72 | 2017-05-24 07:17:27 +0200 | [diff] [blame] | 885 | def createArtTestsScript = "tools/create_art_tests.py" |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 886 | inputs.files files("tests/2017-10-04/art.tar.gz", createArtTestsScript) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 887 | outputs.dir outputDir |
| 888 | dependsOn downloadDeps |
Mads Ager | 677e300 | 2017-05-24 07:54:51 +0200 | [diff] [blame] | 889 | commandLine "python", createArtTestsScript |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 890 | workingDir = projectDir |
| 891 | } |
| 892 | |
| 893 | task createJctfTests(type: Exec) { |
Stephan Herhut | ea6ee58 | 2017-05-23 13:14:34 +0200 | [diff] [blame] | 894 | def outputDir = "build/generated/test/java/com/android/tools/r8/jctf" |
Tamas Kenez | 25a99e9 | 2017-05-29 10:15:30 +0200 | [diff] [blame] | 895 | def script = "tools/create_jctf_tests.py" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 896 | inputs.file script |
| 897 | outputs.dir outputDir |
| 898 | dependsOn downloadDeps |
Tamas Kenez | 25a99e9 | 2017-05-29 10:15:30 +0200 | [diff] [blame] | 899 | commandLine "python", script |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 900 | workingDir = projectDir |
| 901 | } |
| 902 | |
| 903 | compileTestJava { |
| 904 | dependsOn createArtTests |
| 905 | dependsOn createJctfTests |
| 906 | } |
| 907 | |
Morten Krogh-Jespersen | 7bc93dc | 2019-01-29 09:53:08 +0100 | [diff] [blame] | 908 | task buildCfSegments(type: Jar, dependsOn: downloadDeps) { |
| 909 | from sourceSets.cfSegments.output |
| 910 | baseName 'cf_segments' |
| 911 | destinationDir file('build/libs') |
| 912 | } |
| 913 | |
Ian Zerny | ee23a17 | 2018-01-03 09:08:48 +0100 | [diff] [blame] | 914 | task buildD8ApiUsageSample(type: Jar) { |
| 915 | from sourceSets.apiUsageSample.output |
| 916 | baseName 'd8_api_usage_sample' |
| 917 | destinationDir file('tests') |
| 918 | } |
| 919 | |
Ian Zerny | 923a0c1 | 2018-01-03 10:59:18 +0100 | [diff] [blame] | 920 | task buildR8ApiUsageSample(type: Jar) { |
| 921 | from sourceSets.apiUsageSample.output |
| 922 | baseName 'r8_api_usage_sample' |
| 923 | destinationDir file('tests') |
| 924 | } |
| 925 | |
Yohann Roussel | 548ae94 | 2018-01-05 11:13:28 +0100 | [diff] [blame] | 926 | task buildApiSampleJars { |
Yohann Roussel | 548ae94 | 2018-01-05 11:13:28 +0100 | [diff] [blame] | 927 | dependsOn buildD8ApiUsageSample |
| 928 | dependsOn buildR8ApiUsageSample |
| 929 | } |
| 930 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 931 | task buildDebugInfoExamplesDex { |
| 932 | def examplesDir = file("src/test/java") |
| 933 | def hostJar = "debuginfo_examples.jar" |
| 934 | def hostDexJar = "debuginfo_examples_dex.jar" |
| 935 | task "compile_debuginfo_examples"(type: JavaCompile) { |
| 936 | source = fileTree(dir: examplesDir, include: "com/android/tools/r8/debuginfo/*Test.java") |
| 937 | destinationDir = file("build/test/debuginfo_examples/classes") |
| 938 | classpath = sourceSets.main.compileClasspath |
| 939 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 940 | targetCompatibility = JavaVersion.VERSION_1_7 |
| 941 | options.compilerArgs += ["-Xlint:-options"] |
| 942 | } |
| 943 | task "jar_debuginfo_examples"(type: Jar, dependsOn: "compile_debuginfo_examples") { |
| 944 | archiveName = hostJar |
| 945 | destinationDir = file("build/test/") |
| 946 | from "build/test/debuginfo_examples/classes" |
| 947 | include "**/*.class" |
| 948 | } |
| 949 | task "dex_debuginfo_examples"(type: Exec, |
| 950 | dependsOn: ["jar_debuginfo_examples", "downloadDeps"]) { |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 951 | if (OperatingSystem.current().isWindows()) { |
| 952 | executable file("tools/windows/dx/bin/dx.bat") |
Jinseong Jeon | 35a1eff | 2017-09-24 23:28:08 -0700 | [diff] [blame] | 953 | } else if (OperatingSystem.current().isMacOsX()) { |
| 954 | executable file("tools/mac/dx/bin/dx"); |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 955 | } else { |
| 956 | executable file("tools/linux/dx/bin/dx"); |
| 957 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 958 | args "--dex" |
| 959 | args "--output=build/test/${hostDexJar}" |
| 960 | args "build/test/${hostJar}" |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 961 | inputs.files files("build/test/${hostJar}") |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 962 | outputs.file file("build/test/${hostDexJar}") |
| 963 | } |
| 964 | dependsOn dex_debuginfo_examples |
| 965 | } |
| 966 | |
| 967 | task buildDebugTestResourcesJars { |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 968 | def resourcesDir = file("src/test/debugTestResources") |
| 969 | def hostJar = "debug_test_resources.jar" |
| 970 | task "compile_debugTestResources"(type: JavaCompile) { |
| 971 | source = fileTree(dir: resourcesDir, include: '**/*.java') |
| 972 | destinationDir = file("build/test/debugTestResources/classes") |
| 973 | classpath = sourceSets.main.compileClasspath |
| 974 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 975 | targetCompatibility = JavaVersion.VERSION_1_7 |
| 976 | options.compilerArgs += ["-g", "-Xlint:-options"] |
| 977 | } |
| 978 | task "jar_debugTestResources"(type: Jar, dependsOn: "compile_debugTestResources") { |
| 979 | archiveName = hostJar |
| 980 | destinationDir = file("build/test/") |
| 981 | from "build/test/debugTestResources/classes" |
| 982 | include "**/*.class" |
| 983 | } |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 984 | def java8ResourcesDir = file("src/test/debugTestResourcesJava8") |
| 985 | def java8HostJar = "debug_test_resources_java8.jar" |
| 986 | task "compile_debugTestResourcesJava8"(type: JavaCompile) { |
| 987 | source = fileTree(dir: java8ResourcesDir, include: '**/*.java') |
| 988 | destinationDir = file("build/test/debugTestResourcesJava8/classes") |
| 989 | classpath = sourceSets.main.compileClasspath |
| 990 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 991 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 992 | options.compilerArgs += ["-g", "-Xlint:-options"] |
| 993 | } |
| 994 | task "jar_debugTestResourcesJava8"(type: Jar, dependsOn: "compile_debugTestResourcesJava8") { |
| 995 | archiveName = java8HostJar |
| 996 | destinationDir = file("build/test/") |
| 997 | from "build/test/debugTestResourcesJava8/classes" |
| 998 | include "**/*.class" |
| 999 | } |
Sebastien Hertz | 1d7702b | 2017-08-18 09:07:27 +0200 | [diff] [blame] | 1000 | def kotlinResourcesDir = file("src/test/debugTestResourcesKotlin") |
Sebastien Hertz | 2ac9bac | 2018-01-15 16:33:44 +0000 | [diff] [blame] | 1001 | def kotlinHostJar = "debug_test_resources_kotlin.jar" |
| 1002 | task "jar_debugTestResourcesKotlin"(type: kotlin.Kotlinc) { |
| 1003 | source = fileTree(dir: kotlinResourcesDir, include: '**/*.kt') |
| 1004 | destination = file("build/test/${kotlinHostJar}") |
Sebastien Hertz | 1d7702b | 2017-08-18 09:07:27 +0200 | [diff] [blame] | 1005 | } |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 1006 | dependsOn downloadDeps |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1007 | dependsOn jar_debugTestResources |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 1008 | dependsOn jar_debugTestResourcesJava8 |
Sebastien Hertz | 2ac9bac | 2018-01-15 16:33:44 +0000 | [diff] [blame] | 1009 | dependsOn jar_debugTestResourcesKotlin |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1010 | } |
| 1011 | |
Søren Gjesse | 5b4ee0a | 2018-01-30 13:46:39 +0100 | [diff] [blame] | 1012 | // Examples used by tests, where Android specific APIs are used. |
| 1013 | task buildExampleAndroidApi(type: JavaCompile) { |
| 1014 | source = fileTree(dir: file("src/test/examplesAndroidApi"), include: "**/*.java") |
| 1015 | destinationDir = file("build/test/examplesAndroidApi/classes") |
| 1016 | classpath = files("third_party/android_jar/lib-v26/android.jar") |
| 1017 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 1018 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 1019 | } |
| 1020 | |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 1021 | task buildExampleKotlinJars { |
| 1022 | def kotlinSrcDir = file("src/test/examplesKotlin") |
| 1023 | kotlinSrcDir.eachDir { dir -> |
Sebastien Hertz | 2ac9bac | 2018-01-15 16:33:44 +0000 | [diff] [blame] | 1024 | def name = dir.getName(); |
| 1025 | dependsOn "compile_example_kotlin_${name}" |
| 1026 | task "compile_example_kotlin_${name}"(type: kotlin.Kotlinc) { |
| 1027 | source = fileTree(dir: file("src/test/examplesKotlin/${name}"), include: '**/*.kt') |
| 1028 | destination = file("build/test/examplesKotlin/${name}.jar") |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 1029 | } |
| 1030 | } |
| 1031 | } |
| 1032 | |
Lars Bak | c91e87e | 2017-08-18 08:53:10 +0200 | [diff] [blame] | 1033 | // Proto lite generated code yields warnings when compiling with javac. |
| 1034 | // We change the options passed to javac to ignore it. |
| 1035 | compileExamplesJava.options.compilerArgs = ["-Xlint:none"] |
| 1036 | |
Søren Gjesse | 7320ce5 | 2018-05-07 15:45:22 +0200 | [diff] [blame] | 1037 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1038 | task buildExampleJars { |
Rico Wind | 897bb71 | 2017-05-23 10:44:29 +0200 | [diff] [blame] | 1039 | dependsOn downloadProguard |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1040 | def examplesDir = file("src/test/examples") |
Jean-Marie Henaff | 872e442 | 2017-06-13 10:26:20 +0200 | [diff] [blame] | 1041 | def proguardScript |
| 1042 | if (OperatingSystem.current().isWindows()) { |
| 1043 | proguardScript = "third_party/proguard/proguard5.2.1/bin/proguard.bat" |
| 1044 | } else { |
| 1045 | proguardScript = "third_party/proguard/proguard5.2.1/bin/proguard.sh" |
| 1046 | } |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1047 | task extractExamplesRuntime(type: Sync) { |
| 1048 | dependsOn configurations.examplesRuntime |
Ivan Gavrilovic | 635c7e5 | 2017-12-01 15:10:45 +0000 | [diff] [blame] | 1049 | from { configurations.examplesRuntime.collect { zipTree(it) } } |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1050 | include "**/*.class" |
| 1051 | includeEmptyDirs false |
| 1052 | into "$buildDir/runtime/examples/" |
| 1053 | } |
| 1054 | |
Søren Gjesse | 7320ce5 | 2018-05-07 15:45:22 +0200 | [diff] [blame] | 1055 | task "copy_examples_resources"(type: org.gradle.api.tasks.Copy) { |
| 1056 | from examplesDir |
| 1057 | exclude "**/*.java" |
| 1058 | exclude "**/keep-rules*.txt" |
| 1059 | into file("build/test/examples/classes") |
| 1060 | } |
| 1061 | |
| 1062 | task "compile_examples"(type: JavaCompile) { |
Søren Gjesse | 7320ce5 | 2018-05-07 15:45:22 +0200 | [diff] [blame] | 1063 | dependsOn "copy_examples_resources" |
Rico Wind | 40fd2c1 | 2018-09-12 12:14:44 +0200 | [diff] [blame] | 1064 | source examplesDir |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1065 | include "**/*.java" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1066 | destinationDir = file("build/test/examples/classes") |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1067 | classpath = sourceSets.examples.compileClasspath |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1068 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 1069 | targetCompatibility = JavaVersion.VERSION_1_7 |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1070 | options.compilerArgs = ["-g:source,lines", "-Xlint:none"] |
| 1071 | } |
Rico Wind | 40fd2c1 | 2018-09-12 12:14:44 +0200 | [diff] [blame] | 1072 | task "compile_examples_debuginfo_all"(type: JavaCompile) { |
| 1073 | source examplesDir |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1074 | include "**/*.java" |
| 1075 | destinationDir = file("build/test/examples/classes_debuginfo_all") |
| 1076 | classpath = sourceSets.examples.compileClasspath |
| 1077 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 1078 | targetCompatibility = JavaVersion.VERSION_1_7 |
| 1079 | options.compilerArgs = ["-g", "-Xlint:none"] |
| 1080 | } |
Rico Wind | 40fd2c1 | 2018-09-12 12:14:44 +0200 | [diff] [blame] | 1081 | task "compile_examples_debuginfo_none"(type: JavaCompile) { |
| 1082 | source examplesDir |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1083 | include "**/*.java" |
| 1084 | destinationDir = file("build/test/examples/classes_debuginfo_none") |
| 1085 | classpath = sourceSets.examples.compileClasspath |
| 1086 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 1087 | targetCompatibility = JavaVersion.VERSION_1_7 |
| 1088 | options.compilerArgs = ["-g:none", "-Xlint:none"] |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1089 | } |
| 1090 | examplesDir.eachDir { dir -> |
| 1091 | def name = dir.getName(); |
| 1092 | def exampleOutputDir = file("build/test/examples"); |
| 1093 | def jarName = "${name}.jar" |
| 1094 | dependsOn "jar_example_${name}" |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1095 | dependsOn "jar_example_${name}_debuginfo_all" |
| 1096 | dependsOn "jar_example_${name}_debuginfo_none" |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1097 | dependsOn "extractExamplesRuntime" |
| 1098 | def runtimeDependencies = copySpec { } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1099 | // The "throwing" test verifies debugging/stack info on the post-proguarded output. |
| 1100 | def proguardConfigPath = "${dir}/proguard.cfg" |
| 1101 | if (new File(proguardConfigPath).exists()) { |
| 1102 | task "pre_proguard_example_${name}"(type: Jar, dependsOn: "compile_examples") { |
| 1103 | archiveName = "${name}_pre_proguard.jar" |
| 1104 | destinationDir = exampleOutputDir |
| 1105 | from "build/test/examples/classes" |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1106 | include name + "/**/*.class" |
| 1107 | with runtimeDependencies |
| 1108 | includeEmptyDirs false |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1109 | } |
| 1110 | def jarPath = files(tasks.getByPath("pre_proguard_example_${name}")).files.first(); |
| 1111 | def proguardJarPath = "${exampleOutputDir}/${jarName}" |
| 1112 | def proguardMapPath = "${exampleOutputDir}/${name}/${name}.map" |
| 1113 | task "jar_example_${name}"(type: Exec, dependsOn: "pre_proguard_example_${name}") { |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 1114 | inputs.files files( |
| 1115 | tasks.getByPath("pre_proguard_example_${name}"), |
| 1116 | proguardConfigPath) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1117 | // Enable these to get stdout and stderr redirected to files... |
| 1118 | // standardOutput = new FileOutputStream('proguard.stdout') |
| 1119 | // errorOutput = new FileOutputStream('proguard.stderr') |
Jean-Marie Henaff | 872e442 | 2017-06-13 10:26:20 +0200 | [diff] [blame] | 1120 | def proguardArguments = "-verbose -dontwarn java.** -injars ${jarPath}" + |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1121 | " -outjars ${proguardJarPath}" + |
| 1122 | " -include ${proguardConfigPath}" + |
Jean-Marie Henaff | 872e442 | 2017-06-13 10:26:20 +0200 | [diff] [blame] | 1123 | " -printmapping ${proguardMapPath}" |
| 1124 | if (OperatingSystem.current().isWindows()) { |
| 1125 | executable "${proguardScript}" |
| 1126 | args "${proguardArguments}" |
| 1127 | } else { |
| 1128 | executable "bash" |
| 1129 | args "-c", "${proguardScript} '${proguardArguments}'" |
| 1130 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1131 | outputs.file proguardJarPath |
| 1132 | } |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1133 | // TODO: Consider performing distinct proguard compilations. |
| 1134 | task "jar_example_${name}_debuginfo_all"(type: Copy, dependsOn: "jar_example_${name}") { |
| 1135 | from "${exampleOutputDir}/${name}.jar" |
Tamas Kenez | 925cb64 | 2017-09-19 10:41:15 +0200 | [diff] [blame] | 1136 | into "${exampleOutputDir}" |
| 1137 | rename(".*", "${name}_debuginfo_all.jar") |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1138 | } |
| 1139 | task "jar_example_${name}_debuginfo_none"(type: Copy, dependsOn: "jar_example_${name}") { |
| 1140 | from "${exampleOutputDir}/${name}.jar" |
Tamas Kenez | 925cb64 | 2017-09-19 10:41:15 +0200 | [diff] [blame] | 1141 | into "${exampleOutputDir}" |
| 1142 | rename(".*", "${name}_debuginfo_none.jar") |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1143 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1144 | } else { |
| 1145 | task "jar_example_${name}"(type: Jar, dependsOn: "compile_examples") { |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1146 | archiveName = "${name}.jar" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1147 | destinationDir = exampleOutputDir |
| 1148 | from "build/test/examples/classes" |
Søren Gjesse | 7320ce5 | 2018-05-07 15:45:22 +0200 | [diff] [blame] | 1149 | include name + "/**/*" |
Stephan Herhut | 417a72a | 2017-07-18 10:38:30 +0200 | [diff] [blame] | 1150 | with runtimeDependencies |
Søren Gjesse | 7320ce5 | 2018-05-07 15:45:22 +0200 | [diff] [blame] | 1151 | includeEmptyDirs true |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1152 | } |
Tamas Kenez | c5163ed | 2017-09-19 09:27:37 +0200 | [diff] [blame] | 1153 | task "jar_example_${name}_debuginfo_all"(type: Jar, dependsOn: "compile_examples_debuginfo_all") { |
| 1154 | archiveName = "${name}_debuginfo_all.jar" |
| 1155 | destinationDir = exampleOutputDir |
| 1156 | from "build/test/examples/classes_debuginfo_all" |
| 1157 | include name + "/**/*.class" |
| 1158 | with runtimeDependencies |
| 1159 | includeEmptyDirs false |
| 1160 | } |
| 1161 | task "jar_example_${name}_debuginfo_none"(type: Jar, dependsOn: "compile_examples_debuginfo_none") { |
| 1162 | archiveName = "${name}_debuginfo_none.jar" |
| 1163 | destinationDir = exampleOutputDir |
| 1164 | from "build/test/examples/classes_debuginfo_none" |
| 1165 | include name + "/**/*.class" |
| 1166 | with runtimeDependencies |
| 1167 | includeEmptyDirs false |
| 1168 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | task buildExampleAndroidNJars { |
| 1174 | dependsOn downloadDeps |
| 1175 | def examplesDir = file("src/test/examplesAndroidN") |
| 1176 | task "compile_examplesAndroidN"(type: JavaCompile) { |
| 1177 | source = fileTree(dir: examplesDir, include: '**/*.java') |
| 1178 | destinationDir = file("build/test/examplesAndroidN/classes") |
| 1179 | classpath = sourceSets.main.compileClasspath |
| 1180 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 1181 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 1182 | options.compilerArgs += ["-Xlint:-options"] |
| 1183 | } |
| 1184 | examplesDir.eachDir { dir -> |
| 1185 | def name = dir.getName(); |
| 1186 | def exampleOutputDir = file("build/test/examplesAndroidN"); |
| 1187 | def jarName = "${name}.jar" |
| 1188 | dependsOn "jar_examplesAndroidN_${name}" |
| 1189 | task "jar_examplesAndroidN_${name}"(type: Jar, dependsOn: "compile_examplesAndroidN") { |
| 1190 | archiveName = jarName |
| 1191 | destinationDir = exampleOutputDir |
| 1192 | from "build/test/examplesAndroidN/classes" |
| 1193 | include "**/" + name + "/**/*.class" |
| 1194 | } |
| 1195 | } |
| 1196 | } |
| 1197 | |
| 1198 | |
| 1199 | task buildExampleAndroidOJars { |
| 1200 | dependsOn downloadDeps |
| 1201 | def examplesDir = file("src/test/examplesAndroidO") |
| 1202 | // NOTE: we want to enable a scenario when test needs to reference some |
| 1203 | // classes generated by legacy (1.6) Java compiler to test some specific |
| 1204 | // behaviour. To do so we compile all the java files located in sub-directory |
| 1205 | // called 'legacy' with Java 1.6, then compile the rest of the files with |
| 1206 | // Java 1.8 and a reference to previously generated 1.6 classes. |
| 1207 | |
| 1208 | // Compiling all classes in dirs 'legacy' with old Java version. |
| 1209 | task "compile_examplesAndroidO_Legacy"(type: JavaCompile) { |
| 1210 | source = fileTree(dir: examplesDir, include: '**/legacy/**/*.java') |
| 1211 | destinationDir = file("build/test/examplesAndroidOLegacy/classes") |
| 1212 | classpath = sourceSets.main.compileClasspath |
| 1213 | sourceCompatibility = JavaVersion.VERSION_1_6 |
| 1214 | targetCompatibility = JavaVersion.VERSION_1_6 |
| 1215 | options.compilerArgs += ["-Xlint:-options", "-parameters"] |
| 1216 | } |
| 1217 | // Compiling the rest of the files as Java 1.8 code. |
| 1218 | task "compile_examplesAndroidO"(type: JavaCompile) { |
| 1219 | dependsOn "compile_examplesAndroidO_Legacy" |
| 1220 | source = fileTree(dir: examplesDir, include: '**/*.java', exclude: '**/legacy/**/*.java') |
| 1221 | destinationDir = file("build/test/examplesAndroidO/classes") |
| 1222 | classpath = sourceSets.main.compileClasspath |
| 1223 | classpath += files("build/test/examplesAndroidOLegacy/classes") |
| 1224 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 1225 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 1226 | options.compilerArgs += ["-Xlint:-options", "-parameters"] |
| 1227 | } |
| 1228 | examplesDir.eachDir { dir -> |
| 1229 | def name = dir.getName(); |
| 1230 | def destinationDir = file("build/test/examplesAndroidO/classes"); |
| 1231 | if (file("src/test/examplesAndroidO/" + name + "/TestGenerator.java").isFile()) { |
| 1232 | task "generate_examplesAndroidO_${name}"(type: JavaExec, |
| 1233 | dependsOn: "compile_examplesAndroidO") { |
| 1234 | main = name + ".TestGenerator" |
| 1235 | classpath = files(destinationDir, sourceSets.main.compileClasspath) |
| 1236 | args destinationDir |
| 1237 | } |
| 1238 | } else { |
| 1239 | task "generate_examplesAndroidO_${name}" () {} |
| 1240 | } |
| 1241 | } |
| 1242 | examplesDir.eachDir { dir -> |
| 1243 | def name = dir.getName(); |
| 1244 | def exampleOutputDir = file("build/test/examplesAndroidO"); |
| 1245 | def jarName = "${name}.jar" |
| 1246 | dependsOn "jar_examplesAndroidO_${name}" |
| 1247 | task "jar_examplesAndroidO_${name}"(type: Jar, dependsOn: ["compile_examplesAndroidO", |
| 1248 | "generate_examplesAndroidO_${name}"]) { |
| 1249 | archiveName = jarName |
| 1250 | destinationDir = exampleOutputDir |
| 1251 | from "build/test/examplesAndroidO/classes" // Java 1.8 classes |
| 1252 | from "build/test/examplesAndroidOLegacy/classes" // Java 1.6 classes |
| 1253 | include "**/" + name + "/**/*.class" |
| 1254 | // Do not include generator into the test runtime jar, it is not useful. |
| 1255 | // Otherwise, shrinking will need ASM jars. |
| 1256 | exclude "**/TestGenerator*" |
| 1257 | } |
| 1258 | } |
| 1259 | } |
| 1260 | |
Mikaël Peltier | 7b7b53a | 2017-10-09 13:33:21 +0200 | [diff] [blame] | 1261 | task buildExampleAndroidPJars { |
| 1262 | dependsOn downloadDeps |
| 1263 | def examplesDir = file("src/test/examplesAndroidP") |
| 1264 | |
| 1265 | task "compile_examplesAndroidP"(type: JavaCompile) { |
| 1266 | source = fileTree(dir: examplesDir, include: '**/*.java') |
| 1267 | destinationDir = file("build/test/examplesAndroidP/classes") |
| 1268 | classpath = sourceSets.main.compileClasspath |
| 1269 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 1270 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 1271 | options.compilerArgs += ["-Xlint:-options"] |
| 1272 | } |
| 1273 | examplesDir.eachDir { dir -> |
| 1274 | def name = dir.getName(); |
| 1275 | def destinationDir = file("build/test/examplesAndroidP/classes"); |
| 1276 | if (file("src/test/examplesAndroidP/" + name + "/TestGenerator.java").isFile()) { |
| 1277 | task "generate_examplesAndroidP_${name}"(type: JavaExec, |
| 1278 | dependsOn: "compile_examplesAndroidP") { |
| 1279 | main = name + ".TestGenerator" |
| 1280 | classpath = files(destinationDir, sourceSets.main.compileClasspath) |
| 1281 | args destinationDir |
| 1282 | } |
| 1283 | } else { |
| 1284 | task "generate_examplesAndroidP_${name}" () {} |
| 1285 | } |
| 1286 | } |
| 1287 | examplesDir.eachDir { dir -> |
| 1288 | def name = dir.getName(); |
| 1289 | def exampleOutputDir = file("build/test/examplesAndroidP"); |
| 1290 | def jarName = "${name}.jar" |
| 1291 | dependsOn "jar_examplesAndroidP_${name}" |
| 1292 | task "jar_examplesAndroidP_${name}"(type: Jar, |
| 1293 | dependsOn: ["compile_examplesAndroidP", |
| 1294 | "generate_examplesAndroidP_${name}"]) { |
| 1295 | archiveName = jarName |
| 1296 | destinationDir = exampleOutputDir |
| 1297 | from "build/test/examplesAndroidP/classes" // Java 1.8 classes |
| 1298 | include "**/" + name + "/**/*.class" |
| 1299 | // Do not include generator into the test runtime jar, it is not useful. |
| 1300 | // Otherwise, shrinking will need ASM jars. |
| 1301 | exclude "**/TestGenerator*" |
| 1302 | } |
| 1303 | } |
| 1304 | } |
| 1305 | |
Mikaël Peltier | 61633d4 | 2017-10-13 16:51:06 +0200 | [diff] [blame] | 1306 | task buildExampleJava9Jars { |
| 1307 | def examplesDir = file("src/test/examplesJava9") |
| 1308 | examplesDir.eachDir { dir -> |
| 1309 | def name = dir.getName(); |
| 1310 | def exampleOutputDir = file("build/test/examplesJava9"); |
| 1311 | def jarName = "${name}.jar" |
| 1312 | dependsOn "jar_examplesJava9_${name}" |
| 1313 | task "jar_examplesJava9_${name}"(type: Jar) { |
| 1314 | archiveName = jarName |
| 1315 | destinationDir = exampleOutputDir |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 1316 | from sourceSets.examplesJava9.output |
Mikaël Peltier | 61633d4 | 2017-10-13 16:51:06 +0200 | [diff] [blame] | 1317 | include "**/" + name + "/**/*.class" |
| 1318 | } |
| 1319 | } |
| 1320 | } |
| 1321 | |
clementbera | d7ab1dd | 2019-04-16 16:05:00 +0200 | [diff] [blame] | 1322 | task buildExampleJava11Jars { |
| 1323 | def examplesDir = file("src/test/examplesJava11") |
| 1324 | examplesDir.eachDir { dir -> |
| 1325 | def name = dir.getName(); |
| 1326 | def exampleOutputDir = file("build/test/examplesJava11"); |
| 1327 | def jarName = "${name}.jar" |
| 1328 | dependsOn "jar_examplesJava11_${name}" |
| 1329 | task "jar_examplesJava11_${name}"(type: Jar) { |
| 1330 | archiveName = jarName |
| 1331 | destinationDir = exampleOutputDir |
Ian Zerny | d302048 | 2019-04-25 07:05:04 +0200 | [diff] [blame] | 1332 | from sourceSets.examplesJava11.output |
clementbera | d7ab1dd | 2019-04-16 16:05:00 +0200 | [diff] [blame] | 1333 | include "**/" + name + "/**/*.class" |
| 1334 | } |
| 1335 | } |
| 1336 | } |
| 1337 | |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 1338 | task buildExamplesKotlin { |
| 1339 | if (OperatingSystem.current().isMacOsX() || OperatingSystem.current().isWindows()) { |
| 1340 | logger.lifecycle("WARNING: Testing (including building kotlin examples) is only partially" + |
| 1341 | " supported on your platform (" + OperatingSystem.current().getName() + ").") |
| 1342 | } else if (!OperatingSystem.current().isLinux()) { |
| 1343 | logger.lifecycle("WARNING: Testing (including building kotlin examples) is not supported " + |
| 1344 | "on your platform. It is fully supported on Linux and partially supported on " + |
| 1345 | "Mac OS and Windows") |
| 1346 | return; |
| 1347 | } |
| 1348 | def examplesDir = file("src/test/examplesKotlin") |
| 1349 | examplesDir.eachDir { dir -> |
Sebastien Hertz | 2ac9bac | 2018-01-15 16:33:44 +0000 | [diff] [blame] | 1350 | def name = dir.getName(); |
| 1351 | dependsOn "dex_example_kotlin_${name}" |
| 1352 | def exampleOutputDir = file("build/test/examplesKotlin/" + name); |
| 1353 | def dexPath = file("${exampleOutputDir}") |
| 1354 | task "dex_example_kotlin_${name}"(type: dx.Dx, |
| 1355 | dependsOn: "compile_example_kotlin_${name}") { |
| 1356 | doFirst { |
| 1357 | if (!dexPath.exists()) { |
| 1358 | dexPath.mkdirs() |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 1359 | } |
| 1360 | } |
Sebastien Hertz | 2ac9bac | 2018-01-15 16:33:44 +0000 | [diff] [blame] | 1361 | source = files(tasks.getByPath("compile_example_kotlin_${name}")).asFileTree |
| 1362 | destination = dexPath |
| 1363 | debug = false |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 1364 | } |
| 1365 | } |
| 1366 | } |
| 1367 | |
Sebastien Hertz | d331377 | 2018-01-16 14:12:37 +0100 | [diff] [blame] | 1368 | task buildKotlinR8TestResources { |
| 1369 | def examplesDir = file("src/test/kotlinR8TestResources") |
| 1370 | examplesDir.eachDir { dir -> |
Sebastien Hertz | fe97a71 | 2018-02-13 12:08:59 +0100 | [diff] [blame] | 1371 | kotlin.Kotlinc.KotlinTargetVersion.values().each { kotlinTargetVersion -> |
| 1372 | def name = dir.getName() |
| 1373 | def taskName = "jar_kotlinR8TestResources_${name}_${kotlinTargetVersion}" |
Morten Krogh-Jespersen | 6c1f2fa | 2019-01-04 13:23:13 +0000 | [diff] [blame] | 1374 | def outputFile = "build/test/kotlinR8TestResources/${kotlinTargetVersion}/${name}.jar" |
| 1375 | def javaOutput = "build/test/kotlinR8TestResources/${kotlinTargetVersion}/${name}/java" |
Denis Vnukov | c22da84 | 2018-03-14 12:57:20 -0700 | [diff] [blame] | 1376 | def javaOutputJarName = "${name}.java.jar" |
Morten Krogh-Jespersen | 6c1f2fa | 2019-01-04 13:23:13 +0000 | [diff] [blame] | 1377 | def javaOutputJarDir = "build/test/kotlinR8TestResources/${kotlinTargetVersion}" |
Denis Vnukov | c22da84 | 2018-03-14 12:57:20 -0700 | [diff] [blame] | 1378 | task "${taskName}Kotlin"(type: kotlin.Kotlinc) { |
| 1379 | source = fileTree(dir: file("${examplesDir}/${name}"), |
| 1380 | include: ['**/*.kt', '**/*.java']) |
Sebastien Hertz | fe97a71 | 2018-02-13 12:08:59 +0100 | [diff] [blame] | 1381 | destination = file(outputFile) |
| 1382 | targetVersion = kotlinTargetVersion |
| 1383 | } |
Denis Vnukov | c22da84 | 2018-03-14 12:57:20 -0700 | [diff] [blame] | 1384 | task "${taskName}Java"(type: JavaCompile) { |
| 1385 | source = fileTree(dir: file("${examplesDir}/${name}"), include: '**/*.java') |
| 1386 | destinationDir = file(javaOutput) |
| 1387 | classpath = sourceSets.main.compileClasspath |
| 1388 | sourceCompatibility = JavaVersion.VERSION_1_6 |
| 1389 | targetCompatibility = JavaVersion.VERSION_1_6 |
| 1390 | options.compilerArgs += ["-g", "-Xlint:-options"] |
| 1391 | } |
| 1392 | task "${taskName}JavaJar"(type: Jar, dependsOn: "${taskName}Java") { |
| 1393 | archiveName = javaOutputJarName |
| 1394 | destinationDir = file(javaOutputJarDir) |
| 1395 | from javaOutput |
| 1396 | include "**/*.class" |
| 1397 | } |
| 1398 | dependsOn "${taskName}Kotlin", "${taskName}JavaJar" |
Sebastien Hertz | d331377 | 2018-01-16 14:12:37 +0100 | [diff] [blame] | 1399 | } |
Sebastien Hertz | d331377 | 2018-01-16 14:12:37 +0100 | [diff] [blame] | 1400 | } |
| 1401 | } |
| 1402 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1403 | task buildExamples { |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 1404 | if (OperatingSystem.current().isMacOsX() || OperatingSystem.current().isWindows()) { |
| 1405 | logger.lifecycle("WARNING: Testing (including building examples) is only partially supported on your " + |
| 1406 | "platform (" + OperatingSystem.current().getName() + ").") |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1407 | } else if (!OperatingSystem.current().isLinux()) { |
| 1408 | logger.lifecycle("WARNING: Testing (including building examples) is not supported on your platform. " + |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 1409 | "It is fully supported on Linux and partially supported on Mac OS and Windows") |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1410 | return; |
| 1411 | } |
| 1412 | dependsOn buildDebugTestResourcesJars |
| 1413 | dependsOn buildExampleJars |
| 1414 | dependsOn buildExampleAndroidNJars |
| 1415 | dependsOn buildExampleAndroidOJars |
Mikaël Peltier | 7b7b53a | 2017-10-09 13:33:21 +0200 | [diff] [blame] | 1416 | dependsOn buildExampleAndroidPJars |
Mikaël Peltier | 61633d4 | 2017-10-13 16:51:06 +0200 | [diff] [blame] | 1417 | dependsOn buildExampleJava9Jars |
clementbera | d7ab1dd | 2019-04-16 16:05:00 +0200 | [diff] [blame] | 1418 | dependsOn buildExampleJava11Jars |
Søren Gjesse | 5b4ee0a | 2018-01-30 13:46:39 +0100 | [diff] [blame] | 1419 | dependsOn buildExampleAndroidApi |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1420 | def examplesDir = file("src/test/examples") |
Yohann Roussel | f820a57 | 2017-05-31 20:25:51 +0200 | [diff] [blame] | 1421 | def noDexTests = [ |
| 1422 | "multidex", |
| 1423 | "multidex002", |
| 1424 | "multidex004", |
| 1425 | ] |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1426 | examplesDir.eachDir { dir -> |
| 1427 | def name = dir.getName(); |
Yohann Roussel | f820a57 | 2017-05-31 20:25:51 +0200 | [diff] [blame] | 1428 | if (!(name in noDexTests)) { |
| 1429 | dependsOn "dex_example_${name}" |
| 1430 | def exampleOutputDir = file("build/test/examples/" + name); |
| 1431 | def dexPath = file("${exampleOutputDir}") |
| 1432 | def debug = (name == "throwing") |
| 1433 | if (!dexPath.exists()) { |
| 1434 | dexPath.mkdirs() |
| 1435 | } |
| 1436 | task "dex_example_${name}"(type: dx.Dx, dependsOn: "jar_example_${name}") { |
| 1437 | source = files(tasks.getByPath("jar_example_${name}")).asFileTree |
| 1438 | destination = dexPath |
| 1439 | debug = debug |
| 1440 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1441 | } |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | task buildSmali { |
| 1446 | def smaliDir = file("src/test/smali") |
| 1447 | smaliDir.eachDirRecurse() { dir -> |
| 1448 | def name = dir.getName(); |
| 1449 | def relativeDir = smaliDir.toPath().relativize(dir.toPath()); |
| 1450 | def smaliOutputDir = file("build/test/smali/" + relativeDir); |
| 1451 | smaliOutputDir.mkdirs() |
| 1452 | outputs.dir smaliOutputDir |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 1453 | def taskName = "smali_build_${relativeDir.toString().replace('/', '_').replace('\\', '_')}" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1454 | def smaliFiles = fileTree(dir: dir, include: '*.smali') |
| 1455 | def javaFiles = fileTree(dir: dir, include: '*.java') |
| 1456 | def destDir = smaliOutputDir; |
| 1457 | def destFile = destDir.toPath().resolve("${name}.dex").toFile() |
| 1458 | def intermediateFileName = "${name}-intermediate.dex"; |
| 1459 | def intermediateFile = destDir.toPath().resolve(intermediateFileName).toFile() |
| 1460 | if (javaFiles.empty) { |
| 1461 | if (!smaliFiles.empty) { |
| 1462 | dependsOn "${taskName}_smali" |
| 1463 | task "${taskName}_smali"(type: smali.Smali) { |
| 1464 | source = smaliFiles |
| 1465 | destination = destFile |
| 1466 | } |
| 1467 | } |
| 1468 | } else { |
| 1469 | dependsOn "${taskName}_dexmerger" |
| 1470 | task "${taskName}_smali"(type: smali.Smali) { |
| 1471 | source = smaliFiles |
| 1472 | destination = intermediateFile |
| 1473 | } |
| 1474 | task "${taskName}_java"(type: JavaCompile) { |
| 1475 | source = javaFiles |
| 1476 | destinationDir destDir |
| 1477 | classpath = sourceSets.main.compileClasspath |
| 1478 | sourceCompatibility = JavaVersion.VERSION_1_7 |
| 1479 | targetCompatibility = JavaVersion.VERSION_1_7 |
| 1480 | options.compilerArgs += ["-Xlint:-options"] |
| 1481 | } |
| 1482 | task "${taskName}_jar"(type: Jar, dependsOn: "${taskName}_java") { |
| 1483 | archiveName = "Test.jar" |
| 1484 | destinationDir = destDir |
| 1485 | from fileTree(dir: destDir, include: 'Test.class') |
| 1486 | } |
| 1487 | task "${taskName}_dx"(type: dx.Dx, dependsOn: "${taskName}_jar") { |
| 1488 | source = fileTree(dir: destDir, include: 'Test.jar') |
| 1489 | destination = destDir |
| 1490 | } |
| 1491 | task "${taskName}_dexmerger"( |
| 1492 | type: dx.DexMerger, dependsOn: ["${taskName}_dx", "${taskName}_smali"]) { |
| 1493 | source = fileTree(dir: destDir, include: ["classes.dex", intermediateFileName]) |
| 1494 | destination = destFile |
| 1495 | } |
| 1496 | } |
| 1497 | } |
| 1498 | } |
| 1499 | |
| 1500 | tasks.withType(Test) { |
Rico Wind | c56f21c | 2019-03-12 07:29:57 +0100 | [diff] [blame] | 1501 | println("NOTE: Number of processors " + Runtime.runtime.availableProcessors()) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1502 | def userDefinedCoresPerFork = System.getenv('R8_GRADLE_CORES_PER_FORK') |
| 1503 | def coresPerFork = userDefinedCoresPerFork ? userDefinedCoresPerFork.toInteger() : 3 |
| 1504 | // See https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html. |
Rico Wind | 3defc8d | 2019-03-27 08:07:31 +0100 | [diff] [blame] | 1505 | maxParallelForks = (Runtime.runtime.availableProcessors().intdiv(coresPerFork) ?: 1) + 1 |
Rico Wind | c56f21c | 2019-03-12 07:29:57 +0100 | [diff] [blame] | 1506 | println("NOTE: Max parallel forks " + maxParallelForks) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1507 | forkEvery = 0 |
Søren Gjesse | af1c5e2 | 2017-06-15 12:24:03 +0200 | [diff] [blame] | 1508 | if (project.hasProperty('disable_assertions')) { |
| 1509 | enableAssertions = false |
| 1510 | } |
Ian Zerny | 16c2f2d | 2019-02-19 07:25:11 +0100 | [diff] [blame] | 1511 | // TODO(b/124091860): Increase the max heap size to avoid OOM when running tests. |
| 1512 | maxHeapSize = "4g" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1513 | } |
| 1514 | |
| 1515 | task buildPreNJdwpTestsJar(type: Jar) { |
| 1516 | baseName = 'jdwp-tests-preN' |
| 1517 | from zipTree('third_party/jdwp-tests/apache-harmony-jdwp-tests-host.jar') |
| 1518 | // Exclude the classes containing java8 |
| 1519 | exclude 'org/apache/harmony/jpda/tests/jdwp/InterfaceType/*.class' |
| 1520 | exclude 'org/apache/harmony/jpda/tests/jdwp/ObjectReference/InvokeMethodDefault*.class' |
| 1521 | includeEmptyDirs = false |
| 1522 | } |
| 1523 | |
Ian Zerny | 7414316 | 2017-11-24 13:46:35 +0100 | [diff] [blame] | 1524 | task buildPreNJdwpTestsDex(type: Exec, dependsOn: "buildPreNJdwpTestsJar") { |
| 1525 | def inFile = buildPreNJdwpTestsJar.archivePath |
| 1526 | def outFile = new File(buildPreNJdwpTestsJar.destinationDir, buildPreNJdwpTestsJar.baseName + '-dex.jar') |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 1527 | inputs.files files(inFile) |
Ian Zerny | 7414316 | 2017-11-24 13:46:35 +0100 | [diff] [blame] | 1528 | outputs.file outFile |
| 1529 | if (OperatingSystem.current().isWindows()) { |
| 1530 | executable file("tools/windows/dx/bin/dx.bat") |
| 1531 | } else if (OperatingSystem.current().isMacOsX()) { |
| 1532 | executable file("tools/mac/dx/bin/dx"); |
| 1533 | } else { |
| 1534 | executable file("tools/linux/dx/bin/dx"); |
| 1535 | } |
| 1536 | args "--dex" |
| 1537 | args "--output=${outFile}" |
| 1538 | args inFile |
| 1539 | } |
| 1540 | |
Ivan Gavrilovic | 635c7e5 | 2017-12-01 15:10:45 +0000 | [diff] [blame] | 1541 | task getJarsFromSupportLibs(type: GetJarsFromConfiguration) { |
| 1542 | setConfiguration(configurations.supportLibs) |
Yohann Roussel | 126f687 | 2017-08-03 16:25:32 +0200 | [diff] [blame] | 1543 | } |
| 1544 | |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1545 | def getR8LibTask() { |
Morten Krogh-Jespersen | b39fbe5 | 2018-12-17 14:58:48 +0100 | [diff] [blame] | 1546 | if (project.hasProperty('r8lib')) { |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1547 | return R8Lib |
Morten Krogh-Jespersen | b39fbe5 | 2018-12-17 14:58:48 +0100 | [diff] [blame] | 1548 | } else if (project.hasProperty('r8lib_no_deps')) { |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1549 | return R8LibNoDeps |
Morten Krogh-Jespersen | b39fbe5 | 2018-12-17 14:58:48 +0100 | [diff] [blame] | 1550 | } |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1551 | return null |
| 1552 | } |
| 1553 | |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1554 | task configureTestForR8Lib(type: Copy) { |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 1555 | dependsOn testJar |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 1556 | inputs.files files("$buildDir/libs/r8tests.jar") |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1557 | if (getR8LibTask() != null) { |
Morten Krogh-Jespersen | e061698 | 2019-01-03 12:42:36 +0100 | [diff] [blame] | 1558 | dependsOn getR8LibTask() |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 1559 | delete r8LibTestPath |
| 1560 | from zipTree(testJar.outputs.files[0]) |
| 1561 | into r8LibTestPath |
| 1562 | include "com/android/tools/r8/**" |
| 1563 | include "dalvik/**" |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1564 | } |
| 1565 | outputs.dir r8LibTestPath |
Morten Krogh-Jespersen | 807b15f | 2018-12-17 14:24:22 +0100 | [diff] [blame] | 1566 | } |
| 1567 | |
Morten Krogh-Jespersen | 017a700 | 2019-01-10 14:14:17 +0100 | [diff] [blame] | 1568 | def printStackTrace(TestResult result) { |
| 1569 | if (project.hasProperty('r8lib') || project.hasProperty('r8lib_no_deps')) { |
| 1570 | def out = new StringBuffer() |
| 1571 | def err = new StringBuffer() |
Rico Wind | acc291f | 2019-03-06 11:36:33 +0100 | [diff] [blame] | 1572 | def command = "python tools/retrace.py" |
Morten Krogh-Jespersen | 046b18e | 2019-01-17 15:40:14 +0100 | [diff] [blame] | 1573 | def header = "RETRACED STACKTRACE"; |
| 1574 | if (System.getenv('BUILDBOT_BUILDERNAME') != null |
| 1575 | && !System.getenv('BUILDBOT_BUILDERNAME').endsWith("_release")) { |
| 1576 | header += ": (${command} --commit_hash ${System.getenv('BUILDBOT_REVISION')})"; |
| 1577 | } |
Morten Krogh-Jespersen | 017a700 | 2019-01-10 14:14:17 +0100 | [diff] [blame] | 1578 | out.append("\n--------------------------------------\n") |
Morten Krogh-Jespersen | 046b18e | 2019-01-17 15:40:14 +0100 | [diff] [blame] | 1579 | out.append("${header}\n") |
Morten Krogh-Jespersen | 017a700 | 2019-01-10 14:14:17 +0100 | [diff] [blame] | 1580 | out.append("--------------------------------------\n") |
| 1581 | Process process = command.execute() |
| 1582 | def processIn = new PrintStream(process.getOut()) |
| 1583 | process.consumeProcessOutput(out, err) |
| 1584 | result.exception.printStackTrace(processIn) |
| 1585 | processIn.flush() |
| 1586 | processIn.close() |
| 1587 | process.waitFor() |
| 1588 | out.append("\n\n--------------------------------------\n") |
| 1589 | out.append("OBFUSCATED STACKTRACE\n") |
| 1590 | out.append("--------------------------------------\n") |
| 1591 | result.exceptions.add(0, new Exception(out.toString())) |
| 1592 | } else { |
| 1593 | result.exception.printStackTrace() |
| 1594 | } |
| 1595 | } |
| 1596 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1597 | test { |
Jean-Marie Henaff | 7a64eec | 2018-05-31 15:30:35 +0200 | [diff] [blame] | 1598 | if (project.hasProperty('generate_golden_files_to')) { |
| 1599 | systemProperty 'generate_golden_files_to', project.property('generate_golden_files_to') |
| 1600 | assert project.hasProperty('HEAD_sha1') |
| 1601 | systemProperty 'test_git_HEAD_sha1', project.property('HEAD_sha1') |
| 1602 | } |
| 1603 | |
| 1604 | if (project.hasProperty('use_golden_files_in')) { |
| 1605 | systemProperty 'use_golden_files_in', project.property('use_golden_files_in') |
| 1606 | assert project.hasProperty('HEAD_sha1') |
| 1607 | systemProperty 'test_git_HEAD_sha1', project.property('HEAD_sha1') |
| 1608 | } |
Ivan Gavrilovic | 635c7e5 | 2017-12-01 15:10:45 +0000 | [diff] [blame] | 1609 | dependsOn getJarsFromSupportLibs |
Morten Krogh-Jespersen | 75c38f7 | 2018-10-05 09:02:11 +0200 | [diff] [blame] | 1610 | // R8.jar is required for running bootstrap tests. |
| 1611 | dependsOn R8 |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1612 | testLogging.exceptionFormat = 'full' |
| 1613 | if (project.hasProperty('print_test_stdout')) { |
| 1614 | testLogging.showStandardStreams = true |
| 1615 | } |
Tamas Kenez | 0cad51c | 2017-08-21 14:42:01 +0200 | [diff] [blame] | 1616 | if (project.hasProperty('dex_vm') && project.property('dex_vm') != 'default') { |
Ian Zerny | 324d761 | 2019-03-20 10:52:28 +0100 | [diff] [blame] | 1617 | println "NOTE: Running with non default vm: " + project.property('dex_vm') |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1618 | systemProperty 'dex_vm', project.property('dex_vm') |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1619 | } |
Tamas Kenez | 0cad51c | 2017-08-21 14:42:01 +0200 | [diff] [blame] | 1620 | |
Ian Zerny | 324d761 | 2019-03-20 10:52:28 +0100 | [diff] [blame] | 1621 | // Forward runtime configurations for test parameters. |
| 1622 | if (project.hasProperty('runtimes')) { |
| 1623 | println "NOTE: Running with runtimes: " + project.property('runtimes') |
| 1624 | systemProperty 'runtimes', project.property('runtimes') |
Ian Zerny | 4dfd5a5 | 2019-03-12 07:56:11 +0100 | [diff] [blame] | 1625 | } |
| 1626 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1627 | if (project.hasProperty('one_line_per_test')) { |
| 1628 | beforeTest { desc -> |
| 1629 | println "Start executing test ${desc.name} [${desc.className}]" |
| 1630 | } |
| 1631 | afterTest { desc, result -> |
Rico Wind | f88b6be | 2018-12-11 15:14:05 +0100 | [diff] [blame] | 1632 | if (result.resultType == TestResult.ResultType.FAILURE) { |
Morten Krogh-Jespersen | 017a700 | 2019-01-10 14:14:17 +0100 | [diff] [blame] | 1633 | printStackTrace(result) |
Rico Wind | f88b6be | 2018-12-11 15:14:05 +0100 | [diff] [blame] | 1634 | } |
Rico Wind | da6836e | 2018-12-07 12:32:03 +0100 | [diff] [blame] | 1635 | if (project.hasProperty('update_test_timestamp')) { |
| 1636 | file(project.getProperty('update_test_timestamp')).text = new Date().getTime() |
| 1637 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1638 | println "Done executing test ${desc.name} [${desc.className}] with result: ${result.resultType}" |
| 1639 | } |
Rico Wind | f88b6be | 2018-12-11 15:14:05 +0100 | [diff] [blame] | 1640 | } else { |
| 1641 | afterTest { desc, result -> |
| 1642 | if (result.resultType == TestResult.ResultType.FAILURE) { |
Morten Krogh-Jespersen | 017a700 | 2019-01-10 14:14:17 +0100 | [diff] [blame] | 1643 | printStackTrace(result) |
Rico Wind | f88b6be | 2018-12-11 15:14:05 +0100 | [diff] [blame] | 1644 | } |
| 1645 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1646 | } |
| 1647 | if (project.hasProperty('no_internal')) { |
| 1648 | exclude "com/android/tools/r8/internal/**" |
| 1649 | } |
| 1650 | if (project.hasProperty('only_internal')) { |
| 1651 | include "com/android/tools/r8/internal/**" |
| 1652 | } |
Rico Wind | 4e21829 | 2019-03-07 12:44:49 +0100 | [diff] [blame] | 1653 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1654 | if (project.hasProperty('tool')) { |
| 1655 | if (project.property('tool') == 'r8') { |
Rico Wind | f02167a | 2019-03-15 12:27:03 +0100 | [diff] [blame] | 1656 | exclude "com/android/tools/r8/jctf/**" |
Tamas Kenez | cfb2c05 | 2018-10-12 11:03:57 +0200 | [diff] [blame] | 1657 | } else if (project.property('tool') == 'd8') { |
Rico Wind | f02167a | 2019-03-15 12:27:03 +0100 | [diff] [blame] | 1658 | if (project.hasProperty('only_jctf')) { |
| 1659 | include "com/android/tools/r8/jctf/d8/**" |
| 1660 | } else { |
Rico Wind | 819f7c5 | 2019-03-20 09:44:27 +0100 | [diff] [blame] | 1661 | // Don't run anything, deprecated |
| 1662 | println "Running with deprecated tool d8, not running any tests" |
| 1663 | include "" |
Rico Wind | f02167a | 2019-03-15 12:27:03 +0100 | [diff] [blame] | 1664 | } |
Tamas Kenez | cfb2c05 | 2018-10-12 11:03:57 +0200 | [diff] [blame] | 1665 | } else { |
| 1666 | assert(project.property('tool') == 'r8cf') |
Rico Wind | f02167a | 2019-03-15 12:27:03 +0100 | [diff] [blame] | 1667 | assert(project.hasProperty('only_jctf')) |
| 1668 | include "com/android/tools/r8/jctf/r8cf/**" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1669 | } |
| 1670 | } |
| 1671 | if (!project.hasProperty('all_tests')) { |
| 1672 | exclude "com/android/tools/r8/art/dx/**" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1673 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1674 | if (!project.hasProperty('jctf') && !project.hasProperty('only_jctf')) { |
Stephan Herhut | ea6ee58 | 2017-05-23 13:14:34 +0200 | [diff] [blame] | 1675 | exclude "com/android/tools/r8/jctf/**" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1676 | } |
Rico Wind | 8e2f7e4 | 2019-02-21 10:13:21 +0100 | [diff] [blame] | 1677 | if (project.hasProperty('shard_count') ) { |
| 1678 | assert project.hasProperty('shard_number') |
| 1679 | int shard_count = project.getProperty('shard_count') as Integer |
| 1680 | int shard_number = project.getProperty('shard_number') as Integer |
| 1681 | assert shard_count < 65536 |
| 1682 | assert shard_number < shard_count |
| 1683 | exclude { |
| 1684 | entry -> |
| 1685 | // Don't leave out directories. Leaving out a directory means all entries below. |
| 1686 | if (entry.file.isDirectory()) { |
| 1687 | return false |
| 1688 | } |
| 1689 | def first4 = entry.getRelativePath().toString().md5().substring(0, 4) |
| 1690 | int hash = Integer.parseInt(first4, 16) |
| 1691 | return hash % shard_count != shard_number |
| 1692 | } |
| 1693 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1694 | if (project.hasProperty('jctf_compile_only')) { |
| 1695 | println "JCTF: compiling only" |
| 1696 | systemProperty 'jctf_compile_only', '1' |
| 1697 | } |
Tamas Kenez | b77b7d8 | 2017-08-17 14:05:16 +0200 | [diff] [blame] | 1698 | if (project.hasProperty('test_dir')) { |
| 1699 | systemProperty 'test_dir', project.property('test_dir') |
| 1700 | } |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1701 | if (project.hasProperty('r8lib') || project.hasProperty('r8lib_no_deps')) { |
| 1702 | dependsOn configureTestForR8Lib |
Morten Krogh-Jespersen | e28db46 | 2019-01-09 13:32:15 +0100 | [diff] [blame] | 1703 | // We remove build/classes/test from classpath and rely on configureTestForR8Lib to provide |
| 1704 | // all needed tests in r8LibTestPath. |
| 1705 | classpath = files([r8LibPath, r8LibTestPath]) + |
| 1706 | sourceSets.test.runtimeClasspath - |
| 1707 | sourceSets.main.output - |
| 1708 | files(['build/classes/test']) |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 1709 | testClassesDirs = files(r8LibTestPath) |
Morten Krogh-Jespersen | 7df2432 | 2018-12-21 13:39:54 +0100 | [diff] [blame] | 1710 | } |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 1711 | if (OperatingSystem.current().isLinux() |
| 1712 | || OperatingSystem.current().isMacOsX() |
| 1713 | || OperatingSystem.current().isWindows()) { |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1714 | if (OperatingSystem.current().isMacOsX()) { |
| 1715 | logger.lifecycle("WARNING: Testing in only partially supported on Mac OS. " + |
| 1716 | "Art only runs on Linux and tests requiring Art runs in a Docker container, which must be present. " + |
| 1717 | "See tools/docker/README.md for details.") |
| 1718 | } |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 1719 | if (OperatingSystem.current().isWindows()) { |
| 1720 | logger.lifecycle("WARNING: Testing in only partially supported on Windows. " + |
| 1721 | "Art only runs on Linux and tests requiring Art will be skipped") |
| 1722 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1723 | dependsOn downloadDeps |
| 1724 | dependsOn buildExamples |
Mikaël Peltier | 3c8b6ea | 2017-12-12 13:00:21 +0100 | [diff] [blame] | 1725 | dependsOn buildExamplesKotlin |
Sebastien Hertz | d331377 | 2018-01-16 14:12:37 +0100 | [diff] [blame] | 1726 | dependsOn buildKotlinR8TestResources |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1727 | dependsOn buildSmali |
| 1728 | dependsOn jctfCommonJar |
| 1729 | dependsOn jctfTestsClasses |
| 1730 | dependsOn buildDebugInfoExamplesDex |
| 1731 | dependsOn buildPreNJdwpTestsJar |
Mathias Rav | cd79507 | 2018-03-22 12:47:32 +0100 | [diff] [blame] | 1732 | dependsOn buildPreNJdwpTestsDex |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1733 | } else { |
| 1734 | logger.lifecycle("WARNING: Testing in not supported on your platform. Testing is only fully supported on " + |
Jean-Marie Henaff | 39587a8 | 2017-06-08 15:20:13 +0200 | [diff] [blame] | 1735 | "Linux and partially supported on Mac OS and Windows. Art does not run on other platforms.") |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | // The Art tests we use for R8 are pre-build and downloaded from Google Cloud Storage. |
| 1740 | // |
| 1741 | // To build and upload a new set of the Art tests for use with R8 follow these steps: |
| 1742 | // |
| 1743 | // First of all an Android checkout is required. Currently it must be located |
| 1744 | // in $HOME/android/master. |
| 1745 | // |
| 1746 | // TODO(ricow): simplify this |
| 1747 | // |
| 1748 | // Before: update the checked in art, see scripts/update-host-art.sh |
| 1749 | // |
| 1750 | // 1. Get an android checkout in $HOME/android/master and apply the patch from |
| 1751 | // https://android-review.googlesource.com/#/c/294187/ |
| 1752 | // |
| 1753 | // 2. run the following commands in the Android checkout directory: |
| 1754 | // |
| 1755 | // source build/envsetup.sh |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1756 | // lunch aosp_angler-userdebug # or lunch aosp_angler-eng |
| 1757 | // m desugar |
| 1758 | // m -j30 test-art-host |
| 1759 | // DESUGAR=false ANDROID_COMPILE_WITH_JACK=false art/test.py --host -t 001-HelloWorld |
| 1760 | // |
| 1761 | // Without running the test.py command the classes.jar file used by desugar in |
| 1762 | // $HOME/android/master/out/host/common/obj/JAVA_LIBRARIES/core-oj-hostdex_intermediates/ |
| 1763 | // seems to be missing - there is probably also a make target to build it more directly |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1764 | // |
| 1765 | // 3. In the R8 project root directory, make sure we have a clean state before starting: |
| 1766 | // tools/gradle.py downloadDeps |
| 1767 | // tools/gradle.py clean |
| 1768 | // rm -rf tests/art |
| 1769 | // |
| 1770 | // 4. Now build in the R8 checkout (-P hack to not generate dirs when not running this target) |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1771 | // Make sure you have smali on your path, please use the build binary in the |
| 1772 | // out/host/linux-x86/bin directory of the android checkout. Currently this is version pre 2.2.1, |
| 1773 | // if that is updated the call to smali in "task "${smaliToDexTask}"(type: Exec)" below might |
| 1774 | // need to change as smali got a completely new command line interface in version 2.2.1. |
Mikaël Peltier | e116cb6 | 2017-10-05 10:50:30 +0200 | [diff] [blame] | 1775 | // After Android O, Jack is no longer alive, do not forget to uncomment call to buildArtTest for |
| 1776 | // Jack if you build an android version using Jack. |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1777 | // |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1778 | // PATH=$HOME/android/master/out/host/linux-x86/bin:$PATH tools/gradle.py -Pandroid_source buildArtTests |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1779 | // |
| 1780 | // 4a. If any failures are produced in step 4, figure out what went wrong and add an entry in |
| 1781 | // skippedTests with an explanation. Rerun from step 3. |
| 1782 | // |
| 1783 | // 5. Run the tests: |
| 1784 | // tools/gradle.py clean |
| 1785 | // tools/test.py |
| 1786 | // |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1787 | // 5a. If any more tests fail, either fix the issue or add them to the failuresToTriage list (note |
| 1788 | // that you need to change "_" to "-" from stdout). Rerun from step 5 if anything was added to |
| 1789 | // failuresToTriage. |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1790 | // |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1791 | // 6. To upload a new version to Google Cloud Storage: |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1792 | // cd tests |
| 1793 | // upload_to_google_storage.py -a --bucket r8-deps art |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1794 | // |
| 1795 | // 7. Update the manifest file describing the Android repo used: |
| 1796 | // repo manifest -o <r8-checkout-root>/tools/linux/aosp_master_manifest.xml -r |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1797 | |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1798 | def androidCheckoutDir = file("${System.env.HOME}/android/master") |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1799 | |
| 1800 | def artTestDir = file("${androidCheckoutDir}/art/test") |
| 1801 | |
| 1802 | if (project.hasProperty('android_source')) { |
| 1803 | task buildArtTests { |
| 1804 | outputs.upToDateWhen { false } |
| 1805 | def toBeTriaged = [ |
| 1806 | "903-hello-tagging", |
| 1807 | "904-object-allocation", |
| 1808 | "905-object-free", |
| 1809 | "906-iterate-heap", |
| 1810 | "907-get-loaded-classes", |
| 1811 | "908-gc-start-finish", |
| 1812 | "954-invoke-polymorphic-verifier", |
| 1813 | "955-methodhandles-smali", |
| 1814 | "596-monitor-inflation", |
| 1815 | ] |
| 1816 | def skippedTests = toBeTriaged + [ |
| 1817 | // This test produces no jar. |
| 1818 | "000-nop", |
| 1819 | // This does not build, as it tests the error when the application exceeds more |
| 1820 | // than 65536 methods |
| 1821 | "089-many-methods", |
| 1822 | // Requires some jack beta jar |
| 1823 | "956-methodhandles", |
| 1824 | ] |
| 1825 | |
| 1826 | def skippedTestsDx = [ |
| 1827 | // Tests with custom build scripts, where javac is not passed the options |
| 1828 | // -source 1.7 -target 1.7. |
| 1829 | "462-checker-inlining-across-dex-files", |
| 1830 | "556-invoke-super", |
| 1831 | "569-checker-pattern-replacement", |
| 1832 | // These tests use jack even when --build-with-javac-dx is specified. |
| 1833 | "004-JniTest", |
| 1834 | "048-reflect-v8", |
| 1835 | "146-bad-interface", |
| 1836 | "563-checker-invoke-super", |
| 1837 | "580-checker-string-fact-intrinsics", // java.lang.StringFactory |
| 1838 | "604-hot-static-interface", |
| 1839 | "957-methodhandle-transforms", |
| 1840 | "958-methodhandle-emulated-stackframe", |
| 1841 | "959-invoke-polymorphic-accessors", |
| 1842 | "961-default-iface-resolution-gen", |
| 1843 | "962-iface-static", |
| 1844 | "963-default-range-smali", |
| 1845 | "964-default-iface-init-gen", |
| 1846 | "965-default-verify", |
| 1847 | "966-default-conflict", |
| 1848 | "967-default-ame", |
| 1849 | "968-default-partial-compile-gen", |
| 1850 | "969-iface-super", |
| 1851 | "970-iface-super-resolution-gen", |
| 1852 | "971-iface-super", |
| 1853 | // These tests does not build with --build-with-javac-dx |
| 1854 | "004-NativeAllocations", // Javac error |
| 1855 | "031-class-attributes", |
| 1856 | "138-duplicate-classes-check", |
| 1857 | "157-void-class", // Javac error |
| 1858 | "580-checker-string-factory-intrinsics", |
| 1859 | "612-jit-dex-cache", |
| 1860 | "613-inlining-dex-cache", |
| 1861 | "900-hello-plugin", // --experimental agents |
| 1862 | "901-hello-ti-agent", // --experimental agents |
| 1863 | "902-hello-transformation", // --experimental agents |
| 1864 | "909-attach-agent", // --experimental agents |
| 1865 | "946-obsolete-throw", // -source 1.7 -target 1.7, but use lambda |
| 1866 | "950-redefine-intrinsic", // -source 1.7 -target 1.7, but use method references |
| 1867 | "951-threaded-obsolete", // -source 1.7 -target 1.7, but use lambda |
| 1868 | "960-default-smali", // --experimental default-methods |
| 1869 | // These tests force the build to use jack |
| 1870 | "953-invoke-polymorphic-compiler", |
| 1871 | "958-methodhandle-stackframe", |
| 1872 | ] |
| 1873 | |
| 1874 | def artTestBuildDir = file("${projectDir}/tests/art") |
| 1875 | |
| 1876 | if (androidCheckoutDir.exists()) { |
| 1877 | dependsOn downloadDeps |
| 1878 | artTestBuildDir.mkdirs() |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1879 | artTestDir.eachDir { dir -> |
| 1880 | def name = dir.getName(); |
| 1881 | def markerFile = dir.toPath().resolve("info.txt").toFile(); |
| 1882 | if (markerFile.exists() && !(name in skippedTests)) { |
| 1883 | if (!(name in skippedTestsDx)) { |
Rico Wind | de2af6c | 2019-03-26 15:21:08 +0100 | [diff] [blame] | 1884 | dependsOn buildArtTest(androidCheckoutDir, artTestBuildDir, dir); |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1885 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1886 | } |
| 1887 | } |
| 1888 | } |
| 1889 | doFirst { |
| 1890 | if (!androidCheckoutDir.exists()) { |
| 1891 | throw new InvalidUserDataException( |
| 1892 | "This task requires an Android checkout in ${androidCheckoutDir}"); |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1893 | } |
| 1894 | } |
| 1895 | doLast { |
| 1896 | copy { |
| 1897 | from file("${androidCheckoutDir}/out/host/linux-x86/nativetest64") |
| 1898 | into file("${artTestBuildDir}/lib64") |
| 1899 | include 'lib*.so' |
| 1900 | } |
| 1901 | copy { |
| 1902 | from file("${androidCheckoutDir}/out/host/linux-x86/lib64") |
| 1903 | into file("${artTestBuildDir}/lib64") |
| 1904 | include 'libart.so' |
| 1905 | include 'libbacktrace.so' |
| 1906 | include 'libbase.so' |
| 1907 | include 'libc++.so' |
| 1908 | include 'libcutils.so' |
| 1909 | include 'liblz4.so' |
| 1910 | include 'liblzma.so' |
| 1911 | include 'libnativebridge.so' |
| 1912 | include 'libnativeloader.so' |
| 1913 | include 'libsigchain.so' |
| 1914 | include 'libunwind.so' |
| 1915 | include 'libziparchive.so' |
| 1916 | } |
| 1917 | copy { |
| 1918 | from file("${androidCheckoutDir}/out/host/linux-x86/nativetest") |
| 1919 | into file("${artTestBuildDir}/lib") |
| 1920 | include 'lib*.so' |
| 1921 | } |
| 1922 | copy { |
| 1923 | from file("${androidCheckoutDir}/out/host/linux-x86/lib") |
| 1924 | into file("${artTestBuildDir}/lib") |
| 1925 | include 'libart.so' |
| 1926 | include 'libbacktrace.so' |
| 1927 | include 'libbase.so' |
| 1928 | include 'libc++.so' |
| 1929 | include 'libcutils.so' |
| 1930 | include 'liblz4.so' |
| 1931 | include 'liblzma.so' |
| 1932 | include 'libnativebridge.so' |
| 1933 | include 'libnativeloader.so' |
| 1934 | include 'libsigchain.so' |
| 1935 | include 'libunwind.so' |
| 1936 | include 'libziparchive.so' |
| 1937 | } |
| 1938 | } |
| 1939 | } |
| 1940 | } |
| 1941 | |
Rico Wind | de2af6c | 2019-03-26 15:21:08 +0100 | [diff] [blame] | 1942 | def buildArtTest(androidCheckoutDir, artTestBuildDir, dir) { |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1943 | def artTestDir = file("${androidCheckoutDir}/art/test") |
| 1944 | def artRunTestScript = file("${artTestDir}/run-test") |
| 1945 | def dxExecutable = new File("tools/linux/dx/bin/dx"); |
Jean-Marie Henaff | 34d85f7 | 2017-06-14 10:32:04 +0200 | [diff] [blame] | 1946 | def dexMergerExecutable = Utils.dexMergerExecutable() |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1947 | |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1948 | def name = dir.getName() |
Rico Wind | de2af6c | 2019-03-26 15:21:08 +0100 | [diff] [blame] | 1949 | def buildTask = "build_art_test_dx_${name}" |
| 1950 | def sanitizeTask = "sanitize_art_test_dx_${name}" |
| 1951 | def copyCheckTask = "copy_check_art_test_dx_${name}" |
| 1952 | def smaliToDexTask = "smali_to_dex_dx_${name}" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1953 | |
| 1954 | def buildInputs = fileTree(dir: dir, include: '**/*') |
Rico Wind | de2af6c | 2019-03-26 15:21:08 +0100 | [diff] [blame] | 1955 | def testDir = file("${artTestBuildDir}/dx/${name}") |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1956 | def outputJar = testDir.toPath().resolve("${name}.jar").toFile() |
| 1957 | testDir.mkdirs() |
Rico Wind | de2af6c | 2019-03-26 15:21:08 +0100 | [diff] [blame] | 1958 | task "$buildTask"(type: Exec) { |
| 1959 | outputs.upToDateWhen { false } |
| 1960 | inputs.file buildInputs |
| 1961 | executable "${artRunTestScript}" |
| 1962 | args "--host" |
| 1963 | args "--build-only" |
| 1964 | args "--build-with-javac-dx" |
| 1965 | args "--output-path", "${testDir}" |
| 1966 | args "${name}" |
| 1967 | environment DX: "${dxExecutable.absolutePath}" |
| 1968 | environment DXMERGER: "${dexMergerExecutable.absolutePath}" |
| 1969 | environment ANDROID_BUILD_TOP: "${androidCheckoutDir}" |
| 1970 | outputs.file outputJar |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1971 | } |
| 1972 | task "${sanitizeTask}"(type: Exec, dependsOn: buildTask) { |
| 1973 | outputs.upToDateWhen { false } |
| 1974 | executable "/bin/bash" |
| 1975 | args "-c" |
| 1976 | args "rm -rf ${testDir}/smali_*.dex ${testDir}/*-ex.dex ${testDir}/*-ex.jar" + |
| 1977 | " ${testDir}/classes-ex ${testDir}/check" |
| 1978 | } |
| 1979 | |
| 1980 | task "${smaliToDexTask}"(type: Exec) { |
Mikaël Peltier | e116cb6 | 2017-10-05 10:50:30 +0200 | [diff] [blame] | 1981 | // Directory that contains smali files is either smali, or smali/art |
| 1982 | def smali_dir = file("${dir}/smali/art") |
| 1983 | if (smali_dir.exists()) { |
| 1984 | workingDir "${testDir}/smali/art" |
| 1985 | } else { |
| 1986 | workingDir "${testDir}/smali" |
| 1987 | } |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1988 | executable "/bin/bash" |
Søren Gjesse | 34b7773 | 2017-07-07 13:56:21 +0200 | [diff] [blame] | 1989 | // This is the command line options for smali prior to 2.2.1, where smali got a new |
| 1990 | // command line interface. |
| 1991 | args "-c", "smali a *.smali" |
| 1992 | // This is the command line options for smali 2.2.1 and later. |
| 1993 | // args "-c", "smali -o out.dex *.smali" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1994 | } |
| 1995 | |
| 1996 | task "${copyCheckTask}"(type: Copy, dependsOn: sanitizeTask) { |
| 1997 | def smali_dir = file("${dir}/smali") |
| 1998 | outputs.upToDateWhen { false } |
Rico Wind | de2af6c | 2019-03-26 15:21:08 +0100 | [diff] [blame] | 1999 | if (smali_dir.exists()) { |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 2000 | dependsOn smaliToDexTask |
| 2001 | } |
| 2002 | from("${artTestDir}/${name}") { |
| 2003 | include 'check' |
| 2004 | } |
| 2005 | into testDir |
| 2006 | } |
| 2007 | |
| 2008 | return copyCheckTask |
| 2009 | } |
| 2010 | |
| 2011 | task javadocD8(type: Javadoc) { |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2012 | title "D8 API" |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 2013 | classpath = sourceSets.main.compileClasspath |
| 2014 | source = sourceSets.main.allJava |
Yohann Roussel | b16d0f6 | 2017-10-09 16:08:09 +0200 | [diff] [blame] | 2015 | include '**/com/android/tools/r8/ArchiveClassFileProvider.java' |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2016 | include '**/com/android/tools/r8/ArchiveProgramResourceProvider.java' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 2017 | include '**/com/android/tools/r8/BaseCommand.java' |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2018 | include '**/com/android/tools/r8/BaseCompilerCommand.java' |
Yohann Roussel | b16d0f6 | 2017-10-09 16:08:09 +0200 | [diff] [blame] | 2019 | include '**/com/android/tools/r8/ClassFileResourceProvider.java' |
Yohann Roussel | 078c994 | 2017-11-28 15:55:46 +0100 | [diff] [blame] | 2020 | include '**/com/android/tools/r8/CompilationFailedException.java' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 2021 | include '**/com/android/tools/r8/CompilationMode.java' |
| 2022 | include '**/com/android/tools/r8/D8.java' |
| 2023 | include '**/com/android/tools/r8/D8Command.java' |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2024 | include '**/com/android/tools/r8/DexIndexedConsumer.java' |
| 2025 | include '**/com/android/tools/r8/DexFilePerClassFileConsumer.java' |
Yohann Roussel | 078c994 | 2017-11-28 15:55:46 +0100 | [diff] [blame] | 2026 | include '**/com/android/tools/r8/Diagnostic.java' |
| 2027 | include '**/com/android/tools/r8/DiagnosticsHandler.java' |
Ian Zerny | ef028f5 | 2018-01-08 14:23:17 +0100 | [diff] [blame] | 2028 | include '**/com/android/tools/r8/DirectoryClassFileProvider.java' |
| 2029 | include '**/com/android/tools/r8/OutputMode.java' |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2030 | include '**/com/android/tools/r8/ProgramConsumer.java' |
| 2031 | include '**/com/android/tools/r8/ProgramResource.java' |
| 2032 | include '**/com/android/tools/r8/ProgramResourceProvider.java' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 2033 | include '**/com/android/tools/r8/Resource.java' |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2034 | include '**/com/android/tools/r8/ResourceException.java' |
| 2035 | include '**/com/android/tools/r8/StringConsumer.java' |
| 2036 | include '**/com/android/tools/r8/StringResource.java' |
| 2037 | include '**/com/android/tools/r8/Version.java' |
| 2038 | include '**/com/android/tools/r8/origin/*.java' |
| 2039 | } |
| 2040 | |
| 2041 | task javadocR8(type: Javadoc) { |
| 2042 | title "R8 API" |
| 2043 | classpath = sourceSets.main.compileClasspath |
| 2044 | source = sourceSets.main.allJava |
| 2045 | include '**/com/android/tools/r8/ArchiveClassFileProvider.java' |
| 2046 | include '**/com/android/tools/r8/ArchiveProgramResourceProvider.java' |
| 2047 | include '**/com/android/tools/r8/BaseCommand.java' |
| 2048 | include '**/com/android/tools/r8/BaseCompilerCommand.java' |
| 2049 | include '**/com/android/tools/r8/ClassFileConsumer.java' |
| 2050 | include '**/com/android/tools/r8/ClassFileResourceProvider.java' |
| 2051 | include '**/com/android/tools/r8/CompilationFailedException.java' |
| 2052 | include '**/com/android/tools/r8/CompilationMode.java' |
| 2053 | include '**/com/android/tools/r8/R8.java' |
| 2054 | include '**/com/android/tools/r8/R8Command.java' |
| 2055 | include '**/com/android/tools/r8/DexIndexedConsumer.java' |
| 2056 | include '**/com/android/tools/r8/Diagnostic.java' |
| 2057 | include '**/com/android/tools/r8/DiagnosticsHandler.java' |
Ian Zerny | ef028f5 | 2018-01-08 14:23:17 +0100 | [diff] [blame] | 2058 | include '**/com/android/tools/r8/DirectoryClassFileProvider.java' |
| 2059 | include '**/com/android/tools/r8/OutputMode.java' |
Ian Zerny | 850f13d | 2018-01-04 11:25:38 +0100 | [diff] [blame] | 2060 | include '**/com/android/tools/r8/ProgramConsumer.java' |
| 2061 | include '**/com/android/tools/r8/ProgramResource.java' |
| 2062 | include '**/com/android/tools/r8/ProgramResourceProvider.java' |
| 2063 | include '**/com/android/tools/r8/Resource.java' |
| 2064 | include '**/com/android/tools/r8/ResourceException.java' |
| 2065 | include '**/com/android/tools/r8/StringConsumer.java' |
| 2066 | include '**/com/android/tools/r8/StringResource.java' |
| 2067 | include '**/com/android/tools/r8/Version.java' |
Yohann Roussel | 078c994 | 2017-11-28 15:55:46 +0100 | [diff] [blame] | 2068 | include '**/com/android/tools/r8/origin/*.java' |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 2069 | } |
Søren Gjesse | 39a909a | 2017-10-12 09:49:20 +0200 | [diff] [blame] | 2070 | |
| 2071 | task copyMavenDeps(type: Copy) { |
| 2072 | from configurations.compile into "$buildDir/deps" |
Morten Krogh-Jespersen | 7577330 | 2019-01-07 09:45:08 +0100 | [diff] [blame] | 2073 | from configurations.compileClasspath into "$buildDir/deps" |
Søren Gjesse | 39a909a | 2017-10-12 09:49:20 +0200 | [diff] [blame] | 2074 | from configurations.testCompile into "$buildDir/deps" |
| 2075 | } |
Mikaël Peltier | 61633d4 | 2017-10-13 16:51:06 +0200 | [diff] [blame] | 2076 | |
Rico Wind | 23a0511 | 2019-03-27 08:00:44 +0100 | [diff] [blame] | 2077 | task printMavenDeps { |
| 2078 | // Only actually print to stdout when we are updating. |
| 2079 | if (project.hasProperty('updatemavendeps')) { |
| 2080 | for (Configuration config : configurations) { |
| 2081 | if (!config.isCanBeResolved()) { |
| 2082 | continue |
| 2083 | } |
| 2084 | def componentIds = config.incoming.resolutionResult.allDependencies.collect { |
| 2085 | it.selected.id |
| 2086 | } |
| 2087 | def result = dependencies.createArtifactResolutionQuery() |
| 2088 | .forComponents(componentIds) |
| 2089 | .withArtifacts(MavenModule, MavenPomArtifact) |
| 2090 | .execute() |
| 2091 | for (component in result.resolvedComponents) { |
| 2092 | component.getArtifacts(MavenPomArtifact).each { |
| 2093 | println "POM: ${it.file} ${component.id}" |
| 2094 | } |
| 2095 | } |
| 2096 | config.each { |
| 2097 | println "JAR: ${it}" |
| 2098 | } |
| 2099 | } |
| 2100 | } |
| 2101 | } |