Skip to content

Commit

Permalink
Auto-provide servlet-api based on servletSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
earldouglas committed Oct 23, 2024
1 parent d97ffe0 commit caa92bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ addSbtPlugin("com.earldouglas" % "sbt-war" % "5.0.0-M4")

```scala
scalaVersion := "3.5.1"
libraryDependencies += "jakarta.servlet" % "jakarta.servlet-api" % "6.0.0" % Provided
enablePlugins(SbtWar)
```

Expand Down
19 changes: 18 additions & 1 deletion src/main/scala/com/earldouglas/sbt/war/SbtWar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,26 @@ object SbtWar extends AutoPlugin {

val runnerLibraries: Initialize[Seq[ModuleID]] =
Def.setting {

val servletApi: ModuleID =
servletSpec.value match {
case "3.0" =>
"javax.servlet" % "javax.servlet-api" % "3.0.1"
case "3.1" =>
"javax.servlet" % "javax.servlet-api" % "3.1.0"
case "4.0" =>
"jakarta.servlet" % "jakarta.servlet-api" % "4.0.4"
case "6.0" =>
"jakarta.servlet" % "jakarta.servlet-api" % "6.0.0"
}

val warRunnerVersion: String =
s"${servletSpec.value}_${BuildInfo.version}"
Seq("com.earldouglas" % s"war-runner" % warRunnerVersion % War)

Seq(
"com.earldouglas" % s"war-runner" % warRunnerVersion % War,
servletApi % Provided
)
}

val quickstartWar: Initialize[Task[Unit]] =
Expand Down
1 change: 0 additions & 1 deletion src/template/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ libraryDependencies += "org.typelevel" %% "cats-effect" % "3.5.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % "test"

libraryDependencies += "com.h2database" % "h2" % "2.2.224"
libraryDependencies += "jakarta.servlet" % "jakarta.servlet-api" % "6.0.0" % Provided

libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.5.8"
Expand Down

0 comments on commit caa92bd

Please sign in to comment.