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