apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.bmuschko.nexus'
apply plugin: 'maven-publish'

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
    }
}

sourceCompatibility = 1.8

jar {
    manifest {
        attributes 'Implementation-Title': 'Cyclops Reactor', 'Implementation-Version': version
    }
}

if (JavaVersion.current().isJava8Compatible()) {
    allprojects {
        tasks.withType(Javadoc) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }
    }
}

repositories {
    mavenCentral()
}

configurations {
    provided
    doc {
        transitive false
    }
    testArtifacts.extendsFrom testRuntime
}

dependencies {
    compile project(':cyclops')
    compile project(':cyclops-pure')
    compile project(':cyclops-anym')
    compile project(':cyclops-futurestream')
    compile project(':cyclops-reactive-collections')
    compile 'io.projectreactor:reactor-core:' + reactorVersion
    testCompile project(':cyclops-anym').sourceSets.test.output
    testCompile project(':cyclops').sourceSets.test.output
    provided group: 'org.projectlombok', name: 'lombok', version: lombokVersion

    testCompile 'commons-io:commons-io:2.4'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
    testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
    testCompile 'org.reactivestreams:reactive-streams-tck:1.0.0'
    testCompile 'org.assertj:assertj-core:3.2.0'
    testCompile 'com.github.stefanbirkner:system-rules:1.10.0'
    testCompile(group: 'org.hibernate', name: 'hibernate-core', version: '5.1.0.Final')
    testCompile (group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.1.0.Final')
}

sourceSets {
    main.compileClasspath += [configurations.provided]
    test.compileClasspath += [configurations.provided]
    test.runtimeClasspath += [configurations.provided]
}

eclipse.classpath.plusConfigurations += [configurations.provided]  // Eclipse users only

test {
    systemProperties 'property': 'value'
}

javadoc {
    source configurations.doc.collect { zipTree(it) }
    include '**/*.java'
    options.addStringOption('Xdoclint:none', '-quiet')
}

task packageTests(type: Jar) {
    from sourceSets.test.output
    classifier = 'tests'
}
test {
    reports.html.destination = file("$buildDir/reports/test")
    forkEvery = 100
    testLogging {
        events "started", "passed", "skipped", "failed"//, "standardOut", "standardError"
    }
}

artifacts {
    testArtifacts packageTests
}
//artifacts.archives packageTests

modifyPom {
    project {
        name 'cyclops-reactor'
        description 'Cyclops integrations for Reactor'
        url 'https://github.com/aol/cyclops'
        inceptionYear '2016'

        groupId 'com.oath.cyclops'
        artifactId 'cyclops-reactor-integration'
        version "$version"

        scm {
            url 'ssh://git@github.com:aol/cyclops.git'
            connection 'ssh://git@github.com:aol/cyclops.git'
            developerConnection 'ssh://git@github.com:aol/cyclops.git'
        }

        licenses {
            license {
                name 'The MIT License (MIT)'
                url 'https://github.com/oath/cyclops/blob/master/licence.txt'
                distribution 'repo'
            }
        }

        developers {
            developer {
                id 'johnmcclean'
                name 'John McClean'
                email 'john.mcclean@oath.com'
            }
        }
    }
}

extraArchive {
    sources = true
    tests = true
    javadoc = true
}

nexus {
    sign = true
    repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
    snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
}
