plugins {
    id "java"
}

group = rootProject.group

task deploy(dependsOn: ["deployJarsForEmbulkTestMavenPlugin"])

/*
 * Following tasks are for building/deploying JARs for testing org.embulk.plugin.jar.TestJarPluginLoader
 */
task deployJarsForEmbulkTestMavenPlugin(
        type: Copy,
        dependsOn: ["buildFlatJarForEmbulkTestMavenPlugin", "buildDepsJarForEmbulkTestMavenPlugin"]) {
    from("$buildDir/libs") {
        include "**/embulk-test-maven-plugin-*.jar"
    }
    into "$buildDir/embulk-test-maven-plugin"
}

task buildFlatJarForEmbulkTestMavenPlugin(type: Jar) {
    from(sourceSets.main.runtimeClasspath) {
        include "org/embulk/plugin/jar/ExampleJarSpiV0.class"
        include "embulk-test-maven-plugin/main.txt"
    }
    manifest {
        attributes(
                "Manifest-Version": "1.0",
                "Embulk-Plugin-Spi-Version": "0",
                "Embulk-Plugin-Main-Class": "org.embulk.plugin.jar.ExampleJarSpiV0"
        )
    }
    archiveBaseName = "embulk-test-maven-plugin-flat"
}

task buildDepsJarForEmbulkTestMavenPlugin(type: Jar) {
    from(sourceSets.main.runtimeClasspath) {
        include "org/embulk/plugin/jar/ExampleDependencyJar.class"
        include "embulk-test-maven-plugin/deps.txt"
    }
    archiveBaseName = "embulk-test-maven-plugin-deps"
}
