Christian Williams | 6860bf6 | 2017-10-31 18:21:46 -0700 | [diff] [blame] | 1 | import org.gradle.plugins.ide.idea.model.IdeaModel |
| 2 | |
Christian Williams | 6a4bdde | 2017-10-30 18:52:44 -0700 | [diff] [blame] | 3 | buildscript { |
Jonathan Gerrish | bd69283 | 2018-02-19 11:13:00 -0800 | [diff] [blame] | 4 | repositories { |
| 5 | google() |
utzcoz | 1498087 | 2021-03-24 22:17:35 +0800 | [diff] [blame] | 6 | mavenCentral() |
Gautam Korlam | 32cec50 | 2018-04-29 19:00:53 -0700 | [diff] [blame] | 7 | gradlePluginPortal() |
Jonathan Gerrish | bd69283 | 2018-02-19 11:13:00 -0800 | [diff] [blame] | 8 | } |
Christian Williams | 6a4bdde | 2017-10-30 18:52:44 -0700 | [diff] [blame] | 9 | |
| 10 | dependencies { |
christianw | f662314 | 2019-03-08 15:10:39 -0800 | [diff] [blame] | 11 | gradle |
utzcoz | cc0177b | 2021-11-03 23:08:09 +0800 | [diff] [blame] | 12 | classpath 'com.android.tools.build:gradle:7.1.0-beta02' |
Al Sutton | 66ac9c9 | 2020-12-31 09:37:33 +0000 | [diff] [blame] | 13 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.3.0' |
| 14 | classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:3.0.1' |
utzcoz | 207c22d | 2021-04-01 00:59:09 +0800 | [diff] [blame] | 15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31" |
Al Sutton | 1b169eb | 2021-01-23 10:44:15 +0000 | [diff] [blame] | 16 | classpath "com.github.ben-manes:gradle-versions-plugin:0.36.0" |
Christian Williams | 6a4bdde | 2017-10-30 18:52:44 -0700 | [diff] [blame] | 17 | } |
| 18 | } |
| 19 | |
Christian Williams | 3ccf232 | 2016-06-20 17:14:58 -0700 | [diff] [blame] | 20 | allprojects { |
| 21 | repositories { |
Brett Chabot | 38cada5 | 2018-02-21 12:28:51 -0800 | [diff] [blame] | 22 | google() |
Christian Williams | 9dc1af1 | 2018-10-09 16:30:50 -0700 | [diff] [blame] | 23 | mavenCentral() |
utzcoz | 1498087 | 2021-03-24 22:17:35 +0800 | [diff] [blame] | 24 | gradlePluginPortal() |
Christian Williams | 3ccf232 | 2016-06-20 17:14:58 -0700 | [diff] [blame] | 25 | } |
| 26 | |
Jared Burrows | 75ca578 | 2016-07-19 19:51:10 -0700 | [diff] [blame] | 27 | group = "org.robolectric" |
Christian Williams | 023e43e | 2017-01-09 12:04:31 -0800 | [diff] [blame] | 28 | version = thisVersion |
Christian Williams | 3ccf232 | 2016-06-20 17:14:58 -0700 | [diff] [blame] | 29 | } |
Christian Williams | 00b1f7b | 2017-01-06 18:15:35 -0800 | [diff] [blame] | 30 | |
Christian Williams | 6a4bdde | 2017-10-30 18:52:44 -0700 | [diff] [blame] | 31 | apply plugin: 'idea' |
Al Sutton | 1b169eb | 2021-01-23 10:44:15 +0000 | [diff] [blame] | 32 | apply plugin: 'com.github.ben-manes.versions' |
Christian Williams | 00b1f7b | 2017-01-06 18:15:35 -0800 | [diff] [blame] | 33 | |
Christian Williams | 6860bf6 | 2017-10-31 18:21:46 -0700 | [diff] [blame] | 34 | project.ext.configAnnotationProcessing = [] |
| 35 | project.afterEvaluate { |
| 36 | def ideaProject = rootProject.extensions.getByType(IdeaModel).project |
| 37 | ideaProject.ipr.withXml { provider -> |
| 38 | def compilerConfiguration = provider.asNode().component.find { it.'@name' == 'CompilerConfiguration' } |
| 39 | |
| 40 | // prevent compiler from complaining about duplicate classes... |
| 41 | def excludeFromCompile = compilerConfiguration.appendNode 'excludeFromCompile' |
| 42 | configAnnotationProcessing.each { Project subProject -> |
| 43 | excludeFromCompile.appendNode('directory', |
| 44 | [url: "file://${subProject.buildDir}/classes/java/main/generated", includeSubdirectories: "true"]) |
| 45 | } |
| 46 | |
| 47 | // replace existing annotationProcessing tag with a new one... |
| 48 | compilerConfiguration.annotationProcessing.replaceNode { |
| 49 | annotationProcessing { |
| 50 | configAnnotationProcessing.each { Project subProject -> |
| 51 | profile(name: "${subProject.name}_main", enabled: "true") { |
| 52 | module(name: "${subProject.name}_main") |
| 53 | option(name: "org.robolectric.annotation.processing.shadowPackage", |
| 54 | value: subProject.shadows.packageName) |
| 55 | processor(name: "org.robolectric.annotation.processing.RobolectricProcessor") |
| 56 | |
| 57 | processorPath(useClasspath: "false") { |
| 58 | def processorRuntimeCfg = project.project(":processor").configurations['runtime'] |
| 59 | processorRuntimeCfg.allArtifacts.each { artifact -> |
| 60 | entry(name: artifact.file) |
| 61 | } |
| 62 | processorRuntimeCfg.files.each { file -> |
| 63 | entry(name: file) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
Christian Williams | 00b1f7b | 2017-01-06 18:15:35 -0800 | [diff] [blame] | 73 | apply plugin: 'nebula-aggregate-javadocs' |
Christian Williams | 5209dc6 | 2017-04-26 12:01:56 -0700 | [diff] [blame] | 74 | |
Christian Williams | 00b1f7b | 2017-01-06 18:15:35 -0800 | [diff] [blame] | 75 | rootProject.gradle.projectsEvaluated { |
| 76 | rootProject.tasks['aggregateJavadocs'].failOnError = false |
| 77 | } |
Christian Williams | 0ef6a41 | 2017-01-09 18:00:32 -0800 | [diff] [blame] | 78 | |
Christian Williams | 9590ed9 | 2019-01-24 19:24:33 -0800 | [diff] [blame] | 79 | gradle.projectsEvaluated { |
Christian Williams | eeb38e4 | 2019-01-25 10:58:18 -0800 | [diff] [blame] | 80 | def headerHtml = "<ul class=\"navList\" style=\"font-size: 1.5em;\"><li>Robolectric $thisVersion |" + |
| 81 | " <a href=\"/\" target=\"_top\">" + |
| 82 | "<img src=\"http://robolectric.org/images/logo-with-bubbles-down.png\"" + |
| 83 | " style=\"max-height: 18pt; vertical-align: sub;\"/></a></li></ul>" |
| 84 | project.allprojects { p -> |
| 85 | p.tasks.withType(Javadoc) { |
| 86 | options { |
| 87 | noTimestamp = true |
| 88 | links = [ |
| 89 | "https://docs.oracle.com/javase/8/docs/api/", |
| 90 | "https://developer.android.com/reference/", |
| 91 | ] |
utzcoz | 65e6735 | 2021-09-30 21:54:22 +0800 | [diff] [blame] | 92 | // Set javadoc source to JDK 8 to avoid unnamed module problem |
| 93 | // when running aggregateJavadoc with OpenJDK 13+. |
| 94 | source("8") |
Christian Williams | eeb38e4 | 2019-01-25 10:58:18 -0800 | [diff] [blame] | 95 | header = headerHtml |
| 96 | footer = headerHtml |
utzcoz | 67f5671 | 2021-09-30 21:55:17 +0800 | [diff] [blame] | 97 | // bottom = "<link rel=\"stylesheet\" href=\"http://robolectric.org/assets/css/main.css\">" |
Christian Williams | eeb38e4 | 2019-01-25 10:58:18 -0800 | [diff] [blame] | 98 | version = thisVersion |
| 99 | } |
| 100 | } |
Christian Williams | 9590ed9 | 2019-01-24 19:24:33 -0800 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | |
| 104 | task aggregateJsondocs(type: Copy) { |
Christian Williams | e9aec43 | 2019-02-06 16:12:45 -0800 | [diff] [blame] | 105 | gradle.projectsEvaluated { |
| 106 | project.subprojects.findAll { it.plugins.hasPlugin(ShadowsPlugin) }.each { subproject -> |
| 107 | dependsOn subproject.tasks["compileJava"] |
| 108 | from "${subproject.buildDir}/docs/json" |
| 109 | } |
Christian Williams | 9590ed9 | 2019-01-24 19:24:33 -0800 | [diff] [blame] | 110 | } |
| 111 | into "$buildDir/docs/json" |
| 112 | } |
| 113 | |
| 114 | task aggregateDocs { |
| 115 | dependsOn ':aggregateJavadocs' |
| 116 | dependsOn ':aggregateJsondocs' |
| 117 | } |
| 118 | |
Christian Williams | 65b0975 | 2019-03-08 14:41:55 -0800 | [diff] [blame] | 119 | // aggregate test results from all projects... |
Christian Williams | 8e9e0ae | 2017-04-04 13:35:08 -0700 | [diff] [blame] | 120 | task aggregateTestReports(type: TestReport) { |
| 121 | def jobNumber = System.getenv('TRAVIS_JOB_NUMBER') |
| 122 | if (jobNumber == null) { |
| 123 | destinationDir = file("$buildDir/reports/allTests") |
| 124 | } else { |
| 125 | destinationDir = file("$buildDir/reports/allTests/$jobNumber") |
| 126 | } |
| 127 | } |
| 128 | |
Christian Williams | 65b0975 | 2019-03-08 14:41:55 -0800 | [diff] [blame] | 129 | afterEvaluate { |
| 130 | def aggregateTestReportsTask = rootProject.tasks['aggregateTestReports'] |
| 131 | |
| 132 | allprojects.each { p -> |
| 133 | p.afterEvaluate { |
| 134 | p.tasks.withType(Test) { t -> |
| 135 | aggregateTestReportsTask.reportOn binResultsDir |
| 136 | finalizedBy aggregateTestReportsTask |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | |
Christian Williams | 95cf907 | 2017-10-20 17:36:30 -0700 | [diff] [blame] | 142 | task prefetchSdks() { |
Christian Williams | 95cf907 | 2017-10-20 17:36:30 -0700 | [diff] [blame] | 143 | AndroidSdk.ALL_SDKS.each { androidSdk -> |
Christian Williams | 670ba52 | 2018-11-29 11:39:29 -0800 | [diff] [blame] | 144 | doLast { |
Michael Hoisie | 08853c7 | 2021-10-19 15:13:53 -0700 | [diff] [blame] | 145 | println("Prefetching ${androidSdk.coordinates}...") |
| 146 | // prefetch into maven local repo... |
| 147 | def mvnCommand = "mvn -q dependency:get -DrepoUrl=http://maven.google.com \ |
| 148 | -DgroupId=${androidSdk.groupId} -DartifactId=${androidSdk.artifactId} \ |
| 149 | -Dversion=${androidSdk.version}" |
| 150 | shellExec(mvnCommand) |
| 151 | |
| 152 | // prefetch into gradle local cache... |
| 153 | def config = configurations.create("sdk${androidSdk.apiLevel}") |
| 154 | dependencies.add("sdk${androidSdk.apiLevel}", androidSdk.coordinates) |
| 155 | // causes dependencies to be resolved: |
| 156 | config.files |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | task prefetchInstrumentedSdks() { |
| 162 | AndroidSdk.ALL_SDKS.each { androidSdk -> |
| 163 | doLast { |
hoisie | 765e075 | 2021-02-17 16:39:13 -0800 | [diff] [blame] | 164 | println("Prefetching ${androidSdk.preinstrumentedCoordinates}...") |
Christian Williams | 670ba52 | 2018-11-29 11:39:29 -0800 | [diff] [blame] | 165 | // prefetch into maven local repo... |
| 166 | def mvnCommand = "mvn -q dependency:get -DrepoUrl=http://maven.google.com \ |
hoisie | 765e075 | 2021-02-17 16:39:13 -0800 | [diff] [blame] | 167 | -DgroupId=${androidSdk.groupId} -DartifactId=${androidSdk.preinstrumentedArtifactId} \ |
| 168 | -Dversion=${androidSdk.preinstrumentedVersion}" |
Christian Williams | 670ba52 | 2018-11-29 11:39:29 -0800 | [diff] [blame] | 169 | shellExec(mvnCommand) |
| 170 | |
| 171 | // prefetch into gradle local cache... |
| 172 | def config = configurations.create("sdk${androidSdk.apiLevel}") |
hoisie | 765e075 | 2021-02-17 16:39:13 -0800 | [diff] [blame] | 173 | dependencies.add("sdk${androidSdk.apiLevel}", androidSdk.preinstrumentedCoordinates) |
Christian Williams | 670ba52 | 2018-11-29 11:39:29 -0800 | [diff] [blame] | 174 | // causes dependencies to be resolved: |
| 175 | config.files |
| 176 | } |
Christian Williams | 95cf907 | 2017-10-20 17:36:30 -0700 | [diff] [blame] | 177 | } |
Christian Williams | 95cf907 | 2017-10-20 17:36:30 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Christian Williams | 670ba52 | 2018-11-29 11:39:29 -0800 | [diff] [blame] | 180 | private void shellExec(String mvnCommand) { |
| 181 | def process = mvnCommand.execute() |
| 182 | def out = new StringBuffer() |
| 183 | def err = new StringBuffer() |
| 184 | process.consumeProcessOutput(out, err) |
| 185 | process.waitFor() |
| 186 | if (out.size() > 0) println out |
| 187 | if (err.size() > 0) println err |
| 188 | if (process.exitValue() != 0) System.exit(1) |
| 189 | } |
| 190 | |
Christian Williams | 5c70840 | 2017-11-01 09:33:11 -0700 | [diff] [blame] | 191 | task prefetchDependencies() { |
Christian Williams | 5c70840 | 2017-11-01 09:33:11 -0700 | [diff] [blame] | 192 | doLast { |
| 193 | allprojects.each { p -> |
Gautam Korlam | 32cec50 | 2018-04-29 19:00:53 -0700 | [diff] [blame] | 194 | p.configurations.each { config -> |
| 195 | // causes dependencies to be resolved: |
| 196 | if (config.isCanBeResolved()) { |
christianw | f662314 | 2019-03-08 15:10:39 -0800 | [diff] [blame] | 197 | try { |
| 198 | config.files |
utzcoz | 659ddd9 | 2021-02-15 23:00:07 +0800 | [diff] [blame] | 199 | } catch (ResolveException e) { |
utzcoz | 4dd6611 | 2021-05-26 21:23:48 +0800 | [diff] [blame] | 200 | // ignore resolution issues for integration tests and test app, sigh |
| 201 | if (!p.path.startsWith(":integration_tests:") |
| 202 | && !p.path.startsWith(":testapp")) { |
christianw | f662314 | 2019-03-08 15:10:39 -0800 | [diff] [blame] | 203 | throw e |
| 204 | } |
| 205 | } |
Christian Williams | 5c70840 | 2017-11-01 09:33:11 -0700 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | } |
| 209 | } |
Christian Williams | 95cf907 | 2017-10-20 17:36:30 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Christian Williams | 0ef6a41 | 2017-01-09 18:00:32 -0800 | [diff] [blame] | 212 | // for use of external initialization scripts... |
Christian Williams | 814382f | 2017-01-11 15:35:10 -0800 | [diff] [blame] | 213 | project.ext.allSdks = AndroidSdk.ALL_SDKS |