override fun runRemoteCommand()

in jvmti-access/build.gradle.kts [180:204]


  override fun runRemoteCommand() {
    logger.debug("Creating container")
    val container = createContainer()
    try {

      logger.debug("Starting container with ID '${container.id}'.")
      dockerClient.startContainerCmd(container.id).exec()

      logger.debug("Following logs of container with ID '${container.id}'.")
      followContainerLogs(container)

      val containerWait = dockerClient.waitContainerCmd(container.id)
      val exitCode = containerWait.exec(WaitContainerResultCallback()).awaitStatusCode()

      logger.debug("Container exited with code $exitCode")

      if(exitCode != 0) {
        throw GradleException("Container exited with status code $exitCode, check the logs for details")
      }
    } finally {
      dockerClient.removeContainerCmd(container.id)
        .withForce(true)
        .exec()
    }
  }