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:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://git.meager.home/meager/meager-pre-commit-scala
rev: v0.1.2
- repo: https://git.garrity.co/garrity-software/gs-pre-commit-scala
rev: v0.1.3
hooks:
- id: scalafmt

View file

@ -13,12 +13,14 @@ externalResolvers := Seq(
val ProjectName: String = "gs-uuid"
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 conv The conversion function to the output type.
* @return The converted value, or `None` if no value exists.
* @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,
@ -26,53 +28,50 @@ def getProperty[A](
): Option[A] =
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.
*/
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"
/**
* 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] =
getProperty(VersionProperty, identity)
/**
* @return "-SNAPSHOT" if this is NOT a release, empty string otherwise.
/** @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
/** 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.
/** 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.
* @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.
/** 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 =
SelectedVersion.split('.').apply(0)
@ -96,10 +95,13 @@ lazy val publishSettings = Seq(
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")),
homepage := Some(
url(s"https://git.garrity.co/garrity-software/$ProjectName")
),
publishTo := {
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")
}
)
@ -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(publishSettings)
.settings(testSettings)