Skip to content

Commit c93697e

Browse files
committed
Get sonatype credentials from environment variables
One more step in the direction of sbt-ci-release See also #203
1 parent dd59198 commit c93697e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

build.sbt

+20
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@ lazy val defaults = Seq(
7474
if (version.value endsWith "-SNAPSHOT") Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
7575
else Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
7676
},
77+
// This should no longer be necessary once we update to sbt-ci-release
78+
// https://github.com/lightbend/genjavadoc/issues/203
79+
credentials ++= {
80+
val alreadyContainsSonatypeCredentials = credentials.value.collect {
81+
case d: DirectCredentials => d.host == "oss.sonatype.org"
82+
}.nonEmpty
83+
if (!alreadyContainsSonatypeCredentials) {
84+
val env = sys.env.get(_)
85+
(for {
86+
username <- env("SONATYPE_USERNAME")
87+
password <- env("SONATYPE_PASSWORD")
88+
} yield
89+
Credentials(
90+
"Sonatype Nexus Repository Manager",
91+
"oss.sonatype.org",
92+
username,
93+
password
94+
)).toSeq
95+
} else Seq.empty
96+
},
7797
startYear := Some(2012),
7898
homepage := Some(url("https://github.com/lightbend/genjavadoc")),
7999
licenses := Seq("Apache-2.0" -> url("http://opensource.org/licenses/Apache-2.0")),

0 commit comments

Comments
 (0)