plugins {
    id 'java-library'
}

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

compileJava.options.encoding = "UTF-8"

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':axmlprinter')
    //implementation project(':apksigner')
    implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
}

sourceSets.main.java.srcDirs += "$rootProject.projectDir/apksigner/src/main/java"
sourceSets.main.java.srcDirs += "$rootProject.projectDir/apksigner/src/apksigner/java"

jar {
    baseName = "mmpatch"
    destinationDirectory = new File("$rootProject.projectDir/out")
    manifest {
        attributes 'Main-Class': 'com.storm.wind.xpatch.MainCommand'
    }
    dependsOn configurations.runtimeClasspath
    from {
        configurations.runtimeClasspath.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }

    from fileTree(dir: 'src/main', includes: ['assets/**'])

    exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF', 'META-INF/*.txt'
}

tasks.build.doLast {
    println("Build to " + jar.archivePath)
    println("Try \'java -jar " + jar.archiveName + "\' find more help")
}

sourceSets.main.resources {
    srcDirs = [
            "src/main/java",
    ];
    include "**/*.*"
}