plugins {
    id 'java'
    id 'application'
}

mainClassName = 'org.bdware.sc.ContractProcess'

sourceSets {
    main {
        java {
            srcDirs 'src/main/java', 'src/main/debugger', 'src/main/data-mask'
        }
        resources {
            srcDir 'src/main/resources'
        }
    }
    test {
        java {
            srcDirs 'src/test/java', 'src/test/data-mask'
        }
        resources {
            srcDir 'src/test/resources'
        }
    }
}

dependencies {
    implementation project(":common")
    implementation project(":mockjava")

    implementation 'com.atlassian.commonmark:commonmark:0.17.0'
    implementation 'com.idealista:format-preserving-encryption:1.0.0'
    implementation 'com.squareup.okhttp3:okhttp:4.9.1'
    implementation 'com.sun.mail:javax.mail:1.6.2'
    implementation 'org.apache.commons:commons-math3:3.6.1'
    implementation 'org.codehaus.groovy:groovy-all:3.0.8'
    implementation 'org.jsoup:jsoup:1.14.2'

    implementation fileTree(dir: 'lib', include: '*.jar')

    testImplementation 'junit:junit:4.13.2'
}

jar {
    String libs = ''
    configurations.runtimeClasspath.each {
        libs = libs + " libs/" + it.name
    }

    manifest {
        attributes 'Manifest-Version': project.version
        attributes 'Main-Class': mainClassName
        attributes 'Class-Path': libs
    }
}

tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
tasks.processTestResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)

task copyLibs(type: Copy, dependsOn: ":common:jar") {
    into "./build/output/libs/"
    from configurations.runtimeClasspath
}

task copyJar(type: Copy, dependsOn: ":cp:jar") {
    into "./build/output/"
    from "./build/libs/$project.name-${version}.jar"
    rename { String fileName -> "yjs.jar" }
}

task buildBundle(dependsOn: [":cp:copyLibs", ":cp:copyJar"]) {
    doLast {
        println "buildBundle in ./build/output/ successfully"
    }
}