Skip to content

Commit

Permalink
Merge pull request scala#10866 from lrytz/develocity-12
Browse files Browse the repository at this point in the history
Add Gradle Develocity (2.12.x)
  • Loading branch information
SethTisue authored Oct 10, 2024
2 parents e65b9ee + 9ca1e84 commit 2f23835
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ We are grateful for the following OSS licenses:
- [JProfiler Java profiler](https://www.ej-technologies.com/products/jprofiler/overview.html)
- [YourKit Java Profiler](https://www.yourkit.com/java/profiler/)
- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/)
- [![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://develocity.scala-lang.org)

## Build setup

Expand Down
40 changes: 39 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,44 @@ globalVersionSettings
|""".stripMargin
))

// Run `sbt -Dscala.build.publishDevelocity` to publish build scans to develocity.scala-lang.org
// In Jenkins, the `...publishDevelocity=stage` value is used to set the `JENKINS_STAGE` value of the scan
ThisBuild / develocityConfiguration := {
def pubDev = Option(System.getProperty("scala.build.publishDevelocity"))
val isInsideCI = sys.env.get("JENKINS_URL").exists(_.contains("scala-ci.typesafe.com"))
val config = develocityConfiguration.value
val buildScan = config.buildScan
val buildCache = config.buildCache
config
.withProjectId(ProjectId("scala2"))
.withServer(config.server.withUrl(Some(url("https://develocity.scala-lang.org"))))
.withBuildScan(
buildScan
.withPublishing(Publishing.onlyIf(ctx => pubDev.nonEmpty && ctx.authenticated))
.withBackgroundUpload(false)
.tag(if (isInsideCI) "CI" else "Local")
.tag("2.12")
.withLinks(buildScan.links ++
sys.env.get("BUILD_URL").map(u => "Jenkins Build" -> url(u)) ++
sys.env.get("repo_ref").map(sha => "GitHub Commit" -> url(s"https://github.com/scala/scala/commit/$sha")) ++
sys.env.get("_scabot_pr").map(pr => "GitHub PR " -> url(s"https://github.com/scala/scala/pull/$pr")))
.withValues(buildScan.values +
("GITHUB_REPOSITORY" -> "scala/scala") +
("GITHUB_BRANCH" -> "2.12.x") ++
pubDev.filterNot(_.isEmpty).map("JENKINS_STAGE" -> _) ++
sys.env.get("JOB_NAME").map("JENKINS_JOB_NAME" -> _) ++
sys.env.get("repo_ref").map("GITHUB_SHA" -> _) ++
sys.env.get("_scabot_pr").map("GITHUB_PR" -> _) ++
sys.env.get("NODE_NAME").map("JENKINS_NODE" -> _))
.withObfuscation(buildScan.obfuscation.withIpAddresses(_.map(_ => "0.0.0.0")))
)
.withBuildCache(
buildCache
.withLocal(buildCache.local.withEnabled(false))
.withRemote(buildCache.remote.withEnabled(false))
)
}

(Global / scalaVersion) := versionProps("starr.version")

lazy val instanceSettings = Seq[Setting[_]](
Expand Down Expand Up @@ -918,7 +956,7 @@ lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-di
)
.dependsOn(libraryAll, compiler, scalap)

lazy val root: Project = (project in file("."))
lazy val scala2: Project = (project in file("."))
.settings(disableDocs)
.settings(disablePublishing)
.settings(generateBuildCharacterFileSettings)
Expand Down
17 changes: 7 additions & 10 deletions project/ScriptCommands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,18 @@ object ScriptCommands {
def setupPublishCoreNonOpt = setup("setupPublishCoreNonOpt") { args =>
Seq(
(Global / baseVersionSuffix) := "SHA-SNAPSHOT"
) ++ (args match {
case Seq(url) => publishTarget(url)
case Nil => Nil
) ++ (args flatMap {
case url => publishTarget(url)
}) ++ noDocs
}

/** Set up the environment for `validate/publish-core`.
* The optional argument is the Artifactory snapshot repository URL. */
def setupPublishCore = setup("setupPublishCore") { args =>
Seq(
(Global / baseVersionSuffix) := "SHA-SNAPSHOT"
) ++ (args match {
case Seq(url) => publishTarget(url)
case Nil => Nil
(Global / baseVersionSuffix) := "SHA-SNAPSHOT",
) ++ (args flatMap {
case url => publishTarget(url)
}) ++ noDocs ++ enableOptimizer
}

Expand All @@ -49,9 +47,8 @@ object ScriptCommands {
def setupValidateTest = setup("setupValidateTest") { args =>
Seq(
LocalProject("test") / IntegrationTest / testOptions ++= Seq(Tests.Argument("--show-log"), Tests.Argument("--show-diff"))
) ++ (args match {
case Seq(url) => Seq((Global / resolvers) += "scala-pr" at url)
case Nil => Nil
) ++ (args flatMap {
case url => Seq((Global / resolvers) += "scala-pr" at url)
}) ++ enableOptimizer
}

Expand Down
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ concurrentRestrictions in Global := Seq(
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7")

addSbtPlugin("com.gradle" % "sbt-develocity" % "1.1.1")
2 changes: 1 addition & 1 deletion scripts/jobs/validate/publish-core
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ case $prDryRun in
if $libraryAvailable && $reflectAvailable && $compilerAvailable; then
echo "Scala core already built!"
else
$SBT -warn "setupPublishCore $prRepoUrl" publish
$SBT -Dscala.build.publishDevelocity=build -warn "setupPublishCore $prRepoUrl" publish
fi

mv buildcharacter.properties jenkins.properties # parsed by the jenkins job
Expand Down
1 change: 1 addition & 0 deletions scripts/jobs/validate/test
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ case $prDryRun in
# and run JUnit tests, ScalaCheck tests, partest, OSGi tests, MiMa and scaladoc
$SBT \
-Dstarr.version=$scalaVersion \
-Dscala.build.publishDevelocity=test \
-warn \
"setupValidateTest $prRepoUrl" \
$testExtraArgs \
Expand Down

0 comments on commit 2f23835

Please sign in to comment.