Skip to content

Commit

Permalink
Update sbt to 1.9.0 (fixes #219), migrate to new sbt syntax && Modern…
Browse files Browse the repository at this point in the history
…ize a bit the CI (add ScalaSteward and dependabot to help maintain things up-to-date)
  • Loading branch information
guizmaii committed Jun 4, 2023
1 parent f785d91 commit 47efa4e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ jobs:
include:
- java: 8
- java: 11
- java: 17
steps:
- uses: actions/checkout@v2.3.4
- uses: olafurpg/setup-scala@v10
- uses: actions/setup-java@v3
with:
java-version: "adopt@1.${{ matrix.java }}"
distribution: 'temurin'
java-version: ${{ matrix.java }}
- uses: coursier/cache-action@v5
- run: sbt -v test scripted
- run:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/scala-steward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Scala Steward

# This workflow will launch every day at 00:00
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}

jobs:
scala-steward:
timeout-minutes: 45
runs-on: ubuntu-latest
name: Scala Steward
steps:
- name: Scala Steward
uses: scala-steward-org/scala-steward-action@v2.54.0
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ val jmhVersion = {

val commonSettings = Seq(
organization := "pl.project13.scala",
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeOssSnapshots.last else Opts.resolver.sonatypeStaging),
startYear := Some(2014),
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")),
homepage := Some(url("https://github.com/ktoso/sbt-jmh")),
Expand Down
31 changes: 13 additions & 18 deletions plugin/src/main/scala/pl/project13/scala/sbt/JmhPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@

package pl.project13.scala.sbt

import java.util.Properties

import sbt._
import sbt.Keys._
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator
import sbt.KeyRanks.AMinusSetting
import sbt.*
import sbt.Keys.*

import scala.tools.nsc.util.ScalaClassLoader.URLClassLoader
import java.util.Properties

object JmhPlugin extends AutoPlugin {

Expand All @@ -33,7 +28,7 @@ object JmhPlugin extends AutoPlugin {
val generatorType = settingKey[String]("Benchmark code generator type. Available: `default`, `reflection` or `asm`.")
}

import JmhKeys._
import JmhKeys.*

val autoImport = JmhKeys

Expand All @@ -52,17 +47,17 @@ object JmhPlugin extends AutoPlugin {
version := jmhVersionFromProps(),
generatorType := "default",

mainClass in run := Some("org.openjdk.jmh.Main"),
fork in run := true, // makes sure that sbt manages classpath for JMH when forking
run / mainClass := Some("org.openjdk.jmh.Main"),
run / fork := true, // makes sure that sbt manages classpath for JMH when forking
// allow users to configure another classesDirectory like e.g. test:classDirectory
classDirectory := (classDirectory in Compile).value,
dependencyClasspath := (dependencyClasspath in Compile).value,
classDirectory := (Compile / classDirectory).value,
dependencyClasspath := (Compile / dependencyClasspath).value,

resourceDirectory := (resourceDirectory in Compile).value,
resourceDirectory := (Compile / resourceDirectory).value,
sourceGenerators := Seq(Def.task { generateJmhSourcesAndResources.value._1 }.taskValue),
resourceGenerators := Seq(Def.task { generateJmhSourcesAndResources.value._2 }.taskValue),
generateJmhSourcesAndResources := generateBenchmarkSourcesAndResources(streams.value, crossTarget.value / "jmh-cache", (classDirectory in Jmh).value, sourceManaged.value, resourceManaged.value, generatorType.value, (dependencyClasspath in Jmh).value, new Run(scalaInstance.value, true, taskTemporaryDirectory.value)),
generateJmhSourcesAndResources := (generateJmhSourcesAndResources dependsOn(compile in Compile)).value,
generateJmhSourcesAndResources := generateBenchmarkSourcesAndResources(streams.value, crossTarget.value / "jmh-cache", (Jmh / classDirectory).value, sourceManaged.value, resourceManaged.value, generatorType.value, (Jmh / dependencyClasspath).value, new Run(scalaInstance.value, true, taskTemporaryDirectory.value)),
generateJmhSourcesAndResources := (generateJmhSourcesAndResources dependsOn(Compile / compile)).value,

// local copy of https://github.com/sbt/sbt/blob/e4231ac03903e174bc9975ee00d34064a1d1f373/main/src/main/scala/sbt/Keys.scala#L400
// so that it does not break on sbt version below 1.4.0
Expand All @@ -72,13 +67,13 @@ object JmhPlugin extends AutoPlugin {

// includes the asm jar only if needed
libraryDependencies ++= {
val jmhV = (version in Jmh).value
val jmhV = (Jmh / version).value

Seq(
"org.openjdk.jmh" % "jmh-core" % jmhV, // GPLv2
"org.openjdk.jmh" % "jmh-generator-bytecode" % jmhV, // GPLv2
"org.openjdk.jmh" % "jmh-generator-reflection" % jmhV // GPLv2
) ++ ((generatorType in Jmh).value match {
) ++ ((Jmh / generatorType).value match {
case "default" | "reflection" => Nil // default == reflection (0.9)
case "asm" => Seq("org.openjdk.jmh" % "jmh-generator-asm" % jmhV) // GPLv2
case unknown => throw new IllegalArgumentException(s"Unknown benchmark generator type: $unknown, please use one of the supported generators!")
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.13
sbt.version=1.9.0
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0")
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.4.4"
ThisBuild / version := "0.4.4"

0 comments on commit 47efa4e

Please sign in to comment.