buildscript {
  repositories {
    gradlePluginPortal()
    maven {
      url "https://repo.akka.io/maven"
    }
  }
}
plugins {
  id 'java'
  id 'application'
  id 'com.lightbend.akka.grpc.gradle' version '2.5.7'
}
repositories {
  mavenCentral()
  maven {
    url "https://repo.akka.io/maven"
  }
}

dependencies {
  implementation 'org.scala-lang:scala-library:2.13.15'

  implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.10.5'
  implementation 'com.typesafe.akka:akka-discovery_2.13:2.10.5'
  implementation 'com.typesafe.akka:akka-stream_2.13:2.10.5'
  implementation 'com.typesafe.akka:akka-pki_2.13:2.10.5'

  implementation 'ch.qos.logback:logback-classic:1.5.18'

  testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.10.5'
  testImplementation 'com.typesafe.akka:akka-stream-testkit_2.13:2.10.5'
  testImplementation 'junit:junit:4.13'
}

task runServer(type: JavaExec) {
  classpath = sourceSets.main.runtimeClasspath

  main = 'com.example.helloworld.GreeterServer'
}


task runClient(type: JavaExec) {
  classpath = sourceSets.main.runtimeClasspath

  main = 'com.example.helloworld.GreeterClient'

  // arguments to pass to the application
  if (project.hasProperty("GreeterClient.user"))
    args  project.getProperty("GreeterClient.user")
}

application {
  mainClassName = 'com.example.helloworld.GreeterServer'
}

allprojects {
  apply plugin: 'java'

  tasks.withType(Copy).all {
    duplicatesStrategy 'exclude'
  }
}
