group 'com.azimo.tool'
version '2.6'

def jarBasename = 'review-reporter'
def jarClassifier = 'assembly'
def jarArchiveName = jarBasename + "-" + version + "-" + jarClassifier + ".jar"

apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: "net.ltgt.apt"
apply plugin: 'idea'
apply plugin: "jacoco"
apply plugin: 'java'
apply plugin: 'maven-publish'

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "net.ltgt.gradle:gradle-apt-plugin:0.9"
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
    }
}

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    apt 'com.google.dagger:dagger-compiler:2.7'
    compile 'javax.inject:javax.inject:1'

    compile 'com.google.apis:google-api-services-androidpublisher:v2-rev38-1.22.0'

    compile 'com.squareup.retrofit2:retrofit:2.0.1'
    compile 'com.squareup.retrofit2:converter-gson:2.0.1'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.1'
    compile 'com.squareup.retrofit2:converter-scalars:2.0.1'

    compile 'io.reactivex:rxjava:1.1.5'

    compile 'com.squareup.okhttp3:okhttp:3.5.0'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.5.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'

    testCompile 'junit:junit:4.11'
    testCompile 'org.mockito:mockito-core:1.+'
    testCompile 'org.hamcrest:hamcrest-core:1.3'
    testCompile 'org.hamcrest:hamcrest-library:1.3'
    testCompile 'org.hamcrest:hamcrest-integration:1.3'
}

compileJava {
    targetCompatibility = JavaVersion.VERSION_1_8
    sourceCompatibility = JavaVersion.VERSION_1_8
}

jar {
    baseName = jarBasename
    archiveName = "review-reporter-" + version + ".jar"
    manifest {
        attributes 'Main-Class': 'com.azimo.tool.ReviewReporterService',
                'Implementation-Title': 'Azimo',
                'Implementation-Version': version
    }
}

jacocoTestReport {

    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it,
                    exclude: ['**/*Dagger*Component*.*',
                              '**/*_MembersInjector*.*',
                              '**/*_Factory*.*',
                              '**/*Provide*Factory*.*',
                              '**/*Module.*',
                              '**/*Module_*Factory.*',
                              '**/dagger/**',
                              '**/config/AppConfigKey.class',
                              '**/firebase/model/**',
                              '**/firebase/response/**',
                              '**/firebase/FirebaseIssueService.class',
                              '**/jira/JiraIssueService.class',
                              '**/jira/model/**',
                              '**/jira/response/**',
                              '**/publisher/model/**',
                              '**/publisher/AndroidPublisherBuilder.class',
                              '**/slack/model/**',
                              '**/slack/module/**',
                              '**/slack/response/**',
                              '**/slack/SlackService.class',
                              '**/task/base/**',
                              '**/task/interfaces/**',
                              '**/task/module/**'])
        })
    }
}

shadowJar {
    baseName = jarBasename
    classifier = jarClassifier
    archiveName = jarArchiveName
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
        attributes 'Main-Class': 'com.azimo.tool.ReviewReporterService'
    }
} 

publishing {
    repositories {
        maven {
            def mavenUserName = System.getenv('NEXUS_USER')
            def mavenPassword = System.getenv('NEXUS_PASSWORD')
            def mavenUrl = System.getenv('NEXUS_URL')

            if (mavenUserName != null && mavenPassword != null && mavenUrl != null) {
                credentials {
                    username mavenUserName
                    password mavenPassword
                }
                url mavenUrl
            }
        }
    }
    publications {
        mavenJava(MavenPublication) {
            artifactId jarBasename
            artifact shadowJar
        }
    }
}