Skip to content

use coursier instead of sbt for Scala 3 scripts #1466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions advance
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
# % ./advance scalacheck scalatest specs2

set -e
cd scripts
sbt -Dsbt.supershell=false -error "runMain advance $*" < /dev/null

# as per https://github.com/coursier/coursier/issues/2058
cs launch \
scala3-compiler:3+ \
-M dotty.tools.MainGenericRunner \
--extra-jars $(cs fetch --intransitive org.scala-lang.modules:scala-parallel-collections_3:1.0.3) \
--extra-jars $(cs fetch --intransitive com.github.pathikrit:better-files_2.13:3.9.1) \
-- scripts/Advance.scala $*
9 changes: 7 additions & 2 deletions narrow
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@
# dependencies.txt is the source of truth for what dependencies to use

set -e
cd scripts
sbt -Dsbt.supershell=false -error "runMain narrow $*" < /dev/null

# as per https://github.com/coursier/coursier/issues/2058
cs launch \
scala3-compiler:3+ \
-M dotty.tools.MainGenericRunner \
--extra-jars $(cs fetch --intransitive com.github.pathikrit:better-files_2.13:3.9.1) \
-- scripts/Narrow.scala $*
9 changes: 7 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@ BUILD_ID="$(grep '^\[info\] uuid = ' "dbuild-${DBUILDVERSION}/dbuild.out" | sed
rm_project_builds

# report summary information (line counts, green project counts, ...?)
cd scripts
sbt -Dsbt.supershell=false -Dlog4j.configurationFile=log4j.properties -error "runMain report ../dbuild-${DBUILDVERSION}/dbuild.out" < /dev/null | tee ../report.html
# (Scala 3 script support is as per https://github.com/coursier/coursier/issues/2058)
cs launch \
scala3-compiler:3+ \
-M dotty.tools.MainGenericRunner \
-D log4j.configurationFile=scripts/log4j.properties \
-- scripts/Report.scala dbuild-${DBUILDVERSION}/dbuild.out \
| tee report.html

# we've captured $STATUS above, but in this version of the script, it isn't used,
# instead the reporting stuff is in charge of calling sys.exit if it decides to
Expand Down
1 change: 0 additions & 1 deletion scripts/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/Advance.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import better.files._
import scala.collection.parallel.CollectionConverters._ // for .par

@main def advance(args: String*) =
import scala.collection.parallel.CollectionConverters._
// regexes for matching first line of each project's config
// note that we require an explicit tag or branch name,
// or a SHA (which must be the whole 40 characters).
Expand All @@ -11,7 +11,7 @@ import better.files._
val GitHub = """// (https://github.com/\S*.git)#(\S*)(\s*.*)""".r
val Ivy = """// ivy:.*""".r
for
file <- File("../proj").list(_.extension == Some(".conf")).toSeq.par
file <- File("proj").list(_.extension == Some(".conf")).toSeq.par
if args.isEmpty || args.contains(file.nameWithoutExtension)
do
val lines = file.lines.to(Vector)
Expand Down
4 changes: 2 additions & 2 deletions scripts/Narrow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import better.files._

// read dependency information
val tree: Map[String, Set[String]] =
val deps = File("../dependencies.txt")
val deps = File("dependencies.txt")
val Regex = """(\S+): (.*)""".r
deps.lines.map{
case Regex(proj, deps) =>
Expand All @@ -18,7 +18,7 @@ import better.files._
-- Set("scala", "cloc-plugin"))

// write results
val projs = File("../projs.conf")
val projs = File("projs.conf")
projs.clear()
projs.append(
"""|build += {
Expand Down
12 changes: 6 additions & 6 deletions scripts/Report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ object SplitLog:
val EndBuild = """\[([^\]]+)\] --== End Building .+ ==--""".r

def apply(log: io.Source): Unit =
val dir = java.io.File("../logs")
val dir = java.io.File("logs")
dir.mkdirs()
val lines = log.getLines
while lines.hasNext do
lines.next match
case BeginDependencies() =>
slurp(lines, makeWriter("../logs/_dependencies.log"), EndDependencies)
slurp(lines, makeWriter("logs/_dependencies.log"), EndDependencies)
case BeginExtract(name) =>
slurp(lines, makeWriter(s"../logs/$name-extract.log"), EndExtract)
slurp(lines, makeWriter(s"logs/$name-extract.log"), EndExtract)
case BeginBuild(name) =>
slurp(lines, makeWriter(s"../logs/$name-build.log"), EndBuild)
slurp(lines, makeWriter(s"logs/$name-build.log"), EndBuild)
case _ =>

import java.io.PrintWriter
Expand Down Expand Up @@ -178,10 +178,10 @@ object UpdateDependencies:
val Line1 = """\[info\] Project (\S+)""".r
val Line2 = """\[info\] depends on: (.*)""".r
def apply(): Unit =
val inFile = java.io.File("../logs/_dependencies.log")
val inFile = java.io.File("logs/_dependencies.log")
if inFile.exists then
val in = io.Source.fromFile(inFile)
val out = SplitLog.makeWriter("../dependencies.txt")
val out = SplitLog.makeWriter("dependencies.txt")
val tuples =
for Seq(Line1(project), Line2(depends)) <- in.getLines.grouped(2).toSeq
yield (project, depends)
Expand Down
9 changes: 0 additions & 9 deletions scripts/build.sbt

This file was deleted.

1 change: 0 additions & 1 deletion scripts/project/build.properties

This file was deleted.