
plugins {
  id 'application'
  id 'java'
}

repositories {
  mavenCentral()
}

sourceSets {
  main {
    java {
      srcDirs = ['src/main/java']
    }
  }
}

def appmapJar = "$System.env.AGENT_JAR"
def annotationJar = "$System.env.ANNOTATION_JAR"

if (!appmapJar || !annotationJar) {
  throw new GradleException("missing jars\n  appmapJar: ${appmapJar}\n  annotationJar: ${annotationJar}");
}

dependencies {
  //implementation 'org.apache.httpcomponents:httpclient:4.5.14'
  implementation 'org.apache.httpcomponents:fluent-hc:4.5.14'

  implementation files(appmapJar)
  implementation files(annotationJar)
}

application {
  // mainClass = 'http_client.HttpClientTest'
  mainClassName = project.hasProperty("mainClass") ? project.getProperty("mainClass") : "NULL"
  applicationDefaultJvmArgs = [
    System.env.JAVA_OUTPUT_OPTIONS,
    "-javaagent:${appmapJar}",
    "-Djava.util.logging.config.file=${System.env.JUL_CONFIG}",
    //"-Dappmap.debug=true",
    //"-Dappmap.debug.file=../../build/log/httpclient-appmap.log"
  ]

}
