Skip to content

Commit

Permalink
build: fix sbt warnings (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
brharrington authored Nov 14, 2024
1 parent aec0c0a commit 9b5b20c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions project/BuildSettings.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sbt.Def
import sbt._
import sbt.Keys._
import sbt.*
import sbt.Keys.*

object BuildSettings {

Expand All @@ -16,9 +16,9 @@ object BuildSettings {
lazy val checkLicenseHeaders = taskKey[Unit]("Check the license headers for all source files.")
lazy val formatLicenseHeaders = taskKey[Unit]("Fix the license headers for all source files.")

lazy val baseSettings: Seq[Def.Setting[_]] = GitVersion.settings
lazy val baseSettings: Seq[Def.Setting[?]] = GitVersion.settings

lazy val buildSettings: Seq[Def.Setting[_]] = baseSettings ++ Seq(
lazy val buildSettings: Seq[Def.Setting[?]] = baseSettings ++ Seq(
organization := "com.netflix.atlas_v1",
scalaVersion := Dependencies.Versions.scala,
scalacOptions := {
Expand All @@ -36,8 +36,8 @@ object BuildSettings {
// Evictions: https://github.com/sbt/sbt/issues/1636
// Linting: https://github.com/sbt/sbt/pull/5153
(update / evictionWarningOptions).withRank(KeyRanks.Invisible) := EvictionWarningOptions.empty,
checkLicenseHeaders := License.checkLicenseHeaders(streams.value.log, sourceDirectory.value),
formatLicenseHeaders := License.formatLicenseHeaders(streams.value.log, sourceDirectory.value),
checkLicenseHeaders := LicenseCheck.checkLicenseHeaders(streams.value.log, sourceDirectory.value),
formatLicenseHeaders := LicenseCheck.formatLicenseHeaders(streams.value.log, sourceDirectory.value),
packageBin / packageOptions += Package.ManifestAttributes(
"Build-Date" -> java.time.Instant.now().toString,
"Build-Number" -> sys.env.getOrElse("GITHUB_RUN_ID", "unknown"),
Expand All @@ -64,7 +64,7 @@ object BuildSettings {

def profile: Project => Project = p => {
p.settings(SonatypeSettings.settings)
.settings(buildSettings: _*)
.settings(buildSettings *)
.settings(libraryDependencies ++= commonDeps)
}
}
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sbt._
import sbt.*

// format: off

Expand All @@ -17,7 +17,7 @@ object Dependencies {
val crossScala = Seq(scala, "3.5.1")
}

import Versions._
import Versions.*

val pekkoActor = "org.apache.pekko" %% "pekko-actor" % pekko
val pekkoHttp = "org.apache.pekko" %% "pekko-http" % pekkoHttpV
Expand Down
20 changes: 10 additions & 10 deletions project/GitVersion.scala
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import sbt._
import sbt.Keys._
import sbt.*
import sbt.Keys.*
import sbtrelease.Version
import com.github.sbt.git.SbtGit._
import com.github.sbt.git.SbtGit.*

object GitVersion {

// Base version for master branch
private val baseVersion = "v1.8.x"

// 0.1.x
private val versionBranch = """v?([0-9\.]+)(?:\.x)?""".r
private val versionBranch = """v?([0-9.]+)(?:\.x)?""".r

// v0.1.47-31-g230560c
// v0.1.47-20150807.161518-9
private val snapshotVersion = """v?([0-9\.]+)-(?:\d+)-(?:[0-9a-z]+)""".r
private val snapshotVersion = """v?([0-9.]+)-\d+-[0-9a-z]+""".r

// 1.5.0-rc.1-123-gcbfe51a
private val candidateVersion = """v?([0-9\.]+)(?:-rc\.\d+)?-(?:\d+)-(?:[0-9a-z]+)""".r
private val candidateVersion = """v?([0-9.]+)(?:-rc\.\d+)?-\d+-[0-9a-z]+""".r

// v0.1.47
// 1.5.0-rc.1
private val releaseVersion = """v?([0-9\.]+(?:-rc\.\d+)?)""".r
private val releaseVersion = """v?([0-9.]+(?:-rc\.\d+)?)""".r

/**
* Needs to check for "false", don't assume it will ever be set to "true".
Expand All @@ -34,11 +34,11 @@ object GitVersion {
* version to start with.
*/
private def toSnapshotVersion(branch: String, v: String): String = {
val v2 = Version(v).map(_.bump.string).getOrElse(v)
val v2 = Version(v).map(_.bumpNext.unapply).getOrElse(v)
val suffix = "-SNAPSHOT"
branch match {
case versionBranch(b) if !v2.startsWith(b) =>
s"${Version(s"$b.0").map(_.string).getOrElse(v2)}$suffix"
s"${Version(s"$b.0").map(_.unapply).getOrElse(v2)}$suffix"
case _ =>
s"$v2$suffix"
}
Expand All @@ -53,7 +53,7 @@ object GitVersion {
parts(parts.length - 1)
}

lazy val settings: Seq[Def.Setting[_]] = Seq(
lazy val settings: Seq[Def.Setting[?]] = Seq(
ThisBuild / version := {
val branch = extractBranchName(git.gitCurrentBranch.value)
val branchVersion = if (branch == "main" || branch == "master") baseVersion else branch
Expand Down
6 changes: 3 additions & 3 deletions project/License.scala → project/LicenseCheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import java.io.PrintStream
import java.time.ZonedDateTime
import java.time.ZoneOffset
import scala.io.Source
import sbt._
import sbt.*

import scala.util.Using

Expand All @@ -15,8 +15,8 @@ import scala.util.Using
* - supports both test and main source files
* - add target to check which can fail the build
*/
object License {
private val lineSeparator = System.getProperty("line.separator")
object LicenseCheck {
private val lineSeparator = java.lang.System.lineSeparator()

def year: Int = ZonedDateTime.now(ZoneOffset.UTC).getYear

Expand Down

0 comments on commit 9b5b20c

Please sign in to comment.