1+ import com .jsuereth .sbtpgp .PgpKeys .publishSigned
2+
3+ // Used to publish snapshots to Maven Central.
4+ val mavenCentralSnapshots = " Maven Central Snapshots" at " https://central.sonatype.com/repository/maven-snapshots"
5+
6+ // Versions:
7+
18val scala2_13 = " 2.13.16"
29
310val scala3Versions = Seq (
@@ -13,18 +20,75 @@ val scala3Latest = scala3Versions.last
1320
1421val newtypeVersion = " 0.4.4"
1522
16- ThisBuild / organization := " com.kubuszok"
17- ThisBuild / versionScheme := Some (" early-semver" )
23+ // Common settings:
24+
25+ val publishSettings = Seq (
26+ organization := " com.kubuszok" ,
27+ homepage := Some (url(" https://github.com/MateuszKubuszok/scala-newtype-compat" )),
28+ organizationHomepage := Some (url(" https://kubuszok.com" )),
29+ licenses := Seq (" Apache-2.0" -> url(" https://www.apache.org/licenses/LICENSE-2.0" )),
30+ scmInfo := Some (
31+ ScmInfo (
32+ url(" https://github.com/MateuszKubuszok/scala-newtype-compat/" ),
33+ " scm:git:git@github.com:MateuszKubuszok/scala-newtype-compat.git"
34+ )
35+ ),
36+ startYear := Some (2026 ),
37+ developers := List (
38+ Developer (" MateuszKubuszok" , " Mateusz Kubuszok" , " " , url(" https://github.com/MateuszKubuszok" ))
39+ ),
40+ pomExtra := (
41+ <issueManagement >
42+ <system >GitHub issues</system >
43+ <url >https:// github.com/ MateuszKubuszok / scala- newtype- compat/ issues</url >
44+ </issueManagement >
45+ ),
46+ publishTo := {
47+ if (isSnapshot.value) Some (mavenCentralSnapshots)
48+ else localStaging.value
49+ },
50+ publishMavenStyle := true ,
51+ Test / publishArtifact := false ,
52+ pomIncludeRepository := {
53+ _ => false
54+ },
55+ versionScheme := Some (" early-semver" ),
56+ git.useGitDescribe := true ,
57+ git.uncommittedSignifier := None ,
58+ // Sonatype ignores isSnapshot setting and only looks at -SNAPSHOT suffix in version:
59+ // https://central.sonatype.org/publish/publish-maven/#performing-a-snapshot-deployment
60+ // meanwhile sbt-git used to set up SNAPSHOT if there were uncommitted changes:
61+ // https://github.com/sbt/sbt-git/issues/164
62+ // (now this suffix is empty by default) so we need to fix it manually.
63+ git.gitUncommittedChanges := git.gitCurrentTags.value.isEmpty,
64+ git.uncommittedSignifier := Some (" SNAPSHOT" )
65+ )
66+
67+ val noPublishSettings =
68+ Seq (publish / skip := true , publishArtifact := false )
69+
70+ // Modules:
1871
1972lazy val root = project
2073 .in(file(" ." ))
74+ .enablePlugins(GitVersioning , GitBranchPrompt )
75+ .settings(publishSettings)
76+ .settings(noPublishSettings)
2177 .settings(
22- publish / skip := true ,
23- crossScalaVersions := Nil
78+ name := " scala-newtype-compat-root" ,
79+ crossScalaVersions := Nil ,
80+ commands += Command .command(" ci-release" ) { state =>
81+ val extracted = Project .extract(state)
82+ val tags = extracted.get(git.gitCurrentTags)
83+ val cmd = if (tags.nonEmpty) " publishSigned ; sonaRelease" else " publishSigned"
84+ cmd :: state
85+ }
2486 )
2587 .aggregate(compat, plugin, tests)
2688
2789lazy val compat = project
90+ .enablePlugins(GitVersioning , GitBranchPrompt )
91+ .settings(publishSettings)
2892 .settings(
2993 name := " newtype-compat" ,
3094 crossScalaVersions := scala2_13 +: scala3Versions,
@@ -36,6 +100,8 @@ lazy val compat = project
36100 )
37101
38102lazy val plugin = project
103+ .enablePlugins(GitVersioning , GitBranchPrompt )
104+ .settings(publishSettings)
39105 .settings(
40106 name := " newtype-plugin" ,
41107 crossScalaVersions := scala3Versions,
@@ -45,9 +111,11 @@ lazy val plugin = project
45111
46112lazy val tests = project
47113 .dependsOn(compat)
114+ .enablePlugins(GitVersioning , GitBranchPrompt )
115+ .settings(publishSettings)
116+ .settings(noPublishSettings)
48117 .settings(
49118 name := " newtype-compat-tests" ,
50- publish / skip := true ,
51119 crossScalaVersions := scala2_13 +: scala3Versions,
52120 scalaVersion := scala3Latest,
53121 scalacOptions ++= {
0 commit comments