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