diff --git a/README.md b/README.md index ffcc6e2..56f23fa 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/build.sbt b/build.sbt index 5e324f0..9af8d16 100644 --- a/build.sbt +++ b/build.sbt @@ -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, @@ -47,14 +28,14 @@ lazy val publishSettings = Seq( ), description := Description, licenses := List( - "MIT" -> url("https://garrity.co/MIT.html") + "MIT" -> url(s"https://git.garrity.co/garrity-software/$ProjectName/LICENSE") ), homepage := Some( url(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" ) ) diff --git a/project/build.properties b/project/build.properties index 30b7fd9..312809a 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.12.0 +sbt.version=2.0.1 diff --git a/src/main/scala/gs/Gs.scala b/src/main/scala/gs/Gs.scala index ce77ae0..4ea782c 100644 --- a/src/main/scala/gs/Gs.scala +++ b/src/main/scala/gs/Gs.scala @@ -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 { ) ) ) - -} diff --git a/src/main/scala/gs/GsKeys.scala b/src/main/scala/gs/GsKeys.scala index 2e76ad1..e01a654 100644 --- a/src/main/scala/gs/GsKeys.scala +++ b/src/main/scala/gs/GsKeys.scala @@ -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." ) - -} diff --git a/src/main/scala/gs/GsPlugin.scala b/src/main/scala/gs/GsPlugin.scala index 1970634..2b41c80 100644 --- a/src/main/scala/gs/GsPlugin.scala +++ b/src/main/scala/gs/GsPlugin.scala @@ -6,16 +6,16 @@ import java.nio.file.Paths 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 { ) } ) - -}