Updated for GS development.

This commit is contained in:
Pat Garrity 2023-12-23 20:40:30 -06:00
parent 0809a8fe34
commit 63f006f927
Signed by: pfm
GPG key ID: 5CA5D21BAB7F3A76
3 changed files with 33 additions and 30 deletions

View file

@ -1,11 +1,11 @@
--- ---
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://git.meager.home/meager/meager-pre-commit-scala - repo: https://git.garrity.co/garrity-software/gs-pre-commit-scala
rev: v0.1.2 rev: v0.1.3
hooks: hooks:
- id: scalafmt - id: scalafmt

View file

@ -3,7 +3,7 @@
[License (Apache 2.0)](./LICENSE) [License (Apache 2.0)](./LICENSE)
UUID's for Scala 3 with generation based on JUG, and serialization based on code UUID's for Scala 3 with generation based on JUG, and serialization based on code
from Jackson Databind. The only dependency is JUG, whereas the relevant Jackson from Jackson Databind. The only dependency is JUG, whereas the relevant Jackson
code is copied to this implementation (and slightly modified). code is copied to this implementation (and slightly modified).
- [Usage](#usage) - [Usage](#usage)

View file

@ -13,12 +13,14 @@ externalResolvers := Seq(
val ProjectName: String = "gs-uuid" val ProjectName: String = "gs-uuid"
val Description: String = "Garrity Software UUID Implementation" val Description: String = "Garrity Software UUID Implementation"
/** /** Helper to extract the value from `-Dproperty=value`.
* Helper to extract the value from `-Dproperty=value`.
* *
* @param name The property name. * @param name
* @param conv The conversion function to the output type. * The property name.
* @return The converted value, or `None` if no value exists. * @param conv
* The conversion function to the output type.
* @return
* The converted value, or `None` if no value exists.
*/ */
def getProperty[A]( def getProperty[A](
name: String, name: String,
@ -26,53 +28,50 @@ def getProperty[A](
): Option[A] = ): Option[A] =
Option(System.getProperty(name)).map(conv) Option(System.getProperty(name)).map(conv)
/** /** Use `sbt -Dversion=<version>` to provide the version, minus the SNAPSHOT
* Use `sbt -Dversion=<version>` to provide the version, minus the SNAPSHOT
* modifier. This is the typical approach for producing releases. * modifier. This is the typical approach for producing releases.
*/ */
val VersionProperty: String = "version" val VersionProperty: String = "version"
/** /** Use `sbt -Drelease=true` to trigger a release build.
* Use `sbt -Drelease=true` to trigger a release build.
*/ */
val ReleaseProperty: String = "release" val ReleaseProperty: String = "release"
/** /** The value of `-Dversion=<value>`.
* The value of `-Dversion=<value>`.
* *
* @return The version passed as input to SBT. * @return
* The version passed as input to SBT.
*/ */
lazy val InputVersion: Option[String] = lazy val InputVersion: Option[String] =
getProperty(VersionProperty, identity) getProperty(VersionProperty, identity)
/** /** @return
* @return "-SNAPSHOT" if this is NOT a release, empty string otherwise. * "-SNAPSHOT" if this is NOT a release, empty string otherwise.
*/ */
lazy val Modifier: String = lazy val Modifier: String =
if (getProperty(ReleaseProperty, _.toBoolean).getOrElse(false)) "" if (getProperty(ReleaseProperty, _.toBoolean).getOrElse(false)) ""
else "-SNAPSHOT" else "-SNAPSHOT"
/** /** Version used if no version is passed as input. This helps with default/local
* Version used if no version is passed as input. This helps with default/local
* builds. * builds.
*/ */
val DefaultVersion: String = "0.1.0-SNAPSHOT" val DefaultVersion: String = "0.1.0-SNAPSHOT"
/** /** This is the output version of the published artifact. If this build is not a
* This is the output version of the published artifact. If this build is not * release, the suffix "-SNAPSHOT" will be appended.
* a release, the suffix "-SNAPSHOT" will be appended.
* *
* @return The project version. * @return
* The project version.
*/ */
lazy val SelectedVersion: String = lazy val SelectedVersion: String =
InputVersion InputVersion
.map(v => s"$v$Modifier") .map(v => s"$v$Modifier")
.getOrElse(DefaultVersion) .getOrElse(DefaultVersion)
/** /** The major version (first segment) value. Used to label releases.
* The major version (first segment) value. Used to label releases.
* *
* @return The major version of the project. * @return
* The major version of the project.
*/ */
lazy val MajorVersion: String = lazy val MajorVersion: String =
SelectedVersion.split('.').apply(0) SelectedVersion.split('.').apply(0)
@ -96,10 +95,13 @@ lazy val publishSettings = Seq(
licenses := List( licenses := List(
"Apache 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html") "Apache 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")
), ),
homepage := Some(url(s"https://git.garrity.co/garrity-software/$ProjectName")), homepage := Some(
url(s"https://git.garrity.co/garrity-software/$ProjectName")
),
publishTo := { publishTo := {
val repo = "https://maven.garrity.co/" val repo = "https://maven.garrity.co/"
if (SelectedVersion.endsWith("SNAPSHOT")) Some("snapshots" at repo + "snapshots") if (SelectedVersion.endsWith("SNAPSHOT"))
Some("snapshots" at repo + "snapshots")
else Some("releases" at repo + "releases") else Some("releases" at repo + "releases")
} }
) )
@ -110,7 +112,8 @@ lazy val testSettings = Seq(
) )
) )
lazy val `gs-uuid` = (project.in(file("."))) lazy val `gs-uuid` = project
.in(file("."))
.settings(sharedSettings) .settings(sharedSettings)
.settings(publishSettings) .settings(publishSettings)
.settings(testSettings) .settings(testSettings)