<commit_before>ThisBuild / scalaVersion := "2.13.1"

enablePlugins(JooqCodegenPlugin)

Compile / run / description := "Compile/run"
Test / run / description := "Test/run"

lazy val subProj = project.settings(
  Compile / run / description := "subProj/Compile/run",
  Test / run / description := "subProj/Test/run"
)

// Set settings
Compile / jooqCodegenKeys := Seq(
  Compile / run / description,
  Test / run / description,
  subProj / Compile / run / description,
  subProj / Test / run / description
)

addJooqCodegenSettingsTo(Test)

// Append settings
Test / jooqCodegenKeys ++= Seq(
  Compile / run / description,
  Test / run / description,
  subProj / Compile / run / description,
  subProj / Test / run / description
)


lazy val myTask = taskKey[String]("")
myTask := s"myTask: ${math.random()}"

Compile / jooqCodegenKeys += CodegenKey(myTask)    // Append task
Compile / jooqCodegenKeys += baseDirectory         // Append setting
Compile / jooqCodegenKeys += "Answer" -> 42        // Append constant
Compile / jooqCodegenKeys ++= Map("foo" -> "bar")  // Append Map of constants
Compile / jooqCodegenKeys ++= Seq[CodegenKey](     // Append mixture values
  "hoge" -> "piyo",
  myTask,
  Compile / sourceManaged,
  LocalRootProject / baseDirectory,
  CodegenKey(baseDirectory).map(_ / "project").withName("PROJECT_DIR")
)


TaskKey[Unit]("check") := {
  def check(msg: String, actual: Map[String, String], expected: Map[String, String]): Unit = {
    if (actual != expected) {
      println(s"Actual: $actual")
      println(s"Expected: $expected")
      println(s"A - E: ${actual.toSeq.diff(expected.toSeq)}")
      println(s"E - A: ${expected.toSeq.diff(actual.toSeq)}")
      sys.error(msg)
    }
  }

  check(
    "Check variables in Compile",
    (Compile / jooqCodegenConfigVariables).value,
    Map(
      "run::description" -> "Compile/run",
      "compile:run::description" -> "Compile/run",

      "test:run::description" -> "Test/run",

      "subProj/run::description" -> "subProj/Compile/run",
      "subProj/compile:run::description" -> "subProj/Compile/run",

      "subProj/test:run::description" -> "subProj/Test/run",

      "myTask" -> myTask.value.toString,
      "baseDirectory" -> baseDirectory.value.toString,
      "Answer" -> "42",
      "foo" -> "bar",
      "hoge" -> "piyo",
      "sourceManaged" -> (Compile / sourceManaged).value.toString,
      "compile:sourceManaged" -> (Compile / sourceManaged).value.toString,
      "LocalRootProject/baseDirectory" -> baseDirectory.value.toString,
      "PROJECT_DIR" -> (baseDirectory.value / "project").toString
    ) ++ sys.env)

  check(
    "Check variables in Test",
    (Test / jooqCodegenConfigVariables).value,
    Map(
      "baseDirectory" -> baseDirectory.value.toString,
      "sourceManaged" -> (Test / sourceManaged).value.toString,
      "test:sourceManaged" -> (Test / sourceManaged).value.toString,

      "compile:run::description" -> "Compile/run",

      "run::description" -> "Test/run",
      "test:run::description" -> "Test/run",

      "subProj/compile:run::description" -> "subProj/Compile/run",

      "subProj/run::description" -> "subProj/Test/run",
      "subProj/test:run::description" -> "subProj/Test/run"
    ) ++ sys.env)

}<commit_msg>Fix scripted test<commit_after>ThisBuild / scalaVersion := "2.13.1"

enablePlugins(JooqCodegenPlugin)

Compile / run / description := "Compile/run"
Test / run / description := "Test/run"

lazy val subProj = project.settings(
  Compile / run / description := "subProj/Compile/run",
  Test / run / description := "subProj/Test/run"
)

// Set settings
Compile / jooqCodegenKeys := Seq(
  Compile / run / description,
  Test / run / description,
  subProj / Compile / run / description,
  subProj / Test / run / description
)

addJooqCodegenSettingsTo(Test)

// Append settings
Test / jooqCodegenKeys ++= Seq(
  Compile / run / description,
  Test / run / description,
  subProj / Compile / run / description,
  subProj / Test / run / description
)


lazy val myTask = taskKey[String]("")
myTask := s"myTask: ${math.random()}"

Compile / jooqCodegenKeys += CodegenKey(myTask)    // Append task
Compile / jooqCodegenKeys += baseDirectory         // Append setting
Compile / jooqCodegenKeys += "Answer" -> 42        // Append constant
Compile / jooqCodegenKeys ++= Map("foo" -> "bar")  // Append Map of constants
Compile / jooqCodegenKeys ++= Seq[CodegenKey](     // Append mixture values
  "hoge" -> "piyo",
  myTask,
  Compile / sourceManaged,
  LocalRootProject / baseDirectory,
  CodegenKey(baseDirectory).map(_ / "project").withName("PROJECT_DIR")
)


TaskKey[Unit]("check") := {
  def check(msg: String, actual: Map[String, String], expected: Map[String, String]): Unit = {
    if (actual != expected) {
      println(s"Actual: $actual")
      println(s"Expected: $expected")
      println(s"A - E: ${actual.toSeq.diff(expected.toSeq)}")
      println(s"E - A: ${expected.toSeq.diff(actual.toSeq)}")
      sys.error(msg)
    }
  }

  check(
    "Check variables in Compile",
    (Compile / jooqCodegenConfigVariables).value,
    Map(
      "run::description" -> "Compile/run",
      "compile:run::description" -> "Compile/run",

      "test:run::description" -> "Test/run",

      "subProj/run::description" -> "subProj/Compile/run",
      "subProj/compile:run::description" -> "subProj/Compile/run",

      "subProj/test:run::description" -> "subProj/Test/run",

      "myTask" -> myTask.value.toString,
      "baseDirectory" -> baseDirectory.value.toString,
      "Answer" -> "42",
      "foo" -> "bar",
      "hoge" -> "piyo",
      "sourceManaged" -> (Compile / sourceManaged).value.toString,
      "compile:sourceManaged" -> (Compile / sourceManaged).value.toString,
      "LocalRootProject/baseDirectory" -> baseDirectory.value.toString,
      "PROJECT_DIR" -> (baseDirectory.value / "project").toString
    ) ++ sys.env)

  check(
    "Check variables in Test",
    (Test / jooqCodegenConfigVariables).value,
    Map(
      "baseDirectory" -> baseDirectory.value.toString,
      "sourceManaged" -> (Test / sourceManaged).value.toString,
      "test:sourceManaged" -> (Test / sourceManaged).value.toString,
      "jooq-codegen:resourceDirectory" -> (JooqCodegen / resourceDirectory).value.toString,

      "compile:run::description" -> "Compile/run",

      "run::description" -> "Test/run",
      "test:run::description" -> "Test/run",

      "subProj/compile:run::description" -> "subProj/Compile/run",

      "subProj/run::description" -> "subProj/Test/run",
      "subProj/test:run::description" -> "subProj/Test/run"
    ) ++ sys.env)

}
{'fraction_non_alphanumeric': 0.16121212121212122, 'fraction_numerical': 0.0024242424242424242, 'mean_word_length': 3.234124438742784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1368266', 'n_tokens_mistral': 2223, 'n_tokens_neox': 2144, 'n_words': 415}