apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'


group = 'com.henrypump.poc'
version = '1.0-SNAPSHOT'

description = """poc-java"""

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    maven { url "http://repo.maven.apache.org/maven2" }
}

dependencies {
    compile group: 'io.mraa', name: 'mraa', version:'1.5.1'
    compile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1.1'
    compile group: 'org.mongodb', name: 'mongodb-driver', version:'3.4.2'
    compile group: 'de.vandermeer', name: 'asciitable', version:'0.2.5'
    testCompile group: 'junit', name: 'junit', version:'3.8.1'
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.hidetake:gradle-ssh-plugin:2.7.2'
    }
}
apply plugin: 'org.hidetake.ssh'

remotes {
    edison {
        host = '192.168.2.15'
        user = 'root'
        identity = file('henryPumpDev')
    }
    edisonOP {
        host = '10.20.155.218'
        user = 'root'
        identity = file('henryPumpDev')
    }
}

//create a single Jar with all dependencies
task fatJar(type: Jar) {
    manifest {
        attributes 'Implementation-Title': 'POC Jar File',
                'Implementation-Version': version,
                'Main-Class': 'com.henrypump.poc.POC'
    }
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

task deployUSB << {
    ssh.run {
        session(remotes.edison) {
            put from: 'build/libs/poc-java-all-1.0-SNAPSHOT.jar', into: '/home/root'
        }
    }
}

task deployOP << {
    ssh.run {
        session(remotes.edisonOP) {
            put from: 'build/libs/poc-java-all-1.0-SNAPSHOT.jar', into: '/home/root'
        }
    }
}

task runRemote << {
    ssh.run {
        session(remotes.edison) {
            execute 'java -cp .:/usr/lib/java/*:poc-java-all-1.0-SNAPSHOT.jar com.henrypump.poc.POC kiesha7265Well.json kiesha7265_card_147_surface.csv true'
        }
    }
}

task runLocal(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath
    main = "com.henrypump.poc.POC"
    args 'kiesha7265Well.json', 'kiesha7265_card_147_surface.csv', 'false'
}