Skip to content

Commit

Permalink
Setup whitesource tools (#1009)
Browse files Browse the repository at this point in the history
* Setup Whitesource in tools

* fix
  • Loading branch information
andreaTP authored Mar 23, 2021
1 parent 73862f1 commit e89c4a9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
run: |
cd core
sbt "scalafmtCheckAll; scalafmtSbtCheck"
cd ../tools
sbt "scalafmtCheckAll; scalafmtSbtCheck"
- name: Build documentation
run: |
sudo snap install yq
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
run: |
cd core
sbt "whitesourceCheckPolicies; whitesourceUpdate"
cd ../tools
sbt "whitesourceCheckPolicies; whitesourceUpdate"
- name: Build documentation
run: |
sudo snap install yq
Expand Down
33 changes: 33 additions & 0 deletions tools/project/WhitesourceLicensePlugin.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sbt._
import sbt.Keys._
import sbtwhitesource.WhiteSourcePlugin.autoImport._
import sbtwhitesource._
import scala.sys.process.Process
import scala.util.Try

object Whitesource extends AutoPlugin {
private lazy val gitCurrentBranch =
Try(Process("git rev-parse --abbrev-ref HEAD").!!.replaceAll("\\s", "")).recover {
case e => sys.error(s"Couldn't determine git branch for Whitesource: $e")
}.toOption

override def requires = WhiteSourcePlugin

override def trigger = allRequirements

override lazy val projectSettings = Seq(
// do not change the value of whitesourceProduct
whitesourceProduct := "cloudflow",
whitesourceAggregateProjectName := {
"cloudflow-tools-" + (
if (isSnapshot.value)
if (gitCurrentBranch.contains("master")) "master"
else "adhoc"
else majorMinor((LocalRootProject / version).value).map(_ + "-stable").getOrElse("adhoc")
)
},
whitesourceForceCheckAllDependencies := true,
whitesourceFailOnError := true)

private def majorMinor(version: String): Option[String] = """\d+\.\d+""".r.findFirstIn(version)
}
1 change: 1 addition & 0 deletions tools/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
// discipline
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.18")

libraryDependencies ++= Seq(
"org.codehaus.plexus" % "plexus-container-default" % "2.1.0",
Expand Down

0 comments on commit e89c4a9

Please sign in to comment.