diff options
author | Nikolay Tatarinov <rockjam@actor.im> | 2016-10-03 20:19:27 +0300 |
---|---|---|
committer | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-10-03 13:19:27 -0400 |
commit | 669ef3dfc3201fffa451b47d2b629a856afc0b25 (patch) | |
tree | 7bcb64c58266a4fe2dd3965dda47dc6f8fa71b04 /stage2 | |
parent | 174c52b2c24b8491eef687ee5eb3c3b77c34a61c (diff) | |
download | cbt-669ef3dfc3201fffa451b47d2b629a856afc0b25.tar.gz cbt-669ef3dfc3201fffa451b47d2b629a856afc0b25.tar.bz2 cbt-669ef3dfc3201fffa451b47d2b629a856afc0b25.zip |
Sonatype release plugin (#247)
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/BuildBuild.scala | 1 | ||||
-rw-r--r-- | stage2/Lib.scala | 11 | ||||
-rw-r--r-- | stage2/PackageJars.scala | 1 | ||||
-rw-r--r-- | stage2/Publish.scala | 34 |
4 files changed, 13 insertions, 34 deletions
diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala index f444803..b183745 100644 --- a/stage2/BuildBuild.scala +++ b/stage2/BuildBuild.scala @@ -15,6 +15,7 @@ trait BuildBuild extends BaseBuild{ final lazy val scalafmt = DirectoryDependency( managedContext.cbtHome ++ "/plugins/scalafmt" ) final lazy val wartremover = DirectoryDependency( managedContext.cbtHome ++ "/plugins/wartremover" ) final lazy val uberJar = DirectoryDependency( managedContext.cbtHome ++ "/plugins/uber-jar" ) + final lazy val sonatypeRelease = DirectoryDependency( managedContext.cbtHome ++ "/plugins/sonatype-release" ) } override def dependencies = diff --git a/stage2/Lib.scala b/stage2/Lib.scala index c18bf2e..25183a3 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -272,6 +272,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } yield file } + // FIXME: for some reason it includes full path in docs def jarFile( jarFile: File, files: Seq[File], mainClass: Option[String] = None ): Option[File] = { Files.deleteIfExists(jarFile.toPath) if( files.isEmpty ){ @@ -430,11 +431,9 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } } - def publishSigned( sourceFiles: Seq[File], artifacts: Seq[File], url: URL, credentials: Option[String] = None ): Unit = { + def publishSigned( artifacts: Seq[File], url: URL, credentials: Option[String] = None ): Unit = { // TODO: make concurrency configurable here - if(sourceFiles.nonEmpty){ - publish( artifacts ++ artifacts.map(sign), url, credentials ) - } + publish( artifacts ++ artifacts.map(sign), url, credentials ) } private def publish(artifacts: Seq[File], url: URL, credentials: Option[String]): Unit = { @@ -450,12 +449,12 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } def uploadAll(url: URL, nameAndContents: Seq[(String, Array[Byte])], credentials: Option[String] = None ): Unit = - nameAndContents.map{ case(name, content) => upload(name, content, url, credentials ) } + nameAndContents.foreach { case (name, content) => upload(name, content, url, credentials ) } def upload(fileName: String, fileContents: Array[Byte], baseUrl: URL, credentials: Option[String] = None): Unit = { import java.net._ import java.io._ - val url = baseUrl ++ fileName + val url = baseUrl ++ "/" ++ fileName System.err.println(blue("uploading ") ++ url.toString) val httpCon = Stage0Lib.openConnectionConsideringProxy(url) httpCon.setDoOutput(true) diff --git a/stage2/PackageJars.scala b/stage2/PackageJars.scala index 10e4c3a..a101993 100644 --- a/stage2/PackageJars.scala +++ b/stage2/PackageJars.scala @@ -1,5 +1,6 @@ package cbt import java.io.File + // would love to call this just `Package` but that conflicts with scala package objects. trait PackageJars extends BaseBuild with ArtifactInfo{ def name: String diff --git a/stage2/Publish.scala b/stage2/Publish.scala index 96e856b..7e00620 100644 --- a/stage2/Publish.scala +++ b/stage2/Publish.scala @@ -35,37 +35,15 @@ trait Publish extends PackageJars{ ) // ========== publish ========== - final protected val releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version/" - private def snapshotUrl = new URL("https://oss.sonatype.org/content/repositories/snapshots") - private def releaseUrl = new URL("https://oss.sonatype.org/service/local/staging/deploy/maven2") - def publishUrl = if(version.endsWith("-SNAPSHOT")) snapshotUrl else releaseUrl - override def copy(context: Context) = super.copy(context).asInstanceOf[Publish] - - protected def sonatypeCredentials: Option[String] = { - // FIXME: this should probably not use cbtHome, but some reference to the system's host cbt - Some(new String(readAllBytes((context.cbtRootHome ++ "/sonatype.login").toPath)).trim) - } - - def publishSnapshot: Unit = { - copy( context.copy(version = Some(version+"-SNAPSHOT")) ).publishUnsigned - } + private val releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version/" - def publishLocal: Unit = { + def publishLocal: Unit = lib.publishLocal( sourceFiles, `package` :+ pom, context.paths.mavenCache, releaseFolder ) - } - def publishSnapshotLocal: Unit = { + def publishSnapshotLocal: Unit = copy( context.copy(version = Some(version+"-SNAPSHOT")) ).publishLocal - } - def publishUnsigned: Unit = { - lib.publishUnsigned( - sourceFiles, `package` :+ pom, publishUrl ++ releaseFolder, sonatypeCredentials - ) - } - def publishSigned: Unit = { - lib.publishSigned( - sourceFiles, `package` :+ pom, publishUrl ++ releaseFolder, sonatypeCredentials - ) - } + def isSnapshot: Boolean = version.endsWith("-SNAPSHOT") + + override def copy(context: Context) = super.copy(context).asInstanceOf[Publish] } |