version '1.0'

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 { url "http://maven.aliyun.com/nexus/content/groups/public/" }
    maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2"}
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    mavenLocal()
    mavenCentral()
}

def spring_version="4.3.30.RELEASE"
List spring =[ 
    "org.springframework:spring-core:$spring_version", 
    "org.springframework:spring-beans:$spring_version", 
    "org.springframework:spring-context:$spring_version", 
    "org.springframework:spring-tx:$spring_version", 
    "org.springframework:spring-jdbc:$spring_version", 
    "org.springframework:spring-web:$spring_version",
    "org.springframework:spring-webmvc:$spring_version"
]

List spring_boot =[ 
    "org.springframework.boot:spring-boot-starter-web:1.5.22.RELEASE",
    "org.springframework.boot:spring-boot-autoconfigure:1.5.22.RELEASE",
    "org.springframework.boot:spring-boot-configuration-processor:1.5.22.RELEASE",
]

List jaxb = [
     "javax.xml.bind:jaxb-api:2.3.0",
     "com.sun.xml.bind:jaxb-impl:2.3.0",
     "com.sun.xml.bind:jaxb-core:2.3.0",
     "javax.activation:activation:1.1.1",
     "javax.validation:validation-api:2.0.1.Final"
]

def log4j_version="2.17.2"
List logger = [
        "org.apache.logging.log4j:log4j-api:$log4j_version",
        "org.apache.logging.log4j:log4j-core:$log4j_version",
        "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version",
        "org.apache.logging.log4j:log4j-web:$log4j_version",
        "org.slf4j:jcl-over-slf4j:1.7.12"
]

List mysql = [
    'org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1',
    'mysql:mysql-connector-java:8.0.26'
]

List io = [
    'commons-io:commons-io:2.6',
    'commons-fileupload:commons-fileupload:1.4'
]

def jackson_version = "2.13.2"
List jackson = [
    "com.fasterxml.jackson.core:jackson-annotations:$jackson_version",
    "com.fasterxml.jackson.core:jackson-core:$jackson_version",
    "com.fasterxml.jackson.core:jackson-databind:2.13.2.2",
    "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
]

List swagger = [
    'io.springfox:springfox-swagger2:2.8.0',
    'io.springfox:springfox-swagger-ui:2.8.0'
]

dependencies {
    compile spring,spring_boot,jaxb,logger,mysql,io,jackson,swagger
    compile "com.github.briandilley.jsonrpc4j:jsonrpc4j:1.5.1"
    compile "org.apache.commons:commons-lang3:3.12.0"

    compile ('com.webank:data-export-sdk:1.7.7'){
        exclude group: 'ch.qos.logback', module: '*'
    }
    compile 'org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.9.0'

    annotationProcessor 'org.projectlombok:lombok:1.18.2'
    compileOnly 'org.projectlombok:lombok:1.18.2'
}

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'
}

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 '**/*.properties'

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