group = 'com.webank.webase'
version = '0.0.1-SNAPSHOT'

apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'

sourceCompatibility = 1.8
targetCompatibility = 1.8

[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'

// In this section you declare where to find the dependencies of your project
repositories {
    maven {
        jcenter()
        url "http://maven.aliyun.com/nexus/content/groups/public/"
    }
    mavenLocal()
    mavenCentral()
}

def springboot_version = "2.1.2.RELEASE"
List springboot = [
        "org.springframework.boot:spring-boot-starter-web:$springboot_version",
        "org.springframework.boot:spring-boot-starter-log4j2:$springboot_version"
]


List lombok = [
        "org.projectlombok:lombok:1.18.2"
]

List test = [
        "org.springframework.boot:spring-boot-starter-test:$springboot_version"
]


dependencies {
    compile springboot
    // compile "org.apache.commons:commons-lang3:3.8.1"
    compile "com.alibaba:fastjson:1.2.60"

    compile("org.bouncycastle:bcprov-jdk15on:1.60")
    implementation 'junit:junit:4.12'
    implementation 'junit:junit:4.12'

    compile 'com.google.code.gson:gson:2.6.2'

    // https://mvnrepository.com/artifact/de.scravy/pair
    compile group: 'de.scravy', name: 'pair', version: '1.1.0'


    compileOnly lombok

    testCompile test
}

configurations {
    all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    all*.exclude group: 'log4j', module: 'log4j'
    all*.exclude group: 'org.ow2.asm', module: 'asm'
    all*.exclude group: 'jline', module: 'jline'
    all*.exclude group: 'com.google.protobuf', module: 'protobuf-java'
    all*.exclude group: 'javax.annotation', module: 'javax.annotation-api'
}

sourceSets {
    main {
        java {
            srcDir 'src/main/java'
        }
        resources {
            srcDir 'src/main/resources'
        }
    }
}

clean {
    delete 'dist'
    delete 'build'
}


jar {
    destinationDir file('dist/apps')
    archiveName project.name + '.jar'
    exclude '**/*.xml'
    exclude '**/*.yml'
    exclude '**/*.properties'

    doLast {
        copy {
            from file('src/main/resources/')
            into 'dist/conf'
        }
        copy {
            from file('script/')
            into 'dist/script'
        }
        copy {
            from configurations.runtime
            into 'dist/lib'
        }
        copy {
            from file('.').listFiles().findAll { File f -> (f.name.endsWith('.bat') || f.name.endsWith('.sh') || f.name.endsWith('.env')) }
            into 'dist'
        }
    }
}
