/**
 * This build.gradle exists to publish our capsule (executable fat jar) to maven. It cannot be placed in the
 * node project because the bintray plugin cannot publish two modules from one project.
 */
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'us.kirchmeier.capsule'

description 'Corda standalone node'

repositories {
    mavenLocal()
    mavenCentral()
    maven {
        url 'http://oss.sonatype.org/content/repositories/snapshots'
    }
    jcenter()
    maven {
        url 'https://dl.bintray.com/kotlin/exposed'
    }
}

configurations {
    runtimeArtifacts.extendsFrom runtime
}

// Force the Caplet to target Java 6. This ensures that running 'java -jar corda.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

sourceSets {
    test {
        resources {
            srcDir "../../config/test"
        }
    }
    main {
        resources {
            srcDir "../../config/dev"
        }
    }
}

dependencies {
    compile project(':node')
}

task buildCordaJAR(type: FatCapsule, dependsOn: ['buildCertSigningRequestUtilityJAR']) {
    applicationClass 'net.corda.node.MainKt'
    archiveName "corda-${corda_version}.jar"
    applicationSource = files(project.tasks.findByName('jar'), '../build/classes/main/CordaCaplet.class', 'config/dev/log4j2.xml')

    capsuleManifest {
        appClassPath = ["jolokia-agent-war-${project.rootProject.ext.jolokia_version}.war"]
        javaAgents = ["quasar-core-${quasar_version}-jdk8.jar"]
        minJavaVersion = '1.8.0'
        caplets = ['CordaCaplet']
    }
}

task buildCertSigningRequestUtilityJAR(type: FatCapsule) {
    applicationClass 'net.corda.node.utilities.certsigning.CertificateSignerKt'
    archiveName 'certSigningRequestUtility.jar'
    capsuleManifest {
        systemProperties['log4j.configuration'] = 'log4j2.xml'
        minJavaVersion = '1.8.0'
    }
}

artifacts {
    runtimeArtifacts buildCordaJAR
    publish buildCordaJAR {
        classifier ""
    }
}

publish {
    name = 'corda'
    disableDefaultJar = true
}