Skip to content

Commit

Permalink
Merge branch 'main' into fix-cli-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou authored Jul 20, 2022
2 parents b456242 + 8903f22 commit 4746c4b
Show file tree
Hide file tree
Showing 98 changed files with 522 additions and 390 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ c8bf027df68d40d83698aebbd6dfe7f3ac83acbf
#Author: Tobias Roeser <[email protected]> Wed Mar 2 11:56:45 2022 +0100
# Reformatted source code
ba4e52433e07bd408fd3e52ab9b06659b687f594

# Scala Steward: Reformat with scalafmt 3.5.8
31a8c01406b77246150a8418a310132357b83e08
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.4.3"
version = "3.5.8"

align.preset = none
align.openParenCallSite = false
Expand Down
31 changes: 16 additions & 15 deletions bsp/src/mill/bsp/MillScalaBuildServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ trait MillScalaBuildServer extends ScalaBuildServer { this: MillBuildServer =>
val testFramework = m.testFramework()
val compResult = m.compile()

val (frameworkName, classFingerprint): (String, Agg[(Class[_], Fingerprint)]) = Jvm.inprocess(
classpath.map(_.path),
classLoaderOverrideSbtTesting = true,
isolated = true,
closeContextClassLoaderWhenDone = false,
cl => {
val framework = TestRunner.framework(testFramework)(cl)
val discoveredTests = TestRunner.discoverTests(
cl,
framework,
Agg(compResult.classes.path)
)
(framework.name(), discoveredTests)
}
)
val (frameworkName, classFingerprint): (String, Agg[(Class[_], Fingerprint)]) =
Jvm.inprocess(
classpath.map(_.path),
classLoaderOverrideSbtTesting = true,
isolated = true,
closeContextClassLoaderWhenDone = false,
cl => {
val framework = TestRunner.framework(testFramework)(cl)
val discoveredTests = TestRunner.discoverTests(
cl,
framework,
Agg(compResult.classes.path)
)
(framework.name(), discoveredTests)
}
)
val classes = Seq.from(classFingerprint.map(classF => classF._1.getName.stripSuffix("$")))
new ScalaTestClassesItem(id, classes.asJava, frameworkName)
}
Expand Down
2 changes: 1 addition & 1 deletion bsp/test/resources/bsp-modules/proj2/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import mill.scalalib._

object proj2 extends ScalaModule {
def scalaVersion = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???)
}
}
2 changes: 1 addition & 1 deletion bsp/test/resources/bsp-modules/proj3/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import mill.scalalib._

object proj3 extends ScalaModule {
def scalaVersion = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???)
}
}
2 changes: 1 addition & 1 deletion bsp/test/src/BspModulesTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object BspModulesTests extends ScriptTestSuite(false) {
"HelloBsp",
"HelloBsp.test",
"foreign-modules.proj1.proj1",
"foreign-modules.proj2.proj2",
"foreign-modules.proj2.proj2"
// "foreign-modules.proj3.proj3" // still not detected
).sorted
readModules ==> expectedModules
Expand Down
4 changes: 2 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object Deps {
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.2"
val coursier = ivy"io.get-coursier::coursier:2.1.0-M6"

val flywayCore = ivy"org.flywaydb:flyway-core:8.0.2"
val flywayCore = ivy"org.flywaydb:flyway-core:8.5.13"
val graphvizJava = ivy"guru.nidi:graphviz-java-all-j2v8:0.18.1"
val junixsocket = ivy"com.kohlschutter.junixsocket:junixsocket-core:2.5.1"

Expand All @@ -120,7 +120,7 @@ object Deps {
val sbtTestInterface = ivy"org.scala-sbt:test-interface:1.0"
val scalaCheck = ivy"org.scalacheck::scalacheck:1.16.0"
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:${scalaVersion}"
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.4.3"
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.5.8"
val scalametaTrees = ivy"org.scalameta::trees:4.5.9"
def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:${scalaVersion}"
def scalacScoveragePlugin = ivy"org.scoverage:::scalac-scoverage-plugin:1.4.11"
Expand Down
71 changes: 39 additions & 32 deletions ci/shared.sc
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
/**
* Utility code that is shared between our SBT build and our Mill build. SBT
* calls this by shelling out to Ammonite in a subprocess, while Mill loads it
* via import $file
*/
* Utility code that is shared between our SBT build and our Mill build. SBT
* calls this by shelling out to Ammonite in a subprocess, while Mill loads it
* via import $file
*/

import $ivy.`org.scalaj::scalaj-http:2.4.2`

def unpackZip(zipDest: os.Path, url: String) = {
println(s"Unpacking zip $url into $zipDest")
os.makeDir.all(zipDest)

val bytes = scalaj.http.Http.apply(url).option(scalaj.http.HttpOptions.followRedirects(true)).asBytes
val bytes =
scalaj.http.Http.apply(url).option(scalaj.http.HttpOptions.followRedirects(true)).asBytes
val byteStream = new java.io.ByteArrayInputStream(bytes.body)
val zipStream = new java.util.zip.ZipInputStream(byteStream)
while({
zipStream.getNextEntry match{
while ({
zipStream.getNextEntry match {
case null => false
case entry =>
if (!entry.isDirectory) {
val dest = zipDest / os.RelPath(entry.getName)
os.makeDir.all(dest / os.up)
val fileOut = new java.io.FileOutputStream(dest.toString)
val buffer = new Array[Byte](4096)
while ( {
while ({
zipStream.read(buffer) match {
case -1 => false
case n =>
Expand All @@ -35,34 +36,32 @@ def unpackZip(zipDest: os.Path, url: String) = {
zipStream.closeEntry()
true
}
})()
}) ()
}



@main
def downloadTestRepo(label: String, commit: String, dest: os.Path) = {
unpackZip(dest, s"https://github.com/$label/archive/$commit.zip")
dest
}

/**
* Copy of os-lib copy utility providing an additional `mergeFolders` option.
* See pr https://github.com/com-lihaoyi/os-lib/pull/65
*/
* Copy of os-lib copy utility providing an additional `mergeFolders` option.
* See pr https://github.com/com-lihaoyi/os-lib/pull/65
*/
object mycopy {
import os._
import java.nio.file
import java.nio.file.{CopyOption, LinkOption, StandardCopyOption, Files}
def apply(
from: os.Path,
to: os.Path,
followLinks: Boolean = true,
replaceExisting: Boolean = false,
copyAttributes: Boolean = false,
createFolders: Boolean = false,
mergeFolders: Boolean = false
): Unit = {
from: os.Path,
to: os.Path,
followLinks: Boolean = true,
replaceExisting: Boolean = false,
copyAttributes: Boolean = false,
createFolders: Boolean = false,
mergeFolders: Boolean = false
): Unit = {
if (createFolders) makeDir.all(to / up)
val opts1 =
if (followLinks) Array[CopyOption]()
Expand Down Expand Up @@ -94,15 +93,23 @@ object mycopy {

object into {
def apply(
from: os.Path,
to: os.Path,
followLinks: Boolean = true,
replaceExisting: Boolean = false,
copyAttributes: Boolean = false,
createFolders: Boolean = false,
mergeFolders: Boolean = false
): Unit = {
mycopy(from, to / from.last, followLinks, replaceExisting, copyAttributes, createFolders, mergeFolders)
from: os.Path,
to: os.Path,
followLinks: Boolean = true,
replaceExisting: Boolean = false,
copyAttributes: Boolean = false,
createFolders: Boolean = false,
mergeFolders: Boolean = false
): Unit = {
mycopy(
from,
to / from.last,
followLinks,
replaceExisting,
copyAttributes,
createFolders,
mergeFolders
)
}
}
}
}
3 changes: 2 additions & 1 deletion contrib/bloop/src/mill/contrib/bloop/BloopFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ object BloopFormats {
implicit val checksumRW: ReadWriter[BloopConfig.Checksum] = macroRW
implicit val linkerModeDebugRW: ReadWriter[BloopConfig.LinkerMode.Debug.type] = macroRW
implicit val linkerModeReleaseRW: ReadWriter[BloopConfig.LinkerMode.Release.type] = macroRW
implicit val moduleKindJSCommonJSModuleRW: ReadWriter[BloopConfig.ModuleKindJS.CommonJSModule.type] = macroRW
implicit val moduleKindJSCommonJSModuleRW
: ReadWriter[BloopConfig.ModuleKindJS.CommonJSModule.type] = macroRW
implicit val moduleKindJSNoModuleRW: ReadWriter[BloopConfig.ModuleKindJS.NoModule.type] = macroRW
implicit val moduleKindJSESModuleRW: ReadWriter[BloopConfig.ModuleKindJS.ESModule.type] = macroRW
implicit val javaThenScalaRW: ReadWriter[BloopConfig.JavaThenScala.type] = macroRW
Expand Down
4 changes: 2 additions & 2 deletions contrib/buildinfo/src/BuildInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ trait BuildInfo extends ScalaModule {
case (name, _) => s""""${name}" -> ${name}"""
}.mkString(",")
logger.debug(s"Generating object [${buildInfoPackageName.map(_ + ".").getOrElse(
""
)}${buildInfoObjectName}] with [${members.size}] members to [${outputFile}]")
""
)}${buildInfoObjectName}] with [${members.size}] members to [${outputFile}]")
os.write(
outputFile,
s"""|${buildInfoPackageName.map(packageName => s"package ${packageName}\n").getOrElse("")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CodeartifactPublisher(
}
throw new RuntimeException(
s"Failed to publish ${artifacts.map(_.id).mkString(", ")} to AWS Codeartifact. Errors: \n${errors
.mkString("\n")}"
.mkString("\n")}"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/docker/src/DockerModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ trait DockerModule { outer: JavaModule =>
.call(stdout = os.Inherit, stderr = os.Inherit)

log.info(s"Docker build completed ${if (result.exitCode == 0) "successfully"
else "unsuccessfully"} with ${result.exitCode}")
else "unsuccessfully"} with ${result.exitCode}")
tags()
}

Expand Down
4 changes: 4 additions & 0 deletions contrib/flyway/src/ConsoleLog.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class ConsoleLog(val level: ConsoleLog.Level.Level) extends Log {
System.out.println("WARNING: " + message)
}

override def notice(message: String): Unit = {
System.err.println("NOTICE: " + message)
}

override def error(message: String): Unit = {
System.err.println("ERROR: " + message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import play.api.mvc._
* application's home page.
*/
@Singleton
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
class HomeController @Inject() (cc: ControllerComponents) extends AbstractController(cc) {

/**
* Create an Action to render an HTML page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}

"render the index page from the application" in {
Expand All @@ -30,7 +30,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}

"render the index page from the router" in {
Expand All @@ -39,7 +39,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import play.api.mvc._
* application's home page.
*/
@Singleton
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
class HomeController @Inject() (cc: ControllerComponents) extends AbstractController(cc) {

/**
* Create an Action to render an HTML page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}

"render the index page from the application" in {
Expand All @@ -30,7 +30,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}

"render the index page from the router" in {
Expand All @@ -39,7 +39,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import play.api.mvc._
* application's home page.
*/
@Singleton
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
class HomeController @Inject() (cc: ControllerComponents) extends AbstractController(cc) {

/**
* Create an Action to render an HTML page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}

"render the index page from the application" in {
Expand All @@ -30,7 +30,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}

"render the index page from the router" in {
Expand All @@ -39,7 +39,7 @@ class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting

status(home) mustBe OK
contentType(home) mustBe Some("text/html")
contentAsString(home) must include ("Welcome to Play")
contentAsString(home) must include("Welcome to Play")
}
}
}
4 changes: 1 addition & 3 deletions contrib/proguard/test/resources/proguard/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.nio.file.{Files, Paths}

object Main extends App {

}
object Main extends App {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.scalatest._
class GreetSpec extends WordSpec with Matchers {
"Greet" should {
"work" in {
Greet.greet("Nik", None) shouldBe("Hello, Nik!")
Greet.greet("Nik", None) shouldBe ("Hello, Nik!")
}
}
}
Loading

0 comments on commit 4746c4b

Please sign in to comment.