<commit_before>import java.io.FileOutputStream
import java.net.URLClassLoader
import org.apache.commons.io.IOUtils
import sbt._
import sbt.Keys.{classDirectory, fullClasspath, resolvers, libraryDependencies}
import Resolvers._

object Sandbox extends Plugin {

  def sandPrj(name: String, version: String): (Project, ScopeFilter) = (
    Project(name, file(s"sandbox/$name"))
      .settings(libraryDependencies ++= Seq("dvla" %% name % version))
      .settings(resolvers ++= projectResolvers)
      .settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*),
    ScopeFilter(inProjects(LocalProject(name)), inConfigurations(Runtime))
    )

  lazy val (osAddressLookup, scopeOsAddressLookup) = sandPrj("os-address-lookup", "0.1")
  lazy val (vehiclesLookup, scopeVehiclesLookup) = sandPrj("vehicles-lookup", "0.1")
  lazy val (vehiclesDisposeFulfil, scopeVehiclesDisposeFulfil) = sandPrj("vehicles-dispose-fulfil", "0.1")

  lazy val sandboxedProjects = Seq(osAddressLookup, vehiclesLookup, vehiclesDisposeFulfil)

  lazy val vehiclesOnline = ScopeFilter(inProjects(ThisProject), inConfigurations(Runtime))

  lazy val sandbox = taskKey[Unit]("Runs the sandbox'")
  lazy val sandboxTask = sandbox := {

    def runPrj(prjClassPath: Seq[Attributed[File]], classDirectory: File, props: String, fileName: String): Thread = {
      val prjClassloader = new URLClassLoader(
        prjClassPath.map(_.data.toURI.toURL).toArray,
        this.getClass.getClassLoader.getParent.getParent
      )
      val f = new java.io.File(classDirectory, fileName)
      f.getParentFile.mkdirs()
      IOUtils.write(props, new FileOutputStream(f))

      val t = new Thread() {
        override def run() {
          Thread.currentThread().setContextClassLoader(prjClassloader)

          import scala.reflect.runtime.universe.runtimeMirror
          import scala.reflect.runtime.universe.newTermName
          lazy val mirror = runtimeMirror(prjClassloader)
          val bootSymbol = mirror.staticModule("dvla.microservice.Boot").asModule
          val boot = mirror.reflectModule(bootSymbol).instance
          val mainMethodSymbol = bootSymbol.typeSignature.member(newTermName("main")).asMethod
          val bootMirror = mirror.reflect(boot)
          bootMirror.reflectMethod(mainMethodSymbol).apply(Array[String]())
        }
      }
      t.start()
      t
    }

    val cpVehiclesOnline = fullClasspath.all(vehiclesOnline).value.flatten
    val cpVehiclesLookup = fullClasspath.all(scopeVehiclesLookup).value.flatten
    val cpeVehiclesDisposeFulfil = fullClasspath.all(scopeVehiclesDisposeFulfil).value.flatten

    runPrj(
      fullClasspath.all(scopeOsAddressLookup).value.flatten,
      classDirectory.all(scopeOsAddressLookup).value.head,
      """ordnancesurvey.requesttimeout = "9999"
        |ordnancesurvey.apiversion = "testing"
        |ordnancesurvey.beta06.username = "testUser"
        |ordnancesurvey.beta06.password = "<PASSWORD>"
        |ordnancesurvey.beta06.baseurl = "https://localhost/ord-serv:1234"
        |ordnancesurvey.preproduction.apikey = "someApiKey"
        |ordnancesurvey.preproduction.baseurl = "http://baseUrl"""".stripMargin,
      "os-address-lookup"
    ).join()
  }
}<commit_msg>All the micro services are started as part of the sandbox<commit_after>import java.io.FileOutputStream
import java.net.URLClassLoader
import org.apache.commons.io.IOUtils
import sbt._
import sbt.Keys.{classDirectory, fullClasspath, resolvers, libraryDependencies}
import Resolvers._

object Sandbox extends Plugin {

  def sandPrj(name: String, version: String): (Project, ScopeFilter) = (
    Project(name, file(s"target/sandbox/$name"))
      .settings(libraryDependencies ++= Seq("dvla" %% name % version))
      .settings(resolvers ++= projectResolvers)
      .settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*),
    ScopeFilter(inProjects(LocalProject(name)), inConfigurations(Runtime))
  )

  lazy val (osAddressLookup, scopeOsAddressLookup) = sandPrj("os-address-lookup", "0.1")
  lazy val (vehiclesLookup, scopeVehiclesLookup) = sandPrj("vehicles-lookup", "0.1")
  lazy val (vehiclesDisposeFulfil, scopeVehiclesDisposeFulfil) = sandPrj("vehicles-dispose-fulfil", "0.1")

  lazy val sandboxedProjects = Seq(osAddressLookup, vehiclesLookup, vehiclesDisposeFulfil)

  lazy val vehiclesOnline = ScopeFilter(inProjects(ThisProject), inConfigurations(Runtime))

  lazy val sandbox = taskKey[Unit]("Runs the sandbox'")
  lazy val sandboxTask = sandbox := {

    def runPrj(prjClassPath: Seq[Attributed[File]], classDirectory: File, props: String, fileName: String): Unit = {
      val prjClassloader = new URLClassLoader(
        prjClassPath.map(_.data.toURI.toURL).toArray,
        this.getClass.getClassLoader.getParent.getParent
      )
      val f = new java.io.File(classDirectory, s"$fileName.conf")
      f.getParentFile.mkdirs()
      IOUtils.write(props, new FileOutputStream(f))

          Thread.currentThread().setContextClassLoader(prjClassloader)

          import scala.reflect.runtime.universe.runtimeMirror
          import scala.reflect.runtime.universe.newTermName
          lazy val mirror = runtimeMirror(prjClassloader)
          val bootSymbol = mirror.staticModule("dvla.microservice.Boot").asModule
          val boot = mirror.reflectModule(bootSymbol).instance
          val mainMethodSymbol = bootSymbol.typeSignature.member(newTermName("main")).asMethod
          val bootMirror = mirror.reflect(boot)
          bootMirror.reflectMethod(mainMethodSymbol).apply(Array[String]())
    }

    runPrj(
      fullClasspath.all(scopeOsAddressLookup).value.flatten,
      classDirectory.all(scopeOsAddressLookup).value.head,
      """ordnancesurvey.requesttimeout = "9999"
        |ordnancesurvey.apiversion = "testing"
        |ordnancesurvey.beta06.username = "testUser"
        |ordnancesurvey.beta06.password = "<PASSWORD>"
        |ordnancesurvey.beta06.baseurl = "https://localhost/ord-serv:1234"
        |ordnancesurvey.preproduction.apikey = "someApiKey"
        |ordnancesurvey.preproduction.baseurl = "http://baseUrl"""".stripMargin,
      osAddressLookup.id
    )
    runPrj(
      fullClasspath.all(scopeVehiclesLookup).value.flatten,
      classDirectory.all(scopeVehiclesLookup).value.head,
      """getVehicleDetails.baseurl = "http://localhost:8084/GetVehicleDetailsImpl"
        |APPLICATION_CD = "WEBDTT"
        |CHANNEL_CD = "WEBDTT"
        |SERVICE_TYPE_CD = "E"
        |CONTACT_ID = "1"""".stripMargin,
      vehiclesLookup.id
    )
    runPrj(
      fullClasspath.all(scopeVehiclesDisposeFulfil).value.flatten,
      classDirectory.all(scopeVehiclesDisposeFulfil).value.head,
      """vss.baseurl = "http://localhost:8085/demo/services/DisposeToTradeService"
        |APPLICATION_CD = "WEBDTT"
        |SERVICE_TYPE_CD = "WEBDTT"
        |ORG_BUSINESS_UNIT = "WEBDTT"""".stripMargin,
      vehiclesDisposeFulfil.id
    )
  }
}
{'fraction_non_alphanumeric': 0.11380110176862859, 'fraction_numerical': 0.007103508263264714, 'mean_word_length': 3.966882649388049, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5071725', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2159, 'n_words': 337}