Skip to content

Commit

Permalink
Refactor startWar to use WarRunner from war-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
earldouglas committed Oct 16, 2024
1 parent 92d762a commit 403967d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ semanticdbVersion := scalafixSemanticdb.revision
scalacOptions += "-Ywarn-unused-import"
scalacOptions += s"-P:semanticdb:sourceroot:${baseDirectory.value}"

// webapp-components-runner
// war-runner
lazy val warRunnerVersion =
settingKey[String]("webapp-components-runner version")
warRunnerVersion := "10.1.28.0.0-M1"
libraryDependencies += "com.earldouglas" % "webapp-components-runner" % warRunnerVersion.value % Provided
settingKey[String]("war-runner version")
warRunnerVersion := "10.1.28.0.0-M2"
libraryDependencies += "com.earldouglas" % "war-runner" % warRunnerVersion.value % Provided

// sbt-buildinfo
enablePlugins(BuildInfoPlugin)
Expand Down
36 changes: 25 additions & 11 deletions src/main/scala/com/earldouglas/sbt/war/SbtWar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ object SbtWar extends AutoPlugin {

val startWar: Initialize[Task[Unit]] =
Def.task {

val runnerConfigFile: File = {

val configurationFile: File =
(Compile / target).value / "war.properties"

Files
.writeString(
Paths.get(configurationFile.getPath()),
s"""|port=${warPort.value}
|warFile=${pkg.value.getPath()}
|""".stripMargin
)
.toFile()
}

stopContainerInstance(streams.value.log.info(_))

streams.value.log.info("[sbt-war] Starting server")
Expand All @@ -71,10 +87,8 @@ object SbtWar extends AutoPlugin {
Seq(
"-cp",
Path.makeString(runnerJars.value),
"webapp.runner.launch.Main",
"--port",
warPort.value.toString(),
pkg.value.getPath()
"com.earldouglas.WarRunner",
runnerConfigFile.getPath()
)
)
containerInstance.set(Some(process))
Expand Down Expand Up @@ -103,7 +117,7 @@ object SbtWar extends AutoPlugin {
val runnerLibraries: Initialize[Seq[ModuleID]] =
Def.setting {
Seq(
"com.earldouglas" % "webapp-components-runner" % BuildInfo.warRunnerVersion % War
"com.earldouglas" % "war-runner" % BuildInfo.warRunnerVersion % War
)
}

Expand All @@ -128,12 +142,12 @@ object SbtWar extends AutoPlugin {
.writeString(
Paths.get(configurationFile.getPath()),
s"""|hostname=localhost
|port=${warPort.value}
|contextPath=
|emptyWebappDir=${emptyDir}
|emptyClassesDir=${emptyDir}
|resourceMap=${resourceMapString}
|""".stripMargin
|port=${warPort.value}
|contextPath=
|emptyWebappDir=${emptyDir}
|emptyClassesDir=${emptyDir}
|resourceMap=${resourceMapString}
|""".stripMargin
)
.toFile()
}
Expand Down

0 comments on commit 403967d

Please sign in to comment.