// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'java'
buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha07'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
    }
}

allprojects {
    group = GROUP
    version = VERSION_NAME
    repositories {
        jcenter()
        google()
    }
}

//task clean(type: Delete) {
//    delete rootProject.buildDir
//}

ext {
    rs = "org.reactivestreams:reactive-streams:1.0.2"
    reactor = "io.projectreactor:reactor-core:3.1.5.RELEASE"
    akkaStream = "com.typesafe.akka:akka-stream_2.12:2.5.11"
    rxjava1 = 'io.reactivex:rxjava:1.3.7'
    rxjava2 = 'io.reactivex.rxjava2:rxjava:2.1.12'
    rxrelay = 'com.jakewharton.rxrelay:rxrelay:1.2.0'
    junit = 'junit:junit:4.12'
    mockito = 'org.mockito:mockito-core:2.11.0'
    assertjCore2 = 'org.assertj:assertj-core:2.8.0'
    assertjCore3 = 'org.assertj:assertj-core:3.8.0'
    cucjava = 'info.cukes:cucumber-java:1.2.5'
    cucjunit = 'info.cukes:cucumber-junit:1.2.5'
    picocontainer = 'info.cukes:cucumber-picocontainer:1.2.5'

    javapoet = 'com.squareup:javapoet:1.9.0'
    javaparser = 'com.github.javaparser:javaparser-core:3.5.0'
    autoservice = 'com.google.auto.service:auto-service:1.0-rc3'
    autocommon = 'com.google.auto:auto-common:0.8'

    jmhCore = 'org.openjdk.jmh:jmh-core:1.19'
    jmhGen = 'org.openjdk.jmh:jmh-generator-annprocess:1.19'

}

task docs(type: Javadoc) {
    exclude "**/bindup/**"
    exclude "**/example/**"
    destinationDir = file("$buildDir/docs/all")
    options {
        links('http://docs.oracle.com/javase/7/docs/api/',
                'http://docs.oracle.com/javase/8/docs/api/',
                'http://www.reactive-streams.org/reactive-streams-1.0.0-javadoc',
                'http://reactivex.io/RxJava/1.x/javadoc/',
                'http://jakewharton.github.io/RxRelay/',
                'http://reactivex.io/RxJava/2.x/javadoc/',
                'https://projectreactor.io/core/docs/api/')
    }

    if (JavaVersion.current().isJava8Compatible()) {
        //options.addStringOption('Xdoclint:none', '-quiet')
    }
}

subprojects {
    afterEvaluate {
        if (plugins.hasPlugin(JavaPlugin)) {
            // configuration here
            rootProject.tasks.docs {
                source += files(sourceSets.collect { srcSet -> sourceSets.main.allJava })
                classpath += files(sourceSets*.compileClasspath)
            }

        }
    }
}

task publishJavaDocAll(type: Copy, dependsOn: docs) {
    from file("$buildDir/docs/all")
    into(rootProject.projectDir.absolutePath + '/docs/javadoc/' + VERSION_NAME + '/all')
}