/*
 * Copyright (c) 2019 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at:
 *
 *     https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
plugins {
  id 'java'
  id 'application'
  id 'org.eclipse.jkube.kubernetes' version '1.18.1'
  id 'org.eclipse.jkube.openshift' version '1.18.1'
  id 'com.github.johnrengelman.shadow' version '7.1.2'
}

group = 'org.eclipse.jkube.quickstarts.gradle'
version = '1.6.0-SNAPSHOT'
sourceCompatibility = '11'
def vertxVersion = '4.5.6'
def launcherClassName = 'io.vertx.core.Launcher'
def mainVerticleName = 'org.eclipse.jkube.quickstarts.gradle.vertx.MainVerticle'

def watchForChange = "src/**/*"
def doOnChange = "${projectDir}/gradlew classes"

repositories {
  mavenCentral()
}

application {
  mainClass.set(launcherClassName)
}

dependencies {
  implementation(platform("io.vertx:vertx-stack-depchain:$vertxVersion"))
  implementation "io.vertx:vertx-web:$vertxVersion"
}

kubernetes {
  enricher {
    config {
      'jkube-service' {
        type = 'NodePort'
      }
    }
  }
  generator {
      config {
          'vertx' {
              webPort = '8888'
          }
      }
  }
}

application {
  mainClass.set(launcherClassName)
}

java {
  sourceCompatibility = JavaVersion.VERSION_11
  targetCompatibility = JavaVersion.VERSION_11
}

shadowJar {
  archiveClassifier.set('fat')
  manifest {
    attributes 'Main-Verticle': mainVerticleName
  }
  mergeServiceFiles()
}

task runApp(type: JavaExec) {
  args = ["run", mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$launcherClassName", "--on-redeploy=$doOnChange"]
}

