/**
 * This build.gradle exists to package Node Explorer as an executable fat jar.
 */
apply plugin: 'us.kirchmeier.capsule'
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'com.jfrog.artifactory'

description 'Node Explorer'

configurations {
    runtimeArtifacts.extendsFrom runtimeClasspath
}

// Force the Caplet to target Java 6. This ensures that running 'java -jar explorer.jar' on any Java 6 VM upwards
// will get as far as the Capsule version checks, meaning that if your JVM is too old, you will at least get
// a sensible error message telling you what to do rather than a bytecode version exception that doesn't.
// If we introduce .java files into this module that need Java 8+ then we will have to push the caplet into
// its own module so its target can be controlled individually, but for now this suffices.
sourceCompatibility = 1.6
targetCompatibility = 1.6

task buildExplorerJAR(type: FatCapsule, dependsOn: project(':tools:explorer').tasks.jar) {
    applicationClass 'net.corda.explorer.Main'
    archiveName "node-explorer-${corda_release_version}.jar"
    applicationSource = files(
        project(':tools:explorer').configurations.runtimeClasspath,
        project(':tools:explorer').tasks.jar,
        project(':tools:explorer').sourceSets.main.java.outputDir.toString() + '/ExplorerCaplet.class'
    )
    classifier 'fat'

    capsuleManifest {
        applicationVersion = corda_release_version
        systemProperties['visualvm.display.name'] = 'Node Explorer'
        minJavaVersion = '1.8.0'
        minUpdateVersion['1.8'] = java8_minUpdateVersion
        caplets = ['ExplorerCaplet']

        // JVM configuration:
        // - Switch to the G1 GC which is going to be the default in Java 9 and gives low pause times/string dedup.
        //
        jvmArgs = ['-XX:+UseG1GC']
    }
}

assemble.dependsOn buildExplorerJAR

artifacts {
    runtimeArtifacts buildExplorerJAR
    publish buildExplorerJAR {
        classifier ""
    }
}

jar {
    classifier "ignore"
    enabled = false
}

publish {
    disableDefaultJar = true
    name 'corda-tools-explorer'
}