Upgrade this plugin to use SBT 2 and Scala 3.8.4 #1

Merged
pfm merged 1 commit from sbt2 into main 2026-07-21 02:48:30 +00:00
6 changed files with 50 additions and 58 deletions
Showing only changes of commit 7d8cc854cc - Show all commits

View file

@ -3,13 +3,16 @@
General SBT plugin for Garrity Software projects. This plugin should not be used
for non-GS projects.
> [!important]
> As of version 0.8.0, this plugin is only compatible with SBT 2.0.0+
## Usage
**File: project/plugins.sbt**
```scala
resolvers += "Garrity Software Releases" at "https://maven.garrity.co/gs"
addSbtPlugin("gs" % "sbt-garrity-software" % "0.4.0")
addSbtPlugin("gs" % "sbt-garrity-software" % "0.8.0")
```
**File: build.sbt**
@ -19,6 +22,15 @@ ThisBuild / gsProjectName := "project-name"
## Publishing
First, update the `CurrentVersion` value.
```
sbt -Dversion=$VERSION -Drelease=true publish
sbt publish
```
Then:
```
git tag $CURRENT_VERSION
git push origin $CURRENT_VERSION
```

View file

@ -1,3 +1,4 @@
ThisBuild / scalaVersion := "3.8.4"
ThisBuild / organizationName := "garrity software"
ThisBuild / organization := "gs"
ThisBuild / versionScheme := Some("semver-spec")
@ -8,32 +9,12 @@ externalResolvers := Seq(
)
val ProjectName: String = "sbt-garrity-software"
val Description: String = "SBT 1.9.0+ plugin for Garrity Software projects."
val Description: String = "SBT 2.0.0+ plugin for Garrity Software projects."
def getProperty[A](
name: String,
conv: String => A
): Option[A] =
Option(System.getProperty(name)).map(conv)
val CurrentVersion: String = "0.8.0-SNAPSHOT"
val VersionProperty: String = "version"
val ReleaseProperty: String = "release"
lazy val InputVersion: Option[String] =
getProperty(VersionProperty, identity)
lazy val IsRelease: Boolean =
getProperty(ReleaseProperty, _.toBoolean).getOrElse(false)
lazy val Modifier: String =
if (IsRelease) "" else "-SNAPSHOT"
val DefaultVersion: String = "0.1.0-SNAPSHOT"
lazy val SelectedVersion: String =
InputVersion
.map(v => s"$v$Modifier")
.getOrElse(DefaultVersion)
def isRelease(): Boolean =
!CurrentVersion.contains("SNAPSHOT")
lazy val publishSettings = Seq(
publishMavenStyle := true,
@ -41,20 +22,20 @@ lazy val publishSettings = Seq(
pomIncludeRepository := Function.const(false),
scmInfo := Some(
ScmInfo(
url(s"https://git.garrity.co/garrity-software/$ProjectName"),
uri(s"https://git.garrity.co/garrity-software/$ProjectName"),
s"git@git.garrity.co:garrity-software/$ProjectName.git"
)
),
description := Description,
licenses := List(
"MIT" -> url("https://garrity.co/MIT.html")
"MIT" -> uri(s"https://git.garrity.co/garrity-software/$ProjectName/LICENSE")
),
homepage := Some(
url(s"https://git.garrity.co/garrity-software/$ProjectName")
uri(s"https://git.garrity.co/garrity-software/$ProjectName")
),
publishTo := {
val repo = "https://maven.garrity.co/"
if (!IsRelease)
if (!isRelease())
Some("Garrity Software Maven" at repo + "snapshots")
else
Some("Garrity Software Maven" at repo + "gs")
@ -66,18 +47,23 @@ lazy val root = Project(ProjectName, file("."))
.settings(publishSettings)
.settings(
name := ProjectName,
version := SelectedVersion,
version := CurrentVersion,
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
// Minimum SBT version compatible with this plugin.
case "2.12" => "1.9.0"
}
"2.0.0"
},
scalacOptions := Seq(
"-unchecked",
"-deprecation",
"-feature",
"-encoding",
"utf8"
"-encoding",
"utf8",
"-deprecation",
"-feature",
"-explain",
"-unchecked",
"-explain-types",
"-language:strictEquality",
"-Wunused:implicits",
"-Wunused:explicits",
"-Wunused:imports",
"-Wunused:locals",
"-Wunused:privates"
)
)

View file

@ -1 +1 @@
sbt.version=1.12.0
sbt.version=2.0.3

View file

@ -1,8 +1,8 @@
package gs;
package gs
import sbt._
import sbt.*
object Gs {
object Gs:
/** Standard compiler options used by GS projects.
*/
@ -104,5 +104,3 @@ object Gs {
)
)
)
}

View file

@ -1,10 +1,10 @@
package gs
import sbt._
import sbt.*
/** Defines all setting and task keys for the GS SBT Plugin.
*/
object GsKeys {
object GsKeys:
/** Required setting for projects using the Garrity Software plugin. This
* value must match the Git repository name. This value is used to configure
@ -17,5 +17,3 @@ object GsKeys {
lazy val writeScalaVersionToFile = taskKey[Unit](
"Task to emit the Scala version used to build this project to a file."
)
}

View file

@ -3,19 +3,19 @@ package gs
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths
import sbt._
import sbt.Keys._
import sbt.*
import sbt.Keys.*
object GsPlugin extends AutoPlugin {
object GsPlugin extends AutoPlugin:
override def trigger = allRequirements
val autoImport = GsKeys
import autoImport._
import autoImport.*
val ScalaVersionFile: String = ".scala-version"
override def projectSettings: Seq[Setting[_]] = Seq(
override def projectSettings: Seq[Setting[?]] = Seq(
publishMavenStyle := true,
Test / Keys.publishArtifact := false,
pomIncludeRepository := Function.const(false),
@ -42,7 +42,7 @@ object GsPlugin extends AutoPlugin {
}
)
override lazy val buildSettings: Seq[Setting[_]] = Seq(
override lazy val buildSettings: Seq[Setting[?]] = Seq(
writeScalaVersionToFile := {
val outputFile = ScalaVersionFile
Files.write(
@ -51,5 +51,3 @@ object GsPlugin extends AutoPlugin {
)
}
)
}