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