Skip to content

Commit

Permalink
Upgraded: Scala and libs
Browse files Browse the repository at this point in the history
* Scala: 2.12.11 => 2.12.12, 2.13.2 => 2.13.3
* Cats: 2.1.0 => 2.1.1
* Cats Effect: 2.0.0 => 2.1.4
* Effectie: 0.4.0 => 1.0.0
  • Loading branch information
kevin-lee committed Jul 17, 2020
1 parent 706c170 commit 3abfbcc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
23 changes: 15 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import SemVer.{Major, Minor}

val ProjectNamePrefix = "maven2sbt"
val ProjectVersion = "0.4.0"
val ProjectScalaVersion = "2.13.2"
val CrossScalaVersions = Seq("2.11.12", "2.12.11", ProjectScalaVersion)
val ProjectScalaVersion = "2.13.3"
val CrossScalaVersions = Seq("2.11.12", "2.12.12", ProjectScalaVersion)

ThisBuild / organization := "io.kevinlee"
ThisBuild / version := ProjectVersion
Expand All @@ -32,11 +32,12 @@ lazy val hedgehogLibs: Seq[ModuleID] = Seq(
, "qa.hedgehog" %% "hedgehog-sbt" % hedgehogVersion % Test
)

lazy val cats: ModuleID = "org.typelevel" %% "cats-core" % "2.1.0"
lazy val cats: ModuleID = "org.typelevel" %% "cats-core" % "2.1.1"
lazy val cats_2_0_0: ModuleID = "org.typelevel" %% "cats-core" % "2.0.0"
lazy val catsEffect: ModuleID = "org.typelevel" %% "cats-effect" % "2.0.0"
lazy val catsEffect: ModuleID = "org.typelevel" %% "cats-effect" % "2.1.4"
lazy val catsEffect_2_0_0: ModuleID = "org.typelevel" %% "cats-effect" % "2.0.0"

val EffectieVersion = "0.4.0"
val EffectieVersion = "1.0.0"
lazy val effectieCatsEffect: ModuleID = "io.kevinlee" %% "effectie-cats-effect" % EffectieVersion
lazy val effectieScalazEffect: ModuleID = "io.kevinlee" %% "effectie-scalaz-effect" % EffectieVersion

Expand All @@ -48,20 +49,26 @@ def subProject(projectName: String, path: File): Project =
, resolvers += hedgehogRepo
, testFrameworks ++= Seq(TestFramework("hedgehog.sbt.Framework"))
, libraryDependencies ++= hedgehogLibs
, scalacOptions := (SemVer.parseUnsafe(scalaVersion.value) match {
case SemVer(Major(2), Minor(13), _, _, _) =>
scalacOptions.value.filter(_ != "-Xlint:nullary-override")// ++ Seq("-Xlint:-multiarg-infix")
case _ =>
scalacOptions.value
})
)

lazy val core = subProject("core", file("core"))
.enablePlugins(BuildInfoPlugin)
.settings(
crossScalaVersions := CrossScalaVersions
, libraryDependencies ++= crossVersionProps(
Seq("org.scala-lang.modules" %% "scala-xml" % "1.2.0", catsEffect, effectieCatsEffect, effectieScalazEffect)
Seq("org.scala-lang.modules" %% "scala-xml" % "1.2.0", effectieCatsEffect, effectieScalazEffect)
, SemVer.parseUnsafe(scalaVersion.value)
) {
case (Major(2), Minor(11)) =>
Seq(cats_2_0_0)
Seq(cats_2_0_0, catsEffect_2_0_0)
case _ =>
Seq(cats)
Seq(cats, catsEffect)
}
/* Build Info { */
, buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion)
Expand Down
12 changes: 6 additions & 6 deletions cli/src/main/scala/maven2sbt/cli/Maven2SbtApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ object Maven2SbtApp extends MainIo[Maven2SbtArgs] {
.bracket { writer =>
(for {
buildSbt <- EitherT(maven2SbtIo.buildSbtFromPomFile(scalaVersion, pom))
buildSbtString <- eitherTLiftF(IO(BuildSbt.render(buildSbt)))
_ <- eitherTLiftF(IO(writer.write(buildSbtString)))
_ <- eitherTLiftF[IO, Maven2SbtError, Unit](
buildSbtString <- eitherTRightF(IO(BuildSbt.render(buildSbt)))
_ <- eitherTRightF(IO(writer.write(buildSbtString)))
_ <- eitherTRightF[Maven2SbtError](
ConsoleEffect[IO].putStrLn(
s"""Success] The sbt config file has been successfully written at
| $buildSbtPath
Expand All @@ -64,10 +64,10 @@ object Maven2SbtApp extends MainIo[Maven2SbtArgs] {

case Maven2SbtArgs.PrintArgs(scalaVersion, pomPath) =>
(for {
pom <- eitherTLiftF(IO(toCanonicalFile(pomPath)))
pom <- eitherTRightF(IO(toCanonicalFile(pomPath)))
buildSbt <- EitherT(maven2SbtIo.buildSbtFromPomFile(scalaVersion, pom))
buildSbtString <- eitherTLiftF(IO(BuildSbt.render(buildSbt)))
_ <- eitherTLiftF[IO, Maven2SbtError, Unit](
buildSbtString <- eitherTRightF(IO(BuildSbt.render(buildSbt)))
_ <- eitherTRightF[Maven2SbtError](
ConsoleEffect[IO].putStrLn(buildSbtString)
)
} yield ()).value
Expand Down
8 changes: 4 additions & 4 deletions cli/src/main/scala/maven2sbt/cli/Maven2SbtArgsParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import maven2sbt.info.Maven2SbtBuildInfo
*/
object Maven2SbtArgsParser {

def fileParser: Parse[Maven2SbtArgs] = Maven2SbtArgs.fileArgs _ |*| (
def fileParser: Parse[Maven2SbtArgs] = Applicative[Parse].apply4(
flag[String](
both('s', "scala-version")
, metavar("<version>") |+| description("Scala version")
Expand All @@ -33,17 +33,17 @@ object Maven2SbtArgsParser {
, argument[String](
metavar("<pom-path>") |+| description("Path to the pom file.")
).map(new File(_))
)
)(Maven2SbtArgs.fileArgs _)

def printParse: Parse[Maven2SbtArgs] = Maven2SbtArgs.printArgs _ |*| (
def printParse: Parse[Maven2SbtArgs] = Applicative[Parse].apply2(
flag[String](
both('s', "scala-version")
, metavar("<version>") |+| description("Scala version")
).map(ScalaVersion)
, argument[String](
metavar("<pom-path>") |+| description("Path to the pom file.")
).map(new File(_))
)
)(Maven2SbtArgs.printArgs _)

val rawCmd: Command[Maven2SbtArgs] =
Command(
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/maven2sbt/core/Maven2Sbt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ object Maven2Sbt {

def buildSbtFromPomFile(scalaVersion: ScalaVersion, file: File): F[Either[Maven2SbtError, BuildSbt]] =
(for {
pomFile <- eitherTEffectOf(Option(file).filter(_.exists()).toRight(Maven2SbtError.pomFileNotExist(file)))
pomElem <- eitherTLiftEffectOf[F, Maven2SbtError, Elem](XML.loadFile(pomFile))
pomFile <- eitherTOf(Option(file).filter(_.exists()).toRight(Maven2SbtError.pomFileNotExist(file)))
pomElem <- eitherTRight(XML.loadFile(pomFile))
buildSbtString <- EitherT(buildSbt(scalaVersion, pomElem))
} yield buildSbtString).value

def buildSbtFromInputStream(scalaVersion: ScalaVersion, pom: InputStream): F[Either[Maven2SbtError, BuildSbt]] =
(for {
inputStream <- eitherTEffectOf(Option(pom).toRight(Maven2SbtError.noPomInputStream))
pomElem <- eitherTLiftEffectOf[F, Maven2SbtError, Elem](XML.load(inputStream))
inputStream <- eitherTOf(Option(pom).toRight(Maven2SbtError.noPomInputStream))
pomElem <- eitherTRight(XML.load(inputStream))
buildSbtString <- EitherT(buildSbt(scalaVersion, pomElem))
} yield buildSbtString).value

Expand Down

0 comments on commit 3abfbcc

Please sign in to comment.