Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Aurimas Liutikas | b938b2e | 2017-07-24 14:47:17 -0700 | [diff] [blame] | 17 | import android.support.LibraryVersions |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 18 | import com.android.build.gradle.internal.coverage.JacocoPlugin |
| 19 | import com.android.build.gradle.internal.coverage.JacocoReportTask |
| 20 | import com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask |
Aurimas Liutikas | a015004 | 2017-04-21 09:46:12 -0700 | [diff] [blame] | 21 | import org.gradle.api.logging.configuration.ShowStacktrace |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 22 | |
| 23 | def supportRoot = ext.supportRootFolder |
| 24 | if (supportRoot == null) { |
| 25 | throw new RuntimeException("variable supportRootFolder is not set. you must set it before" + |
| 26 | " including this script") |
| 27 | } |
| 28 | def init = new Properties() |
| 29 | ext.init = init |
Alan Viverette | 1b86237 | 2017-03-22 11:32:28 -0400 | [diff] [blame] | 30 | ext.init.debugKeystore = file("${supportRoot}/development/keystore/debug.keystore") |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 31 | |
Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 32 | ext.runningInBuildServer = System.env.DIST_DIR != null && System.env.OUT_DIR != null |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 33 | |
| 34 | apply from: "${supportRoot}/buildSrc/dependencies.gradle" |
Alan Viverette | 5b3946f | 2017-04-27 09:59:22 -0400 | [diff] [blame] | 35 | ext.docs = [:] |
| 36 | ext.docs.offline = rootProject.getProperties().containsKey("offlineDocs") |
| 37 | ext.docs.dac = [ |
| 38 | libraryroot: "android/support", |
| 39 | dataname: "SUPPORT_DATA" |
| 40 | ] |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 41 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 42 | def enableDoclavaAndJDiff(p) { |
| 43 | p.configurations { |
| 44 | doclava |
| 45 | jdiff |
| 46 | } |
| 47 | |
| 48 | p.dependencies { |
Aurimas Liutikas | eca7a07 | 2017-07-11 01:11:52 +0000 | [diff] [blame] | 49 | doclava project(':doclava') |
| 50 | jdiff project(':jdiff') |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 51 | jdiff libs.xml_parser_apis |
| 52 | jdiff libs.xerces_impl |
| 53 | } |
| 54 | apply from: "${ext.supportRootFolder}/buildSrc/diff_and_docs.gradle" |
| 55 | } |
| 56 | |
Aurimas Liutikas | bb78f3f | 2017-06-19 11:30:37 -0700 | [diff] [blame] | 57 | def getFullSdkPath() { |
Aurimas Liutikas | b06771d | 2017-04-20 09:46:49 -0700 | [diff] [blame] | 58 | final String osName = System.getProperty("os.name").toLowerCase(); |
| 59 | final boolean isMacOsX = |
| 60 | osName.contains("mac os x") || osName.contains("darwin") || osName.contains("osx"); |
| 61 | final String platform = isMacOsX ? 'darwin' : 'linux' |
Aurimas Liutikas | bb78f3f | 2017-06-19 11:30:37 -0700 | [diff] [blame] | 62 | return "${repos.prebuiltsRoot}/fullsdk-${platform}" |
| 63 | } |
| 64 | |
| 65 | def setSdkInLocalPropertiesFile() { |
Aurimas Liutikas | d2d9bda | 2017-03-03 16:06:39 -0800 | [diff] [blame] | 66 | ext.buildToolsVersion = '26.0.0' |
Aurimas Liutikas | bb78f3f | 2017-06-19 11:30:37 -0700 | [diff] [blame] | 67 | final String fullSdkPath = getFullSdkPath(); |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 68 | if (file(fullSdkPath).exists()) { |
| 69 | gradle.ext.currentSdk = 26 |
Alan Viverette | eb9f332 | 2017-03-09 16:29:57 -0500 | [diff] [blame] | 70 | project.ext.androidJar = |
| 71 | files("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android.jar") |
| 72 | project.ext.androidSrcJar = |
| 73 | file("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android-stubs-src.jar") |
Alan Viverette | 810a148 | 2017-03-20 12:43:43 -0400 | [diff] [blame] | 74 | project.ext.androidApiTxt = null |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 75 | File props = file("local.properties") |
| 76 | props.write "sdk.dir=${fullSdkPath}" |
Aurimas Liutikas | 3c66600 | 2017-03-08 19:30:28 -0800 | [diff] [blame] | 77 | ext.usingFullSdk = true |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 78 | } else { |
| 79 | gradle.ext.currentSdk = 'current' |
Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 80 | project.ext.androidJar = files("${repos.prebuiltsRoot}/sdk/current/android.jar") |
Alan Viverette | 810a148 | 2017-03-20 12:43:43 -0400 | [diff] [blame] | 81 | project.ext.androidSrcJar = null |
Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 82 | project.ext.androidApiTxt = file("${repos.prebuiltsRoot}/sdk/api/26.txt") |
Aurimas Liutikas | bb78f3f | 2017-06-19 11:30:37 -0700 | [diff] [blame] | 83 | System.setProperty('android.dir', "${supportRootFolder}/../../") |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 84 | File props = file("local.properties") |
| 85 | props.write "android.dir=../../" |
Aurimas Liutikas | 3c66600 | 2017-03-08 19:30:28 -0800 | [diff] [blame] | 86 | ext.usingFullSdk = false |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 87 | } |
| 88 | } |
| 89 | |
| 90 | def setupRepoOutAndBuildNumber() { |
Yigit Boyar | ef30066 | 2017-05-01 11:52:07 -0700 | [diff] [blame] | 91 | // common support repo folder which works well for prebuilts. |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 92 | ext.supportRepoOut = '' |
Yigit Boyar | ef30066 | 2017-05-01 11:52:07 -0700 | [diff] [blame] | 93 | // files in artifactoryRepoOut can be safely copied into a real artifactory. |
| 94 | ext.artifactoryRepoOut = '' |
Aurimas Liutikas | 76542da | 2017-06-29 17:00:29 -0700 | [diff] [blame] | 95 | ext.buildNumber = "0" |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 96 | /* |
| 97 | * With the build server you are given two env variables. |
| 98 | * The OUT_DIR is a temporary directory you can use to put things during the build. |
| 99 | * The DIST_DIR is where you want to save things from the build. |
| 100 | * |
| 101 | * The build server will copy the contents of DIST_DIR to somewhere and make it available. |
| 102 | */ |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 103 | if (ext.runningInBuildServer) { |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 104 | buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build') |
| 105 | .getCanonicalFile() |
| 106 | project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile() |
| 107 | |
| 108 | // the build server does not pass the build number so we infer it from the last folder of |
| 109 | // the dist path. |
| 110 | ext.buildNumber = project.ext.distDir.getName() |
Aurimas Liutikas | a015004 | 2017-04-21 09:46:12 -0700 | [diff] [blame] | 111 | |
| 112 | // the build server should always print out full stack traces for any failures. |
| 113 | gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 114 | } else { |
| 115 | buildDir = file("${ext.supportRootFolder}/../../out/host/gradle/frameworks/support/build") |
| 116 | project.ext.distDir = new File("${ext.supportRootFolder}/../../out/dist") |
| 117 | } |
| 118 | subprojects { |
| 119 | // Change buildDir first so that all plugins pick up the new value. |
| 120 | project.buildDir = new File("$project.parent.buildDir/../$project.name/build") |
| 121 | } |
| 122 | ext.supportRepoOut = new File(buildDir, 'support_repo') |
Yigit Boyar | ef30066 | 2017-05-01 11:52:07 -0700 | [diff] [blame] | 123 | ext.artifactoryRepoOut = new File(buildDir, 'artifactory_repo') |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 124 | ext.testApkDistOut = ext.distDir |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 125 | ext.testResultsDistDir = new File(distDir, "host-test-reports") |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 126 | ext.docsDir = new File(buildDir, 'javadoc') |
| 127 | } |
| 128 | |
Aurimas Liutikas | 38e8f4d | 2017-06-16 08:31:03 -0700 | [diff] [blame] | 129 | def configureBuildOnServer() { |
| 130 | def buildOnServerTask = rootProject.tasks.create("buildOnServer") |
| 131 | rootProject.tasks.whenTaskAdded { task -> |
| 132 | if ("createArchive".equals(task.name)) { |
| 133 | buildOnServerTask.dependsOn task |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | subprojects { |
| 138 | project.tasks.whenTaskAdded { task -> |
| 139 | if ("assembleErrorProne".equals(task.name) || "assembleAndroidTest".equals(task.name)) { |
| 140 | buildOnServerTask.dependsOn task |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 146 | def configureSubProjects() { |
| 147 | // lint every library |
| 148 | def lintTask = project.tasks.create("lint") |
| 149 | subprojects { |
Aurimas Liutikas | 6509a1a | 2017-05-09 16:25:43 -0700 | [diff] [blame] | 150 | repos.addMavenRepositories(repositories) |
| 151 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 152 | // Only modify Android projects. |
Aurimas Liutikas | eca7a07 | 2017-07-11 01:11:52 +0000 | [diff] [blame] | 153 | if (project.name.equals('doclava') |
| 154 | || project.name.equals('jdiff') |
| 155 | || project.name.equals('support-testutils') |
Hyundo Moon | da9ee6b | 2017-07-21 14:32:12 +0900 | [diff] [blame] | 156 | || project.name.equals('noto-emoji-compat') |
| 157 | || project.name.equals('support-media-compat-test-lib')) { |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 158 | // disable tests and return |
| 159 | project.tasks.whenTaskAdded { task -> |
| 160 | if (task instanceof org.gradle.api.tasks.testing.Test) { |
| 161 | task.enabled = false |
| 162 | } |
| 163 | } |
| 164 | return |
| 165 | } |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 166 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 167 | project.ext.currentSdk = gradle.ext.currentSdk |
| 168 | apply plugin: 'maven' |
| 169 | |
Aurimas Liutikas | b938b2e | 2017-07-24 14:47:17 -0700 | [diff] [blame] | 170 | version = LibraryVersions.SUPPORT_LIBRARY.toString(); |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 171 | group = 'com.android.support' |
| 172 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 173 | project.plugins.whenPluginAdded { plugin -> |
| 174 | def isAndroidLibrary = "com.android.build.gradle.LibraryPlugin" |
| 175 | .equals(plugin.class.name) |
| 176 | def isAndroidApp = "com.android.build.gradle.AppPlugin".equals(plugin.class.name) |
| 177 | def isJavaLibrary = "org.gradle.api.plugins.JavaPlugin".equals(plugin.class.name) |
| 178 | |
| 179 | if (isAndroidLibrary || isAndroidApp) { |
| 180 | project.android.buildToolsVersion = rootProject.buildToolsVersion |
| 181 | |
| 182 | // Enable code coverage for debug builds only if we are not running inside the IDE, |
| 183 | // since enabling coverage reports breaks the method parameter resolution in the IDE |
| 184 | // debugger. |
| 185 | project.android.buildTypes.debug.testCoverageEnabled = |
Sergey Vasilinets | ac8e72b | 2017-04-26 15:55:17 -0700 | [diff] [blame] | 186 | !project.hasProperty('android.injected.invoked.from.ide') |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 187 | |
| 188 | // Copy the class files in a jar to be later used to generate code coverage report |
| 189 | project.android.testVariants.all { v -> |
| 190 | // check if the variant has any source files |
| 191 | // and test coverage is enabled |
| 192 | if (v.buildType.testCoverageEnabled |
| 193 | && v.sourceSets.any { !it.java.sourceFiles.isEmpty() }) { |
| 194 | def jarifyTask = project.tasks.create( |
| 195 | name: "package${v.name.capitalize()}ClassFilesForCoverageReport", |
| 196 | type: Jar) { |
| 197 | from v.testedVariant.javaCompile.destinationDir |
| 198 | exclude "**/R.class" |
| 199 | exclude "**/R\$*.class" |
| 200 | exclude "**/BuildConfig.class" |
| 201 | destinationDir file(project.distDir) |
Aurimas Liutikas | 76542da | 2017-06-29 17:00:29 -0700 | [diff] [blame] | 202 | archiveName "${project.name}-${v.baseName}-allclasses.jar" |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 203 | } |
Aurimas Liutikas | 21b7fce | 2017-06-23 09:52:08 -0700 | [diff] [blame] | 204 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 205 | def collectJacocoAntPackages = project.tasks.create( |
| 206 | name: "collectJacocoAntPackages", |
| 207 | type: Jar) { |
Aurimas Liutikas | 21b7fce | 2017-06-23 09:52:08 -0700 | [diff] [blame] | 208 | inputs.files project.configurations[JacocoPlugin.ANT_CONFIGURATION_NAME] |
| 209 | from { |
Aurimas Liutikas | 585a934 | 2017-06-25 16:07:56 -0700 | [diff] [blame] | 210 | project.configurations[JacocoPlugin.ANT_CONFIGURATION_NAME] |
| 211 | .resolvedConfiguration |
| 212 | .resolvedArtifacts.collect{ zipTree(it.getFile()) }} { |
Aurimas Liutikas | 21b7fce | 2017-06-23 09:52:08 -0700 | [diff] [blame] | 213 | // exclude all the signatures the jar might have |
| 214 | exclude "META-INF/*.SF" |
| 215 | exclude "META-INF/*.DSA" |
| 216 | exclude "META-INF/*.RSA" |
| 217 | } |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 218 | destinationDir file(project.distDir) |
Aurimas Liutikas | 21b7fce | 2017-06-23 09:52:08 -0700 | [diff] [blame] | 219 | archiveName "jacocoant.jar" |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 220 | } |
Aurimas Liutikas | 21b7fce | 2017-06-23 09:52:08 -0700 | [diff] [blame] | 221 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 222 | jarifyTask.dependsOn v.getJavaCompiler() |
Aurimas Liutikas | 21b7fce | 2017-06-23 09:52:08 -0700 | [diff] [blame] | 223 | v.assemble.dependsOn jarifyTask , collectJacocoAntPackages |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | // Enforce NewApi lint check as fatal. |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 228 | project.android.lintOptions.fatal 'NewApi' |
| 229 | lintTask.dependsOn project.lint |
| 230 | } |
| 231 | |
| 232 | if (isAndroidLibrary || isJavaLibrary) { |
| 233 | // Add library to the aggregate dependency report. |
| 234 | task allDeps(type: DependencyReportTask) {} |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 235 | |
Aurimas Liutikas | 6509a1a | 2017-05-09 16:25:43 -0700 | [diff] [blame] | 236 | project.afterEvaluate { |
| 237 | Upload uploadTask = (Upload) project.tasks.uploadArchives; |
| 238 | uploadTask.repositories.mavenDeployer { |
| 239 | |
| 240 | // Disable unique names for SNAPSHOTS so they can be updated in place. |
| 241 | setUniqueVersion(false) |
Aurimas Liutikas | fc24331 | 2017-05-12 14:21:13 -0700 | [diff] [blame] | 242 | } |
| 243 | uploadTask.doLast { |
Aurimas Liutikas | 6509a1a | 2017-05-09 16:25:43 -0700 | [diff] [blame] | 244 | // Remove any invalid maven-metadata.xml files that may have been |
| 245 | // created for SNAPSHOT versions that are *not* uniquely versioned. |
Aurimas Liutikas | fc24331 | 2017-05-12 14:21:13 -0700 | [diff] [blame] | 246 | repositories.mavenDeployer.pom*.each { pom -> |
Aurimas Liutikas | 6509a1a | 2017-05-09 16:25:43 -0700 | [diff] [blame] | 247 | if (pom.version.endsWith('-SNAPSHOT')) { |
| 248 | final File artifactDir = new File( |
| 249 | rootProject.ext.supportRepoOut, |
| 250 | pom.groupId.replace('.', '/') |
| 251 | + '/' + pom.artifactId |
| 252 | + '/' + pom.version) |
| 253 | delete fileTree(dir: artifactDir, |
| 254 | include: 'maven-metadata.xml*') |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 255 | } |
| 256 | } |
| 257 | } |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 258 | |
Aurimas Liutikas | 6509a1a | 2017-05-09 16:25:43 -0700 | [diff] [blame] | 259 | // create a release task that produces artifactory friends artifacts |
| 260 | // a.k.a. unique versions for snapshots with their maven-metadata files. |
| 261 | task artifactoryRelease(type : Upload) { |
| 262 | configuration = uploadTask.configuration |
| 263 | repositories { |
| 264 | mavenDeployer { |
| 265 | repository(url: uri("$rootProject.ext.artifactoryRepoOut")) |
| 266 | setUniqueVersion(true) |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // Before the upload, make sure the repo is ready. |
| 272 | uploadTask.dependsOn rootProject.tasks.prepareRepo |
| 273 | |
| 274 | artifactoryRelease.dependsOn uploadTask |
| 275 | |
| 276 | // Make the mainupload depend on this one. |
| 277 | mainUpload.dependsOn uploadTask |
| 278 | mainUpload.dependsOn artifactoryRelease |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 279 | } |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 283 | // Copy instrumentation test APKs and app APKs into the dist dir |
| 284 | // For test apks, they are uploaded only if we have java test sources. |
| 285 | // For regular app apks, they are uploaded only if they have java sources. |
| 286 | project.tasks.whenTaskAdded { task -> |
| 287 | if (task.name.startsWith("packageDebug")) { |
| 288 | def testApk = task.name.contains("AndroidTest") |
| 289 | task.doLast { |
| 290 | def source = testApk ? project.android.sourceSets.androidTest |
| 291 | : project.android.sourceSets.main |
Aurimas Liutikas | ef3b492 | 2017-06-28 10:44:59 -0700 | [diff] [blame] | 292 | if (task.hasProperty("outputDirectory") && !source.java.sourceFiles.isEmpty()) { |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 293 | copy { |
Aurimas Liutikas | ef3b492 | 2017-06-28 10:44:59 -0700 | [diff] [blame] | 294 | from(task.outputDirectory) |
| 295 | include '*.apk' |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 296 | into(rootProject.ext.testApkDistOut) |
| 297 | rename { String fileName -> |
| 298 | // multiple modules may have the same name so prefix the name with |
| 299 | // the module's path to ensure it is unique. |
| 300 | // e.g. palette-v7-debug-androidTest.apk becomes |
| 301 | // support-palette-v7_palette-v7-debug-androidTest.apk |
| 302 | "${project.getPath().replace(':', '-').substring(1)}_${fileName}" |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | // copy host side test results to DIST |
| 311 | project.tasks.whenTaskAdded { task -> |
| 312 | if (task instanceof org.gradle.api.tasks.testing.Test) { |
| 313 | def junitReport = task.reports.junitXml |
| 314 | if (junitReport.enabled) { |
| 315 | def zipTask = project.tasks.create(name : "zipResultsOf${task.name.capitalize()}", type : Zip) { |
| 316 | destinationDir(testResultsDistDir) |
Yigit Boyar | 278676d | 2017-03-10 15:29:11 -0800 | [diff] [blame] | 317 | // first one is always :, drop it. |
| 318 | archiveName("${project.getPath().split(":").join("_").substring(1)}.zip") |
Yigit Boyar | 7bfacb7 | 2017-03-02 14:27:41 -0800 | [diff] [blame] | 319 | } |
| 320 | if (project.rootProject.ext.runningInBuildServer) { |
| 321 | task.ignoreFailures = true |
| 322 | } |
| 323 | task.finalizedBy zipTask |
| 324 | task.doFirst { |
| 325 | zipTask.from(junitReport.destination) |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 331 | project.afterEvaluate { p -> |
| 332 | // remove dependency on the test so that we still get coverage even if some tests fail |
| 333 | p.tasks.findAll { it instanceof JacocoReportTask }.each { task -> |
| 334 | def toBeRemoved = new ArrayList() |
| 335 | def dependencyList = task.taskDependencies.values |
| 336 | dependencyList.each { dep -> |
| 337 | if (dep instanceof String) { |
| 338 | def t = tasks.findByName(dep) |
| 339 | if (t instanceof DeviceProviderInstrumentTestTask) { |
| 340 | toBeRemoved.add(dep) |
| 341 | task.mustRunAfter(t) |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | toBeRemoved.each { dep -> |
| 346 | dependencyList.remove(dep) |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | def setupRelease() { |
| 354 | apply from: "${ext.supportRootFolder}/buildSrc/release.gradle" |
| 355 | } |
| 356 | |
Yigit Boyar | 88c16ce | 2017-02-08 16:06:14 -0800 | [diff] [blame] | 357 | ext.init.enableDoclavaAndJDiff = this.&enableDoclavaAndJDiff |
| 358 | ext.init.setSdkInLocalPropertiesFile = this.&setSdkInLocalPropertiesFile |
| 359 | ext.init.setupRepoOutAndBuildNumber = this.&setupRepoOutAndBuildNumber |
| 360 | ext.init.setupRelease = this.&setupRelease |
Aurimas Liutikas | 38e8f4d | 2017-06-16 08:31:03 -0700 | [diff] [blame] | 361 | ext.init.configureSubProjects = this.&configureSubProjects |
Yigit Boyar | e1bbf71 | 2017-03-08 13:52:37 -0800 | [diff] [blame] | 362 | ext.init.configureBuildOnServer = this.&configureBuildOnServer |