From 0f09c54c6462e9e1cd0b0ab6f9f10f9b01d55768 Mon Sep 17 00:00:00 2001 From: Pat Garrity Date: Fri, 12 Jan 2024 22:36:25 -0600 Subject: [PATCH] Updating to use the GS plugins. --- build.sbt | 126 ++------------------------------------------ project/plugins.sbt | 9 +++- 2 files changed, 13 insertions(+), 122 deletions(-) diff --git a/build.sbt b/build.sbt index 4810a31..b1b52b7 100644 --- a/build.sbt +++ b/build.sbt @@ -1,109 +1,12 @@ val scala3: String = "3.3.1" -ThisBuild / organizationName := "garrity software" -ThisBuild / organization := "gs" -ThisBuild / organizationHomepage := Some(url("https://garrity.co/")) -ThisBuild / scalaVersion := scala3 -ThisBuild / versionScheme := Some("early-semver") - -externalResolvers := Seq( - "Garrity Software Releases" at "https://maven.garrity.co/releases" -) - -val ProjectName: String = "gs-uuid" -val Description: String = "Garrity Software UUID Implementation" - -/** Helper to extract the value from `-Dproperty=value`. - * - * @param name - * The property name. - * @param conv - * The conversion function to the output type. - * @return - * The converted value, or `None` if no value exists. - */ -def getProperty[A]( - name: String, - conv: String => A -): Option[A] = - Option(System.getProperty(name)).map(conv) - -/** Use `sbt -Dversion=` to provide the version, minus the SNAPSHOT - * modifier. This is the typical approach for producing releases. - */ -val VersionProperty: String = "version" - -/** Use `sbt -Drelease=true` to trigger a release build. - */ -val ReleaseProperty: String = "release" - -/** The value of `-Dversion=`. - * - * @return - * The version passed as input to SBT. - */ -lazy val InputVersion: Option[String] = - getProperty(VersionProperty, identity) - -/** @return - * "-SNAPSHOT" if this is NOT a release, empty string otherwise. - */ -lazy val Modifier: String = - if (getProperty(ReleaseProperty, _.toBoolean).getOrElse(false)) "" - else "-SNAPSHOT" - -/** Version used if no version is passed as input. This helps with default/local - * builds. - */ -val DefaultVersion: String = "0.1.0-SNAPSHOT" - -/** This is the output version of the published artifact. If this build is not a - * release, the suffix "-SNAPSHOT" will be appended. - * - * @return - * The project version. - */ -lazy val SelectedVersion: String = - InputVersion - .map(v => s"$v$Modifier") - .getOrElse(DefaultVersion) - -/** The major version (first segment) value. Used to label releases. - * - * @return - * The major version of the project. - */ -lazy val MajorVersion: String = - SelectedVersion.split('.').apply(0) +ThisBuild / scalaVersion := scala3 +ThisBuild / versionScheme := Some("semver-spec") +ThisBuild / gsProjectName := "gs-uuid" val sharedSettings = Seq( scalaVersion := scala3, - version := SelectedVersion -) - -lazy val publishSettings = Seq( - publishMavenStyle := true, - Test / publishArtifact := false, - pomIncludeRepository := Function.const(false), - scmInfo := Some( - ScmInfo( - url(s"https://git.garrity.co/garrity-software/$ProjectName"), - s"git@git.garrity.co:garrity-software/$ProjectName.git" - ) - ), - description := Description, - licenses := List( - "Apache 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html") - ), - homepage := Some( - url(s"https://git.garrity.co/garrity-software/$ProjectName") - ), - publishTo := { - val repo = "https://maven.garrity.co/" - if (SelectedVersion.endsWith("SNAPSHOT")) - Some("Garrity Software Maven" at repo + "snapshots") - else Some("Garrity Software Maven" at repo + "releases") - } + version := semVerSelected.value ) lazy val testSettings = Seq( @@ -115,29 +18,10 @@ lazy val testSettings = Seq( lazy val `gs-uuid` = project .in(file(".")) .settings(sharedSettings) - .settings(publishSettings) .settings(testSettings) - .settings(name := s"$ProjectName-v$MajorVersion") + .settings(name := s"${gsProjectName.value}-v${semVerMajor.value}") .settings( libraryDependencies ++= Seq( "com.fasterxml.uuid" % "java-uuid-generator" % "4.1.1" ) ) - -ThisBuild / scalacOptions ++= Seq( - "-encoding", - "utf8", // Set source file character encoding. - "-deprecation", // Emit warning and location for usages of deprecated APIs. - "-feature", // Emit warning and location for usages of features that should be imported explicitly. - "-explain", // Explain errors in more detail. - "-unchecked", // Enable additional warnings where generated code depends on assumptions. - "-explain-types", // Explain type errors in more detail. - "-Xfatal-warnings", // Fail the compilation if there are any warnings. - "-language:strictEquality", // Enable multiversal equality (require CanEqual) - "-Wunused:implicits", // Warn if an implicit parameter is unused. - "-Wunused:explicits", // Warn if an explicit parameter is unused. - "-Wunused:imports", // Warn if an import selector is not referenced. - "-Wunused:locals", // Warn if a local definition is unused. - "-Wunused:privates", // Warn if a private member is unused. - "-Ysafe-init" // Enable the experimental safe initialization check. -) diff --git a/project/plugins.sbt b/project/plugins.sbt index 2c1199a..021c50e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,10 @@ credentials += Credentials(Path.userHome / ".sbt" / ".credentials") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8") +externalResolvers := Seq( + "Garrity Software Mirror" at "https://maven.garrity.co/releases", + "Garrity Software Releases" at "https://maven.garrity.co/gs" +) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8") +addSbtPlugin("gs" % "sbt-garrity-software" % "0.1.0") +addSbtPlugin("gs" % "sbt-gs-semver" % "0.2.0")