This repository has been archived by the owner on Feb 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from eed3si9n/wip/split
Add sbt-bintray-remote-cache
- Loading branch information
Showing
36 changed files
with
414 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
sbt-bintray-remote-cache | ||
======================== | ||
|
||
requirements | ||
------------ | ||
|
||
- an account on [bintray](https://bintray.com) (get one [here](https://bintray.com/signup/oss)) | ||
- a desire to build a zero-second build | ||
|
||
setup | ||
----- | ||
|
||
Add the following to your sbt `project/plugins.sbt` file: | ||
|
||
![Bintray version](https://img.shields.io/bintray/v/sbt/sbt-plugin-releases/sbt-bintray.svg) | ||
|
||
```scala | ||
addSbtPlugin("org.foundweekends" % "sbt-bintray-remote-cache" % "x.y.z") | ||
``` | ||
|
||
### Bintray repo and package | ||
|
||
Go to `https://bintray.com/<your_bintray_user>/` and create a new **Generic** repository with the name **`remote-cache`**. | ||
|
||
Next, create a _package_ within the remote-cache repo. The granularity should typically be one package for one build. | ||
|
||
### build.sbt | ||
|
||
Then in your `build.sbt`: | ||
|
||
```scala | ||
ThisBuild / bintrayRemoteCacheOrganization := "your_bintray_user or organization" | ||
ThisBuild / bintrayRemoteCachePackage := "your_package_name" | ||
``` | ||
|
||
usage | ||
----- | ||
|
||
### credentials | ||
|
||
To push remote cache, you need to provide Bintray credentials (user name and API key) using a credential file or environment variables. | ||
|
||
1. Environment variables | ||
|
||
sbt-bintray-remote-cache will look for bintray user and pass in the environment variables `BINTRAY_REMOTE_CACHE_USER` and `BINTRAY_REMOTE_CACHE_PASS`. Note that these are different from sbt-bintray. | ||
|
||
2. Credentials file | ||
|
||
sbt-bintray-remote-cache will look for a credentials file under `~/.bintray/.credentials` used to authenticate publishing requests to bintray. | ||
|
||
### pushing remote cache | ||
|
||
From the CI machine, run | ||
|
||
``` | ||
> pushRemoteCache | ||
``` | ||
|
||
### cleaning up the old cache | ||
|
||
From the CI machine, run | ||
|
||
``` | ||
> bintrayRemoteCacheCleanOld | ||
``` | ||
|
||
This will **remove** versions older than a month, while keeping minimum 100 cache entry. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,71 @@ | ||
lazy val unusedWarnings = Seq("-Ywarn-unused-import", "-Ywarn-unused") | ||
|
||
ThisBuild / organization := "org.foundweekends" | ||
ThisBuild / homepage := Some(url(s"https://github.com/sbt/${name.value}")) | ||
ThisBuild / licenses := Seq("MIT" -> | ||
url(s"https://github.com/sbt/${name.value}/blob/${version.value}/LICENSE")) | ||
ThisBuild / description := "package publisher for bintray.com" | ||
ThisBuild / developers := List( | ||
Developer("softprops", "Doug Tangren", "@softprops", url("https://github.com/softprops")) | ||
) | ||
ThisBuild / scmInfo := Some(ScmInfo(url(s"https://github.com/sbt/${name.value}"), s"[email protected]:sbt/${name.value}.git")) | ||
ThisBuild / scalaVersion := "2.12.12" | ||
|
||
lazy val commonSettings: Seq[Setting[_]] = Seq( | ||
organization in ThisBuild := "org.foundweekends", | ||
homepage in ThisBuild := Some(url(s"https://github.com/sbt/${name.value}")), | ||
licenses in ThisBuild := Seq("MIT" -> | ||
url(s"https://github.com/sbt/${name.value}/blob/${version.value}/LICENSE")), | ||
description in ThisBuild := "package publisher for bintray.com", | ||
developers in ThisBuild := List( | ||
Developer("softprops", "Doug Tangren", "@softprops", url("https://github.com/softprops")) | ||
), | ||
scmInfo in ThisBuild := Some(ScmInfo(url(s"https://github.com/sbt/${name.value}"), s"[email protected]:sbt/${name.value}.git")), | ||
// crossScalaVersions in ThisBuild := Seq("2.10.7", "2.11.8", "2.12.6"), | ||
scalaVersion := (crossScalaVersions in ThisBuild).value.last, | ||
scalacOptions ++= Seq(Opts.compile.deprecation, "-Xlint", "-feature"), | ||
scalacOptions ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)){ | ||
case Some((2, v)) if v >= 11 => unusedWarnings | ||
}.toList.flatten, | ||
publishArtifact in Test := false, | ||
bintrayRepository := "sbt-plugin-releases", | ||
bintrayOrganization := Some("sbt"), | ||
bintrayPackage := "sbt-bintray" | ||
bintrayPackage := "sbt-bintray", | ||
scriptedBufferLog := true, | ||
scriptedLaunchOpts ++= Seq( | ||
"-Xmx1024M", | ||
"-XX:MaxPermSize=256M", | ||
"-Dbintray.user=username", | ||
"-Dbintray.pass=password", | ||
"-Dplugin.version=" + version.value | ||
), | ||
) ++ Seq(Compile, Test).flatMap(c => | ||
scalacOptions in (c, console) --= unusedWarnings | ||
) | ||
|
||
lazy val root = (project in file(".")) | ||
.aggregate(core, sbtBintray, sbtBintrayRemoteCache) | ||
.settings( | ||
publish / skip := true, | ||
) | ||
|
||
lazy val core = (project in file("core")) | ||
.enablePlugins(SbtPlugin) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "sbt-bintray", | ||
sbtPlugin := true, | ||
crossSbtVersions := List("0.13.18", "1.0.0"), | ||
scalaVersion := (CrossVersion partialVersion sbtCrossVersion.value match { | ||
case Some((0, 13)) => "2.10.7" | ||
case Some((1, _)) => "2.12.6" | ||
case _ => sys error s"Unhandled sbt version ${sbtCrossVersion.value}" | ||
}), | ||
name := "sbt-bintray-core", | ||
libraryDependencies ++= Seq( | ||
"org.foundweekends" %% "bintry" % "0.5.2", | ||
"org.slf4j" % "slf4j-nop" % "1.7.28"), // https://github.com/sbt/sbt-bintray/issues/26 | ||
"org.foundweekends" %% "bintry" % "0.6.0", | ||
"org.slf4j" % "slf4j-nop" % "1.7.28", // https://github.com/sbt/sbt-bintray/issues/26 | ||
"com.eed3si9n.verify" %% "verify" % "0.2.0" % Test, | ||
), | ||
testFrameworks += new TestFramework("verify.runner.Framework"), | ||
resolvers += Resolver.sonatypeRepo("releases"), | ||
scriptedSettings, | ||
scriptedBufferLog := true, | ||
scriptedLaunchOpts ++= Seq( | ||
"-Xmx1024M", | ||
"-XX:MaxPermSize=256M", | ||
"-Dbintray.user=username", | ||
"-Dbintray.pass=password", | ||
"-Dplugin.version=" + version.value | ||
) | ||
) | ||
|
||
val sbtCrossVersion = sbtVersion in pluginCrossBuild | ||
lazy val sbtBintray = (project in file("sbt-bintray")) | ||
.enablePlugins(SbtPlugin) | ||
.dependsOn(core) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "sbt-bintray", | ||
pluginCrossBuild / sbtVersion := "1.0.0", | ||
) | ||
|
||
lazy val sbtBintrayRemoteCache = (project in file("sbt-bintray-remote-cache")) | ||
.enablePlugins(SbtPlugin) | ||
.dependsOn(core) | ||
.settings(commonSettings) | ||
.settings( | ||
name := "sbt-bintray-remote-cache", | ||
pluginCrossBuild / sbtVersion := "1.4.1", | ||
) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package bintray | ||
|
||
import java.io.File | ||
|
||
/** | ||
* This abstract which environmental variable will be used by which plugin. | ||
*/ | ||
case class BintrayCredentialContext( | ||
credsFile: File, | ||
userNameProp: String, | ||
passProp: String, | ||
userNameEnv: String, | ||
passEnv: String | ||
) | ||
|
||
object BintrayCredentialContext { | ||
def apply(credsFile: File): BintrayCredentialContext = | ||
BintrayCredentialContext( | ||
credsFile, | ||
"bintray.user", | ||
"bintray.pass", | ||
"BINTRAY_USER", | ||
"BINTRAY_PASS" | ||
) | ||
|
||
def remoteCache(credsFile: File): BintrayCredentialContext = | ||
BintrayCredentialContext( | ||
credsFile, | ||
"bintray.remote.cache.user", | ||
"bintray.remote.cache.pass", | ||
"BINTRAY_REMOTE_CACHE_USER", | ||
"BINTRAY_REMOTE_CACHE_PASS" | ||
) | ||
} |
File renamed without changes.
Oops, something went wrong.