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