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