plugins {
    id 'org.springframework.boot' version '2.6.1'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'com.github.sherter.google-java-format' version '0.8'
}

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

sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'org.example'
version = '1.0.0-SNAPSHOT'


repositories {
    mavenLocal()
    mavenCentral()
    maven { url "http://maven.aliyun.com/nexus/content/groups/public/"}
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    maven { url "https://oss.sonatype.org/service/local/staging/deploy/maven2"}
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
    all {
    }
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

def log4j_version="2.18.0"
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-to-slf4j:$log4j_version",
    //    "org.apache.logging.log4j:log4j-web:$log4j_version"
]

dependencies {
    implementation 'junit:junit:4.13.1'
    compile logger
    compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.0.0')
    compile ('org.springframework.boot:spring-boot-starter-web')
    compileOnly ('org.projectlombok:lombok')
    annotationProcessor ('org.projectlombok:lombok')

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation ('org.junit.jupiter:junit-jupiter-api:5.6.1')
    testRuntimeOnly ('org.junit.jupiter:junit-jupiter-engine:5.6.1')
}


sourceSets {
    main {
        java {
            srcDir 'src/main/java'
        }
        resources  {
            srcDir 'src/main/resources'
        }
    }
}
test {
    useJUnitPlatform()
}

bootJar {
    destinationDir file('dist')
    archiveName project.name + '-exec.jar'
    doLast {
        copy {
            from file('src/main/resources')
            into 'dist'
        }
    }
}

googleJavaFormat {
    options style: 'AOSP'
    source = sourceSets*.allJava
    include '**/*.java'
}

clean {
    println "delete ${projectDir}/dist"
    delete "${projectDir}/dist"
}
