apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

dependencies {
    testCompile 'commons-codec:commons-codec:1.13'
    testCompile 'org.apache.commons:commons-collections4:4.1'
    testCompile 'org.apache.commons:commons-imaging:1.0-alpha1'
    testCompile 'org.apache.commons:commons-lang3:3.9'
    testCompile 'com.jakewharton:disklrucache:2.0.2'
    testCompile 'com.squareup:javapoet:1.11.1'
    testCompile 'com.squareup:javawriter:2.5.1'
    testCompile 'joda-time:joda-time:2.10.5'
    testCompile 'org.joda:joda-convert:2.2.1'
    testCompile 'org.jsoup:jsoup:1.12.1'
    testCompile 'junit:junit:4.12'
    testCompile 'javax.jms:javax.jms-api:2.0.1'
    testCompile 'javax.mail:javax.mail-api:1.6.2'
    testCompile 'com.squareup.mimecraft:mimecraft:1.1.1'
    testCompile 'org.scribe:scribe:1.3.7'
    testCompile 'com.sparkjava:spark-core:2.9.1'
    testCompile 'log4j:log4j:1.2.17'
    testCompile 'com.google.guava:guava:12.0'
}

version='1.1.4'

tasks.withType(JavaCompile) {
    sourceCompatibility = targetCompatibility = '1.8'
    options.compilerArgs << '-Xlint:deprecation'
    options.compilerArgs << '-Xlint:unchecked'
    options.encoding = 'UTF-8'
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
    }
}

repositories {
    jcenter()
}

jar {
    manifest {
        attributes 'JD-Core-Version': version
    }
}

// Publication to JCenter Maven repository
task sourceJar(type: Jar) {
    classifier 'sources'
    from sourceSets.main.allJava
}

publishing {
    publications {
        publicationJdCore(MavenPublication) {
            groupId 'org.jd'
            artifactId 'jd-core'
            version project.version
            from components.java
            artifact tasks.sourceJar
        }
    }
}

bintray {
    // Command: gradlew -Dbintray.user=XXX -Dbintray.key=YYY bintrayUpload
    user = System.getProperty('bintray.user')
    key = System.getProperty('bintray.key')
    publications = ['publicationJdCore']

    dryRun = false //[Default: false] Whether to run this as dry-run, without deploying
    publish = true //[Default: false] Whether version should be auto published after an upload
    override = false //[Default: false] Whether to override version artifacts already published

    pkg {
        userOrg = 'java-decompiler'
        repo = 'maven'
        name = 'org.jd:jd-core'
        description = 'JD-Core is a JAVA decompiler written in JAVA.'
        licenses = ['GPL-3.0']

        websiteUrl = 'https://github.com/java-decompiler/jd-core'
        issueTrackerUrl = 'https://github.com/java-decompiler/jd-core/issues'
        vcsUrl = 'https://github.com/java-decompiler/jd-core.git'

        publicDownloadNumbers = true
        version {
            name = project.version
            released = new Date()
        }
    }
}

// 'cleanIdea' task extension //
cleanIdea.doFirst {
    delete project.name + '.iws'
    delete 'out'
    followSymlinks = true
}
