pekko/project/Publish.scala

63 lines
2 KiB
Scala
Raw Normal View History

/**
2017-01-04 17:37:10 +01:00
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
*/
2011-09-23 10:21:03 +02:00
package akka
2011-07-08 18:01:19 +12:00
import sbt._
2011-12-09 21:55:49 +13:00
import sbt.Keys._
2011-07-08 18:01:19 +12:00
import java.io.File
object Publish extends AutoPlugin {
2011-07-08 18:01:19 +12:00
val defaultPublishTo = settingKey[File]("Default publish directory")
2011-12-09 21:55:49 +13:00
override def trigger = allRequirements
override lazy val projectSettings = Seq(
crossPaths := false,
pomExtra := akkaPomExtra,
publishTo := akkaPublishTo.value,
credentials ++= akkaCredentials,
organizationName := "Lightbend Inc.",
organizationHomepage := Some(url("http://www.lightbend.com")),
2012-03-30 09:59:33 -04:00
publishMavenStyle := true,
2017-10-06 10:30:28 +02:00
pomIncludeRepository := { x false },
defaultPublishTo := crossTarget.value / "repository")
2011-07-08 18:01:19 +12:00
def akkaPomExtra = {
/* The scm info is automatic from the sbt-git plugin
2012-03-30 09:59:33 -04:00
<scm>
<url>git://github.com/akka/akka.git</url>
<connection>scm:git:git@github.com:akka/akka.git</connection>
</scm>
*/
<inceptionYear>2009</inceptionYear>
2012-03-30 09:59:33 -04:00
<developers>
<developer>
<id>akka-contributors</id>
<name>Akka Contributors</name>
<email>akka-dev@googlegroups.com</email>
<url>https://github.com/akka/akka/graphs/contributors</url>
</developer>
2012-03-30 09:59:33 -04:00
</developers>
2011-07-08 18:01:19 +12:00
}
private def akkaPublishTo = Def.setting {
sonatypeRepo(version.value) orElse localRepo(defaultPublishTo.value)
}
private def sonatypeRepo(version: String): Option[Resolver] =
2017-10-06 10:30:28 +02:00
Option(sys.props("publish.maven.central")) filter (_.toLowerCase == "true") map { _
val nexus = "https://oss.sonatype.org/"
if (version endsWith "-SNAPSHOT") "snapshots" at nexus + "content/repositories/snapshots"
else "releases" at nexus + "service/local/staging/deploy/maven2"
2011-12-09 21:55:49 +13:00
}
2011-07-08 18:01:19 +12:00
private def localRepo(repository: File) =
Some(Resolver.file("Default Local Repository", repository))
2011-07-08 18:01:19 +12:00
private def akkaCredentials: Seq[Credentials] =
2017-10-06 10:30:28 +02:00
Option(System.getProperty("akka.publish.credentials", null)).map(f Credentials(new File(f))).toSeq
2011-07-08 18:01:19 +12:00
}