Upgrade this plugin to use SBT 2.0.1 and Scala 3.8.4
This commit is contained in:
parent
ed0411bd74
commit
06280e8ed3
6 changed files with 46 additions and 54 deletions
16
README.md
16
README.md
|
|
@ -3,13 +3,16 @@
|
||||||
General SBT plugin for Garrity Software projects. This plugin should not be used
|
General SBT plugin for Garrity Software projects. This plugin should not be used
|
||||||
for non-GS projects.
|
for non-GS projects.
|
||||||
|
|
||||||
|
> [!important]
|
||||||
|
> As of version 0.8.0, this plugin is only compatible with SBT 2.0.0+
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
**File: project/plugins.sbt**
|
**File: project/plugins.sbt**
|
||||||
```scala
|
```scala
|
||||||
resolvers += "Garrity Software Releases" at "https://maven.garrity.co/gs"
|
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**
|
**File: build.sbt**
|
||||||
|
|
@ -19,6 +22,15 @@ ThisBuild / gsProjectName := "project-name"
|
||||||
|
|
||||||
## Publishing
|
## Publishing
|
||||||
|
|
||||||
|
First, update the `CurrentVersion` value.
|
||||||
|
|
||||||
```
|
```
|
||||||
sbt -Dversion=$VERSION -Drelease=true publish
|
sbt publish
|
||||||
|
```
|
||||||
|
|
||||||
|
Then:
|
||||||
|
|
||||||
|
```
|
||||||
|
git tag $CURRENT_VERSION
|
||||||
|
git push origin $CURRENT_VERSION
|
||||||
```
|
```
|
||||||
|
|
|
||||||
54
build.sbt
54
build.sbt
|
|
@ -1,3 +1,4 @@
|
||||||
|
ThisBuild / scalaVersion := "3.8.4"
|
||||||
ThisBuild / organizationName := "garrity software"
|
ThisBuild / organizationName := "garrity software"
|
||||||
ThisBuild / organization := "gs"
|
ThisBuild / organization := "gs"
|
||||||
ThisBuild / versionScheme := Some("semver-spec")
|
ThisBuild / versionScheme := Some("semver-spec")
|
||||||
|
|
@ -8,32 +9,12 @@ externalResolvers := Seq(
|
||||||
)
|
)
|
||||||
|
|
||||||
val ProjectName: String = "sbt-garrity-software"
|
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](
|
val CurrentVersion: String = "0.8.0-SNAPSHOT"
|
||||||
name: String,
|
|
||||||
conv: String => A
|
|
||||||
): Option[A] =
|
|
||||||
Option(System.getProperty(name)).map(conv)
|
|
||||||
|
|
||||||
val VersionProperty: String = "version"
|
def isRelease(): Boolean =
|
||||||
val ReleaseProperty: String = "release"
|
!CurrentVersion.contains("SNAPSHOT")
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
lazy val publishSettings = Seq(
|
lazy val publishSettings = Seq(
|
||||||
publishMavenStyle := true,
|
publishMavenStyle := true,
|
||||||
|
|
@ -47,14 +28,14 @@ lazy val publishSettings = Seq(
|
||||||
),
|
),
|
||||||
description := Description,
|
description := Description,
|
||||||
licenses := List(
|
licenses := List(
|
||||||
"MIT" -> url("https://garrity.co/MIT.html")
|
"MIT" -> url(s"https://git.garrity.co/garrity-software/$ProjectName/LICENSE")
|
||||||
),
|
),
|
||||||
homepage := Some(
|
homepage := Some(
|
||||||
url(s"https://git.garrity.co/garrity-software/$ProjectName")
|
url(s"https://git.garrity.co/garrity-software/$ProjectName")
|
||||||
),
|
),
|
||||||
publishTo := {
|
publishTo := {
|
||||||
val repo = "https://maven.garrity.co/"
|
val repo = "https://maven.garrity.co/"
|
||||||
if (!IsRelease)
|
if (!isRelease())
|
||||||
Some("Garrity Software Maven" at repo + "snapshots")
|
Some("Garrity Software Maven" at repo + "snapshots")
|
||||||
else
|
else
|
||||||
Some("Garrity Software Maven" at repo + "gs")
|
Some("Garrity Software Maven" at repo + "gs")
|
||||||
|
|
@ -66,18 +47,23 @@ lazy val root = Project(ProjectName, file("."))
|
||||||
.settings(publishSettings)
|
.settings(publishSettings)
|
||||||
.settings(
|
.settings(
|
||||||
name := ProjectName,
|
name := ProjectName,
|
||||||
version := SelectedVersion,
|
version := CurrentVersion,
|
||||||
pluginCrossBuild / sbtVersion := {
|
pluginCrossBuild / sbtVersion := {
|
||||||
scalaBinaryVersion.value match {
|
"2.0.0"
|
||||||
// Minimum SBT version compatible with this plugin.
|
|
||||||
case "2.12" => "1.9.0"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
scalacOptions := Seq(
|
scalacOptions := Seq(
|
||||||
"-unchecked",
|
"-encoding",
|
||||||
|
"utf8",
|
||||||
"-deprecation",
|
"-deprecation",
|
||||||
"-feature",
|
"-feature",
|
||||||
"-encoding",
|
"-explain",
|
||||||
"utf8"
|
"-unchecked",
|
||||||
|
"-explain-types",
|
||||||
|
"-language:strictEquality",
|
||||||
|
"-Wunused:implicits",
|
||||||
|
"-Wunused:explicits",
|
||||||
|
"-Wunused:imports",
|
||||||
|
"-Wunused:locals",
|
||||||
|
"-Wunused:privates"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
sbt.version=1.12.0
|
sbt.version=2.0.1
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package gs;
|
package gs
|
||||||
|
|
||||||
import sbt._
|
import sbt.*
|
||||||
|
|
||||||
object Gs {
|
object Gs:
|
||||||
|
|
||||||
/** Standard compiler options used by GS projects.
|
/** Standard compiler options used by GS projects.
|
||||||
*/
|
*/
|
||||||
|
|
@ -104,5 +104,3 @@ object Gs {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package gs
|
package gs
|
||||||
|
|
||||||
import sbt._
|
import sbt.*
|
||||||
|
|
||||||
/** Defines all setting and task keys for the GS SBT Plugin.
|
/** 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
|
/** Required setting for projects using the Garrity Software plugin. This
|
||||||
* value must match the Git repository name. This value is used to configure
|
* value must match the Git repository name. This value is used to configure
|
||||||
|
|
@ -17,5 +17,3 @@ object GsKeys {
|
||||||
lazy val writeScalaVersionToFile = taskKey[Unit](
|
lazy val writeScalaVersionToFile = taskKey[Unit](
|
||||||
"Task to emit the Scala version used to build this project to a file."
|
"Task to emit the Scala version used to build this project to a file."
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,16 @@ import java.nio.file.Paths
|
||||||
import sbt._
|
import sbt._
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
|
|
||||||
object GsPlugin extends AutoPlugin {
|
object GsPlugin extends AutoPlugin:
|
||||||
override def trigger = allRequirements
|
override def trigger = allRequirements
|
||||||
|
|
||||||
val autoImport = GsKeys
|
val autoImport = GsKeys
|
||||||
|
|
||||||
import autoImport._
|
import autoImport.*
|
||||||
|
|
||||||
val ScalaVersionFile: String = ".scala-version"
|
val ScalaVersionFile: String = ".scala-version"
|
||||||
|
|
||||||
override def projectSettings: Seq[Setting[_]] = Seq(
|
override def projectSettings: Seq[Setting[?]] = Seq(
|
||||||
publishMavenStyle := true,
|
publishMavenStyle := true,
|
||||||
Test / Keys.publishArtifact := false,
|
Test / Keys.publishArtifact := false,
|
||||||
pomIncludeRepository := Function.const(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 := {
|
writeScalaVersionToFile := {
|
||||||
val outputFile = ScalaVersionFile
|
val outputFile = ScalaVersionFile
|
||||||
Files.write(
|
Files.write(
|
||||||
|
|
@ -51,5 +51,3 @@ object GsPlugin extends AutoPlugin {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue