buildscript {
  ext {
    springBootVersion = '1.3.2.RELEASE'
  }
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath "se.transmode.gradle:gradle-docker:1.2"
  }
}

apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'docker'

jar {
  baseName = 'boot-react'
  version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
  mavenCentral()
  jcenter()
}

dependencies {
  compile 'org.springframework.boot:spring-boot-devtools'
  compile 'org.springframework.boot:spring-boot-starter-web'
  compile 'org.codehaus.groovy:groovy'
  compile 'org.zeroturnaround:zt-exec:1.9'

  compile 'org.springframework.boot:spring-boot-starter-security'
  compile 'org.springframework.session:spring-session'
  compile 'org.springframework.boot:spring-boot-starter-redis'

  testCompile 'org.springframework.boot:spring-boot-starter-test'
  testCompile 'org.springframework.security:spring-security-test'
  testCompile 'org.spockframework:spock-spring'
  testCompile 'com.geowarin:spring-spock-mvc:0.2.1'
}


eclipse {
  classpath {
    containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
    containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
  }
}

jar {
  from('../frontend/dist') {
    into 'static'
  }
}

jar.dependsOn(':frontend:assemble')

task buildDocker(type: Docker) {
  baseImage = 'develar/java:latest'
  push = false
  tag = 'geowarin/boot-react'
  addFile {
    from jar
    rename {'app.jar'}
  }
  entryPoint(['java', '-Djava.security.egd=file:/dev/./urandom', '-jar', '/app.jar'])
  exposePort(8080)
}

buildDocker.dependsOn(build)
