Home | History | Annotate | Download | only in robolectric-shadows
      1 import org.gradle.plugins.ide.idea.model.IdeaModel
      2 
      3 buildscript {
      4     repositories { jcenter() }
      5 
      6     dependencies {
      7         classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+'
      8         classpath 'ch.raffael.pegdown-doclet:pegdown-doclet:1.3'
      9     }
     10 }
     11 
     12 plugins {
     13     id "net.ltgt.apt" version "0.13" // automatic annotation processing
     14 }
     15 
     16 allprojects {
     17     repositories {
     18         mavenLocal()
     19         jcenter()
     20     }
     21 
     22     group = "org.robolectric"
     23     version = thisVersion
     24 }
     25 
     26 apply plugin: 'idea'
     27 apply plugin: 'net.ltgt.apt'
     28 
     29 project.ext.configAnnotationProcessing = []
     30 project.afterEvaluate {
     31     def ideaProject = rootProject.extensions.getByType(IdeaModel).project
     32     ideaProject.ipr.withXml { provider ->
     33         def compilerConfiguration = provider.asNode().component.find { it.'@name' == 'CompilerConfiguration' }
     34 
     35         // prevent compiler from complaining about duplicate classes...
     36         def excludeFromCompile = compilerConfiguration.appendNode 'excludeFromCompile'
     37         configAnnotationProcessing.each { Project subProject ->
     38             excludeFromCompile.appendNode('directory',
     39                     [url: "file://${subProject.buildDir}/classes/java/main/generated", includeSubdirectories: "true"])
     40         }
     41 
     42         // replace existing annotationProcessing tag with a new one...
     43         compilerConfiguration.annotationProcessing.replaceNode {
     44             annotationProcessing {
     45                 configAnnotationProcessing.each { Project subProject ->
     46                     profile(name: "${subProject.name}_main", enabled: "true") {
     47                         module(name: "${subProject.name}_main")
     48                         option(name: "org.robolectric.annotation.processing.shadowPackage",
     49                                 value: subProject.shadows.packageName)
     50                         processor(name: "org.robolectric.annotation.processing.RobolectricProcessor")
     51 
     52                         processorPath(useClasspath: "false") {
     53                             def processorRuntimeCfg = project.project(":processor").configurations['runtime']
     54                             processorRuntimeCfg.allArtifacts.each { artifact ->
     55                                 entry(name: artifact.file)
     56                             }
     57                             processorRuntimeCfg.files.each { file ->
     58                                 entry(name: file)
     59                             }
     60                         }
     61                     }
     62                 }
     63             }
     64         }
     65     }
     66 }
     67 
     68 apply plugin: 'nebula-aggregate-javadocs'
     69 apply plugin: 'ch.raffael.pegdown-doclet'
     70 
     71 rootProject.gradle.projectsEvaluated {
     72     rootProject.tasks['aggregateJavadocs'].failOnError = false
     73 }
     74 
     75 task aggregateTestReports(type: TestReport) {
     76     def jobNumber = System.getenv('TRAVIS_JOB_NUMBER')
     77     if (jobNumber == null) {
     78         destinationDir = file("$buildDir/reports/allTests")
     79     } else {
     80         destinationDir = file("$buildDir/reports/allTests/$jobNumber")
     81     }
     82 }
     83 
     84 task prefetchSdks() {
     85     AndroidSdk.ALL_SDKS.each { androidSdk ->
     86         def config = configurations.create("sdk${androidSdk.apiLevel}")
     87         dependencies.add("sdk${androidSdk.apiLevel}", androidSdk.coordinates)
     88         // causes dependencies to be resolved:
     89         config.files
     90     }
     91 }
     92 
     93 task prefetchDependencies() {
     94     dependsOn "prefetchSdks"
     95 
     96     doLast {
     97         allprojects.each { p ->
     98             ['compile', 'runtime', 'testCompile', 'testRuntime'].each { configName ->
     99                 if (p.configurations.findByName(configName)) {
    100                     // causes dependencies to be resolved:
    101                     p.configurations[configName].files
    102                 }
    103             }
    104         }
    105     }
    106 }
    107 
    108 // for use of external initialization scripts...
    109 project.ext.allSdks = AndroidSdk.ALL_SDKS
    110