Skip to content

Commit

Permalink
Merge pull request #26 from kamon-io/support-for-newer-play-versions
Browse files Browse the repository at this point in the history
delete projects for older Play versions, bring support for Play 2.9 aand 3.0
  • Loading branch information
ivantopo authored Jan 9, 2024
2 parents 4af613b + 58e2277 commit 358f1d8
Show file tree
Hide file tree
Showing 23 changed files with 1,109 additions and 2,187 deletions.
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
sbt-kanela-runner
=========

This project contains [sbt] plugins that automatically configure your build to perform enable the Kanela
instrumentation agent when running your application from within SBT, both for regular applications and Play Framework
projects in development mode.
This project contains [sbt] plugins that automatically configures your build to enable the Kanela instrumentation agent
when running your application from within SBT. It works with regular applications with a `main` method, Play Framework,
and Lagom projects in development mode.

Starting on version 2.1.x this plugin requires SBT 1.9.0+. See details below for compatibility with older SBT and
Play/Lagom versions.

SBT versions 1.2.x and 1.3.x are supported. The last version supporting SBT 0.13 was 2.0.5.

## Why this plugin?

Expand All @@ -14,19 +16,18 @@ doing so can be challenging when running from SBT. These plugins take care of th
`run` will just work, regardless your project type or whether you are forking the JVM or not.



## Regular Projects (non-Play)

### Configuring

Add the `sbt-kanela-runner` plugin to your `project/plugins.sbt` file using the code bellow:

```scala
addSbtPlugin("io.kamon" % "sbt-kanela-runner" % "2.0.14")
addSbtPlugin("io.kamon" % "sbt-kanela-runner" % "2.1.0")
```

### Important
This plugin will only work properly on SBT 1.3 if the `classLoaderLayeringStrategy` setting is set to `Flat` or you set
#### Important
This plugin will only work properly on SBT 1.3+ if the `classLoaderLayeringStrategy` setting is set to `Flat` or you set
`fork in run := true`.

### Running
Expand All @@ -35,15 +36,25 @@ Just `run`, like you do all the time!

Here is what the plugin will do depending on your `fork` settings:
* **fork in run := true**: The forked process will run with the `-javaagent:<jarpath>` and that's all.
* **fork in run := false**: The plugin will try to attach the Kanela agent to the current process, targetting the
* **fork in run := false**: The plugin will try to attach the Kanela agent to the current process, targeting the
ClassLoader where your application is placed.


## Play Projects

### Configuring
### Installing the Plugin

For Play Framework 2.6 and 2.7 projects add the `sbt-kanela-runner-play-2.x` to your `project/plugins.sbt` file:
For Play Framework 2.9 and 3.0, add the appropriate `sbt-kanela-runner-play-x.x` to your `project/plugins.sbt` file:

```scala
// For Play Framework 2.9
addSbtPlugin("io.kamon" % "sbt-kanela-runner-play-2.9" % "2.1.0")

// For Play Framework 3.0
addSbtPlugin("io.kamon" % "sbt-kanela-runner-play-3.0" % "2.1.0")
```

For older Play Framework versions:

```scala
// For Play Framework 2.6
Expand All @@ -66,15 +77,16 @@ file and call `.enablePlugins(JavaAgent)` on it, it will probably look like this
lazy val root = (project in file(".")).enablePlugins(PlayScala, JavaAgent)
```

This plugin has been tested with **Play 2.8.8**, **Play 2.7.3** and **Play 2.6.23**.
This plugin has been tested with **Play Framework 2.9.1**, **3.0.1**, **2.8.8**, **2.7.3**, and **2.6.23**.

### Running

Just `run`, like you do all the time! A notice will be shown saying that you are running your application with Kanela.


## Lagom Projects
### Configuration

### Installing the Plugin

For Lagom Framework 1.6 add the `sbt-kanela-runner-lagom-1.6` plugin to your `project/plugins.sbt` file:

Expand Down
56 changes: 15 additions & 41 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,62 +32,36 @@ def crossSbtDependency(module: ModuleID, sbtVersion: String, scalaVersion: Strin
Defaults.sbtPluginExtra(module, sbtVersion, scalaVersion)
}

val playSbtPluginFor26 = "com.typesafe.play" % "sbt-plugin" % "2.6.25"
val playSbtPluginFor27 = "com.typesafe.play" % "sbt-plugin" % "2.7.9"
val playSbtPluginFor28 = "com.typesafe.play" % "sbt-plugin" % "2.8.8"
val lagomSbtPluginFor16 = "com.lightbend.lagom" % "lagom-sbt-plugin" % "1.6.7"

val playSbtPluginFor29 = "com.typesafe.play" % "sbt-plugin" % "2.9.1"
val playSbtPluginFor30 = "org.playframework" % "sbt-plugin" % "3.0.1"
val sbtJavaAgentPlugin = "com.github.sbt" % "sbt-javaagent" % "0.1.8"

lazy val sbtKanelaRunner = Project("sbt-kanela-runner", file("."))
.settings(
noPublishing: _*
).aggregate(kanelaRunner, kanelaRunnerPlay26, kanelaRunnerPlay27, kanelaRunnerPlay28, kanelaRunnerLagom16)
).aggregate(kanelaRunner, kanelaRunnerPlay29, kanelaRunnerPlay30)

lazy val kanelaRunner = Project("kanela-runner", file("sbt-kanela-runner"))
.settings(
moduleName := "sbt-kanela-runner",
libraryDependencies += "net.bytebuddy" % "byte-buddy-agent" % "1.9.12"
libraryDependencies += "net.bytebuddy" % "byte-buddy-agent" % "1.14.2"
)

lazy val kanelaRunnerPlay26 = Project("kanela-runner-play-26", file("sbt-kanela-runner-play-2.6"))
.dependsOn(kanelaRunner)
.settings(
name := "sbt-kanela-runner-play-2.6",
moduleName := "sbt-kanela-runner-play-2.6",
libraryDependencies ++= Seq(
crossSbtDependency(playSbtPluginFor26, (sbtBinaryVersion in pluginCrossBuild).value, scalaBinaryVersion.value)
)
)

lazy val kanelaRunnerPlay27 = Project("kanela-runner-play-27", file("sbt-kanela-runner-play-2.7"))
lazy val kanelaRunnerPlay29 = Project("kanela-runner-play-29", file("sbt-kanela-runner-play-2.9"))
.dependsOn(kanelaRunner)
.settings(
name := "sbt-kanela-runner-play-2.7",
moduleName := "sbt-kanela-runner-play-2.7",
libraryDependencies ++= Seq(
crossSbtDependency(playSbtPluginFor27, (sbtBinaryVersion in pluginCrossBuild).value, scalaBinaryVersion.value)
)
name := "sbt-kanela-runner-play-2.9",
moduleName := "sbt-kanela-runner-play-2.9",
libraryDependencies += crossSbtDependency(playSbtPluginFor29, (pluginCrossBuild / sbtBinaryVersion).value, scalaBinaryVersion.value),
libraryDependencies += crossSbtDependency(sbtJavaAgentPlugin, (pluginCrossBuild / sbtBinaryVersion).value, scalaBinaryVersion.value)
)

lazy val kanelaRunnerPlay28 = Project("kanela-runner-play-28", file("sbt-kanela-runner-play-2.8"))
lazy val kanelaRunnerPlay30 = Project("kanela-runner-play-30", file("sbt-kanela-runner-play-3.0"))
.dependsOn(kanelaRunner)
.settings(
name := "sbt-kanela-runner-play-2.8",
moduleName := "sbt-kanela-runner-play-2.8",
libraryDependencies ++= Seq(
crossSbtDependency(playSbtPluginFor28, (sbtBinaryVersion in pluginCrossBuild).value, scalaBinaryVersion.value)
)
name := "sbt-kanela-runner-play-3.0",
moduleName := "sbt-kanela-runner-play-3.0",
libraryDependencies += crossSbtDependency(playSbtPluginFor30, (pluginCrossBuild / sbtBinaryVersion).value, scalaBinaryVersion.value),
libraryDependencies += crossSbtDependency(sbtJavaAgentPlugin, (pluginCrossBuild / sbtBinaryVersion).value, scalaBinaryVersion.value)
)

lazy val kanelaRunnerLagom16 = Project("kanela-runner-lagom-16", file("sbt-kanela-runner-lagom-1.6"))
.dependsOn(kanelaRunner)
.settings(
name := "sbt-kanela-runner-lagom-1.6",
moduleName := "sbt-kanela-runner-lagom-1.6",
libraryDependencies ++= Seq(
crossSbtDependency(lagomSbtPluginFor16, (sbtBinaryVersion in pluginCrossBuild).value, scalaBinaryVersion.value)
)
)

// remove this?
//crossSbtVersions := Seq("1.3.8")
2 changes: 1 addition & 1 deletion project/KamonSbtUmbrella.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object KamonSbtUmbrella extends AutoPlugin {
def optionalScope(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile,optional")

val noPublishing = Seq(
skip in publish := true,
publish / skip := true,
publishLocal := {},
publishArtifact := false
)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.8
sbt.version=1.9.8
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.4")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
Loading

0 comments on commit 358f1d8

Please sign in to comment.