ihostage
(Sergey Morgunov)
1
Sometimes you want to build and publish a custom version of Lagom with bugfix (don’t forget share fix to community ) or maybe specific features.
Below the simple How To, how you can do that using Nexus 3 and Maven repository.
- Change version in
versions.sbt
- WA for SBT 0.13 (see details if interested). Add to top of
build.sbt
next line:
isSnapshot in ThisBuild := true
- Change
sonatypeSettings
in build.sbt
:
def sonatypeSettings: Seq[Setting[_]] = Seq(
// Use for publish release versions
publishTo := Some("releases" at "http://nexus.domain/repository/maven-releases"),
// Use for publish snapshot versions
// publishTo := Some("snapshots" at "nexus.domain/repository/maven-snapshots"),
credentials += Credentials(
"Sonatype Nexus Repository Manager",
"nexus.domain",
sys.props.getOrElse("nexusUser", System.getenv("NEXUS_USER")),
sys.props.getOrElse("nexusPassword", System.getenv("NEXUS_PASSWORD"))
)
)
- Remove
publishTo
settings for sbt-plugin
and add sonatypeSettings
:
lazy val `sbt-plugin` = (project in file("dev") / "sbt-plugin")
...
.settings(sonatypeSettings: _*)
.settings(
...
publishMavenStyle := true
)
...
- Export environment variables (Bintray credentials can be empty):
export NEXUS_USER=nexus_user
export NEXUS_PASSWORD=****
export BINTRAY_PASS=
export BINTRAY_USER=
- Run
publish
command
sbt "+++ 2.12.6 publish"
- Profit!
PS: Of course, a Lagom develops and sometime this instruction may become outdated. But I think it may be useful for someone like us
2 Likes
ihostage
(Sergey Morgunov)
2
Patch for build.sbt:
Index: build.sbt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- build.sbt (revision 850a97b46b9b7f451a830fa7d51295d14ee1e130)
+++ build.sbt (date 1552469191000)
@@ -14,6 +14,7 @@
// Turn off "Resolving" log messages that clutter build logs
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet
+isSnapshot in ThisBuild := true
def defineSbtVersion(scalaBinVer: String): String = scalaBinVer match {
case "2.12" => "1.2.1"
@@ -136,7 +137,17 @@
}
def sonatypeSettings: Seq[Setting[_]] = Seq(
- publishTo := sonatypePublishTo.value
+ // Use for publish release versions
+ publishTo := Some("releases" at "http://nexus.domain/repository/maven-releases")
+ // Use for publish SNAPSHOT versions
+ // publishTo := Some("snapshots" at "http://nexus.domain/repository/maven-snapshots")
+ ,
+ credentials += Credentials(
+ "Sonatype Nexus Repository Manager",
+ "nexus.domain",
+ sys.props.getOrElse("nexusUser", System.getenv("NEXUS_USER")),
+ sys.props.getOrElse("nexusPassword", System.getenv("NEXUS_PASSWORD"))
+ )
)
def runtimeScalaSettings: Seq[Setting[_]] = Seq(
@@ -1162,6 +1173,7 @@
.settings(common: _*)
.settings(scriptedSettings: _*)
.enablePlugins(SbtPluginPlugins)
+ .settings(sonatypeSettings: _*)
.settings(
name := "lagom-sbt-plugin",
sbtPlugin := true,
@@ -1206,13 +1218,7 @@
val () = (publishLocal in `sbt-scripted-library`).value
val () = (publishLocal in LocalProject("sbt-scripted-tools")).value
},
- publishTo := {
- if (isSnapshot.value) {
- // Bintray doesn't support publishing snapshots, publish to Sonatype snapshots instead
- Some(Opts.resolver.sonatypeSnapshots)
- } else publishTo.value
- },
- publishMavenStyle := isSnapshot.value
+ publishMavenStyle := true
).dependsOn(`sbt-build-tool-support`)
lazy val `maven-plugin` = (project in file("dev") / "maven-plugin")