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