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