<commit_before>package com.earldouglas.xwp

import java.util.concurrent.atomic.AtomicReference
import sbt._
import sbt.Keys._

object ContainerPlugin extends AutoPlugin {

  lazy val quickstart = taskKey[Process]("quickstart container")
  lazy val start      = taskKey[Process]("start container")
  lazy val debug      = taskKey[Process]("start container in debug mode")
  lazy val join       = taskKey[Option[Int]]("join container")
  lazy val stop       = taskKey[Unit]("stop container")

  object autoImport {
    val Container = config("container").hide

    val debugOptions            = settingKey[Seq[String]]("debug options")

    val containerLibs           = settingKey[Seq[ModuleID]]("container libraries")
    val containerMain           = settingKey[String]("container main class")
    val containerPort           = settingKey[Int]("port number to be used by container")
    val containerConfigFile     = settingKey[Option[File]]("path of container configuration file")
    val containerArgs           = settingKey[Seq[String]]("additional container args")
    val containerForkOptions    = settingKey[ForkOptions]("fork options")
    val containerShutdownOnExit = settingKey[Boolean]("shutdown container on sbt exit")

    val containerLaunchCmd      = taskKey[Seq[String]]("command to launch container")
  }

  private lazy val containerInstance =
    settingKey[AtomicReference[Option[Process]]]("Current container process")

  import WebappPlugin.autoImport.webappPrepare
  import autoImport._

  override def requires = WarPlugin

  override val projectConfigurations = Seq(Container)

  override lazy val projectSettings =
    containerSettings(Container) ++
      inConfig(Container)(Seq(
        containerLibs := Nil
      , containerMain := ""
      ))

  def containerSettings(conf: Configuration) =
    baseContainerSettings ++
      Seq(libraryDependencies ++= (containerLibs in conf).value.map(_ % conf)) ++
      inConfig(conf)(Seq(
        start              := (startTask dependsOn webappPrepare).value
      , quickstart         := quickstartTask.value
      , debug              := (debugTask dependsOn webappPrepare).value
      , join               := joinTask.value
      , stop               := stopTask.value
      , onLoad in Global   := onLoadSetting.value
      , javaOptions        := (javaOptions in Compile).value
      , containerLaunchCmd <<= defaultLaunchCmd
      ))

  lazy val baseContainerSettings = Seq(
    containerPort           := -1
  , containerConfigFile     := None
  , containerArgs           := Nil
  , containerForkOptions    := new ForkOptions
  , containerInstance       := new AtomicReference(Option.empty[Process])
  , containerShutdownOnExit := true
  , debugOptions            := Seq( "-Xdebug"
                                  , "-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n"
                                  )
  )

  private def defaultLaunchCmd = Def.task {
    val portArg: Seq[String] = containerPort.value match {
      case p if p > 0 => Seq("--port", p.toString)
      case _ => Nil
    }

    val configArg: Seq[String] = containerConfigFile.value match {
      case Some(file) => Seq("--config", file.absolutePath)
      case None => Nil
    }<commit_msg>Clean up indentation<commit_after>package com.earldouglas.xwp

import java.util.concurrent.atomic.AtomicReference
import sbt._
import sbt.Keys._

object ContainerPlugin extends AutoPlugin {

  lazy val quickstart = taskKey[Process]("quickstart container")
  lazy val start      = taskKey[Process]("start container")
  lazy val debug      = taskKey[Process]("start container in debug mode")
  lazy val join       = taskKey[Option[Int]]("join container")
  lazy val stop       = taskKey[Unit]("stop container")

  object autoImport {
    val Container = config("container").hide

    val debugOptions            = settingKey[Seq[String]]("debug options")

    val containerLibs           = settingKey[Seq[ModuleID]]("container libraries")
    val containerMain           = settingKey[String]("container main class")
    val containerPort           = settingKey[Int]("port number to be used by container")
    val containerConfigFile     = settingKey[Option[File]]("path of container configuration file")
    val containerArgs           = settingKey[Seq[String]]("additional container args")
    val containerForkOptions    = settingKey[ForkOptions]("fork options")
    val containerShutdownOnExit = settingKey[Boolean]("shutdown container on sbt exit")

    val containerLaunchCmd      = taskKey[Seq[String]]("command to launch container")
  }

  private lazy val containerInstance =
    settingKey[AtomicReference[Option[Process]]]("Current container process")

  import WebappPlugin.autoImport.webappPrepare
  import autoImport._

  override def requires = WarPlugin

  override val projectConfigurations = Seq(Container)

  override lazy val projectSettings =
    containerSettings(Container) ++
      inConfig(Container)(Seq(
        containerLibs := Nil
      , containerMain := ""
      ))

  def containerSettings(conf: Configuration) =
    baseContainerSettings ++
      Seq(libraryDependencies ++= (containerLibs in conf).value.map(_ % conf)) ++
      inConfig(conf)(Seq(
        start              := (startTask dependsOn webappPrepare).value
      , quickstart         := quickstartTask.value
      , debug              := (debugTask dependsOn webappPrepare).value
      , join               := joinTask.value
      , stop               := stopTask.value
      , onLoad in Global   := onLoadSetting.value
      , javaOptions        := (javaOptions in Compile).value
      , containerLaunchCmd <<= defaultLaunchCmd
      ))

  lazy val baseContainerSettings =
    Seq( containerPort           := -1
       , containerConfigFile     := None
       , containerArgs           := Nil
       , containerForkOptions    := new ForkOptions
       , containerInstance       := new AtomicReference(Option.empty[Process])
       , containerShutdownOnExit := true
       , debugOptions            := Seq( "-Xdebug"
                                       , "-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n"
                                       )
       )

  private def defaultLaunchCmd = Def.task {
    val portArg: Seq[String] = containerPort.value match {
      case p if p > 0 => Seq("--port", p.toString)
      case _ => Nil
    }

    val configArg: Seq[String] = containerConfigFile.value match {
      case Some(file) => Seq("--config", file.absolutePath)
      case None => Nil
    }
{'fraction_non_alphanumeric': 0.09765028989929814, 'fraction_numerical': 0.00183094293561184, 'mean_word_length': 2.7759216589861753, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '370403', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1701, 'n_words': 422}