import com.jprofiler.gradle.JavaProfile

plugins {
    id 'com.jprofiler' version '16.2.1'
    id 'java'
}

// Execute ../gradlew in this directory to Compile and run the offline profiling sample code.
// See src/main/java/TestProgram.java for more information.

jprofiler {
    installDir = jprofilerHome
}
defaultTasks 'run'

dependencies {
    // This artifact contains the controller API, it is also available in the "$JPROFILER_HOME/api" directory
    implementation "com.jprofiler:jprofiler-controller:$version"
}

task run(type: JavaProfile) {
    mainClass = 'TestProgram'
    classpath sourceSets.main.runtimeClasspath
    offline = true
    sessionId = 80
    configFile = file('../common/jprofiler_config.xml')
    // This is the directory where the JProfiler snapshots will be saved
    workingDir = file(findProperty('snapshotsDir') ?: layout.buildDirectory.dir("snapshots").get().asFile)
    workingDir.mkdirs()
    // If you change this parameter to 'true', the test program will trigger heap dumps for the snapshot files
    args 'false'
}