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