Skip to content

Commit

Permalink
Scala 3 support (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
reibitto authored May 23, 2021
1 parent 77b4e86 commit 4c3ddeb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
30 changes: 22 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ scala_212: &scala_212
scala_213: &scala_213
SCALA_VERSION: 2.13.3

scala_dotty: &scala_dotty
SCALA_VERSION: 0.20.0-RC1
scala_3: &scala_3
SCALA_VERSION: 3.0.0

jdk_8: &jdk_8
JDK_VERSION: 8
Expand Down Expand Up @@ -200,11 +200,11 @@ jobs:
- <<: *scala_212
- <<: *jdk_8

compile_dotty:
compile_3:
<<: *compile
<<: *machine_ubuntu
environment:
- <<: *scala_dotty
- <<: *scala_3
- <<: *jdk_8

mdoc:
Expand Down Expand Up @@ -235,11 +235,11 @@ jobs:
- <<: *scala_213
- <<: *jdk_8

test_dotty_jdk8_jvm:
test_3_jdk8_jvm:
<<: *test
<<: *machine_ubuntu
environment:
- <<: *scala_dotty
- <<: *scala_3
- <<: *jdk_8

test_211_jdk11_jvm:
Expand All @@ -263,11 +263,11 @@ jobs:
- <<: *scala_213
- <<: *jdk_11

test_dotty_jdk11_jvm:
test_3_jdk11_jvm:
<<: *test
<<: *machine_ubuntu
environment:
- <<: *scala_dotty
- <<: *scala_3
- <<: *jdk_11

release:
Expand Down Expand Up @@ -316,6 +316,12 @@ workflows:
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test_3_jdk8_jvm:
requires:
- lint
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test_211_jdk11_jvm:
requires:
- lint
Expand All @@ -334,6 +340,12 @@ workflows:
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- test_3_jdk11_jvm:
requires:
- lint
filters:
tags:
only: /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
- release:
context: Sonatype2
requires:
Expand All @@ -343,6 +355,8 @@ workflows:
- test_212_jdk11_jvm
- test_213_jdk8_jvm
- test_213_jdk11_jvm
- test_3_jdk8_jvm
- test_3_jdk11_jvm
- mdoc
filters:
branches:
Expand Down
30 changes: 18 additions & 12 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import sbt._
import sbt.Keys._
import sbt._
import sbtbuildinfo.BuildInfoKeys._
import sbtbuildinfo._
import BuildInfoKeys._

object BuildHelper {
private val Scala211 = "2.11.12"
private val Scala212 = "2.12.13"
private val Scala213 = "2.13.6"
private val Scala3 = "3.0.0"

private val stdOptions = Seq(
"-encoding",
"UTF-8",
"-explaintypes",
"-Yrangepos",
"-feature",
"-language:higherKinds",
"-language:existentials",
"-Xlint:_,-type-parameter-shadow",
"-Xsource:2.13",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-unchecked",
"-deprecation",
"-Xfatal-warnings"
Expand All @@ -45,10 +40,19 @@ object BuildHelper {
"-Ywarn-unused-import"
)

private val stdOptsUpto211 = Seq(
"-explaintypes",
"-Yrangepos",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xlint:_,-type-parameter-shadow",
"-Xsource:2.13"
)

private def extraOptions(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 13)) =>
stdOpts213
stdOpts213 ++ stdOptsUpto211
case Some((2, 12)) =>
Seq(
"-opt-warnings",
Expand All @@ -57,9 +61,11 @@ object BuildHelper {
"-Ywarn-unused:imports",
"-opt:l:inline",
"-opt-inline-from:<source>"
) ++ stdOptsUpto212
) ++ stdOptsUpto212 ++ stdOptsUpto211
case Some((3, 0)) =>
Seq("-noindent")
case _ =>
Seq("-Xexperimental") ++ stdOptsUpto212
Seq("-Xexperimental") ++ stdOptsUpto212 ++ stdOptsUpto211
}

def buildInfoSettings(packageName: String) =
Expand All @@ -71,7 +77,7 @@ object BuildHelper {

def stdSettings(prjName: String) = Seq(
name := s"$prjName",
crossScalaVersions := Seq(Scala211, Scala212, Scala213),
crossScalaVersions := Seq(Scala211, Scala212, Scala213, Scala3),
ThisBuild / scalaVersion := Scala213,
scalacOptions := stdOptions ++ extraOptions(scalaVersion.value),
incOptions ~= (_.withLogRecompileOnMacro(false))
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/zio/process/ProcessInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object ProcessInput {
* Returns a ProcessInput from an array of bytes.
*/
def fromByteArray(bytes: Array[Byte]): ProcessInput =
ProcessInput(Some(Stream.fromInputStream(new ByteArrayInputStream(bytes)).mapError(CommandError.IOError)))
ProcessInput(Some(Stream.fromInputStream(new ByteArrayInputStream(bytes)).mapError(CommandError.IOError.apply)))

/**
* Returns a ProcessInput from a stream of bytes.
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/zio/process/ProcessStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final case class ProcessStream(private val inputStream: InputStream) {
* Return the output of this process as a chunked stream of bytes.
*/
def stream: ZStream[Blocking, CommandError, Byte] =
ZStream.fromInputStream(inputStream).mapError(CommandError.IOError)
ZStream.fromInputStream(inputStream).mapError(CommandError.IOError.apply)

/**
* Return the entire output of this process as a string (default encoding of UTF-8).
Expand Down

0 comments on commit 4c3ddeb

Please sign in to comment.