Skip to content

Instantly share code, notes, and snippets.

@DamianReeves
Last active August 14, 2020 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DamianReeves/3ae7b00d4968243b6f6e2adc213df260 to your computer and use it in GitHub Desktop.
Save DamianReeves/3ae7b00d4968243b6f6e2adc213df260 to your computer and use it in GitHub Desktop.
Mill Build issue
import $ivy.`com.goyeau::mill-git:e8d8fae`
import $ivy.`com.goyeau::mill-scalafix:0.1.5`
import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import $ivy.`io.github.davidgregory084::mill-tpolecat:0.1.4`
import mill._
import mill.scalalib._
import mill.scalajslib._
import publish._
import mill.scalalib.scalafmt._
import com.goyeau.mill.git.GitVersionedPublishModule
import com.goyeau.mill.git.GitVersionModule
import com.goyeau.mill.scalafix.ScalafixModule
import io.github.davidgregory084.TpolecatModule
object Deps {
object ScalaVersions {
val scala211 = Version.withRevision(2, 11, 12)
val scala212 = Version.withRevision(2, 12, 10)
val scala213 = Version.withRevision(2, 13, 3)
val scalaJS06 = Version.withRevision(0, 6, 32)
val scalaJS1 = Version.withRevision(1, 0, 0)
val selected = scala211
}
object Scala_2_11 {
val acyclic = ivy"com.lihaoyi::acyclic:0.1.9"
val fastparse = ivy"com.lihaoyi::fastparse:2.1.2"
val paradise = ivy"org.scalamacros:::paradise:2.1.1"
val pprint = ivy"com.lihaoyi::pprint:0.5.4"
}
object Scala_2_12 {
val paradise = ivy"org.scalamacros:::paradise:2.1.1"
}
val acyclic = ivy"com.lihaoyi::acyclic:0.2.0"
val fastparse = ivy"com.lihaoyi::fastparse:2.3.0"
val newtype = ivy"io.estatico::newtype:0.4.4"
val pprint = ivy"com.lihaoyi::pprint:0.6.0"
val zio = ivy"dev.zio::zio:1.0.0"
val zioConfig = ivy"dev.zio::zio-config:1.0.0-RC26"
val zioConfigTypesafe = ivy"dev.zio::zio-config-typesafe:1.0.0-RC26"
val zioLogging = ivy"dev.zio::zio-logging:0.4.0"
val zioLoggingSlf4j = ivy"dev.zio::zio-logging-slf4j:0.4.0"
val zioStreams = ivy"dev.zio::zio-streams:1.0.0"
val zioTest = ivy"dev.zio::zio-test:1.0.0"
val zioTestSbt = ivy"dev.zio::zio-test-sbt:1.0.0"
}
trait FlowzPublishModule extends PublishModule {
//def artifactName = "flowz-" + super.artifactName()
def publishVersion = GitVersionModule.version(withSnapshotSuffix = true)
def pomSettings = PomSettings(
description = artifactName(),
organization = "damianreeves.com",
url = "https://github.com/DamianReeves/flowz",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("DamianReeves", "flowz"),
developers = Seq(
Developer("DamianReeves", "Damian Reeves", "https://github.com/DamianReeves")
)
)
def javacOptions = Seq("-source", "1.8", "-target", "1.8")
}
trait ScalaProject
extends FlowzPublishModule
with ScalaModule
with ScalafmtModule
with ScalafixModule
with TpolecatModule {
def crossScalaVersion: Version
def scalaVersion = T { crossScalaVersion.fullVersion }
def compileIvyDeps = crossScalaVersion match {
case Version(2, 11) => Agg(Deps.Scala_2_11.acyclic)
case _ => Agg(Deps.acyclic)
}
def scalacPluginIvyDeps = crossScalaVersion match {
case Version(2, 11) => Agg(Deps.Scala_2_11.acyclic)
case _ => Agg(Deps.acyclic)
}
trait Tests extends super.Tests with ScalaTestProject
}
trait ScalaTestProject
extends ScalaModule
with TestModule
with ScalafmtModule
with ScalafixModule
with TpolecatModule {
def ivyDeps = Agg(
Deps.zioTest,
Deps.zioTestSbt
)
def testFrameworks =
Seq("zio.test.sbt.ZTestFramework")
}
abstract class FlowzScalaCrossProject(val crossScalaVersion: Version) extends ScalaProject {}
object flowz extends Module {
import Deps.ScalaVersions._
object core extends mill.Cross[CoreModule](scala211, scala212, scala213)
class CoreModule(crossScalaVersion: Version) extends FlowzScalaCrossProject(crossScalaVersion) {
def ivyDeps = {
val common = Agg(Deps.zio, Deps.zioLogging)
crossScalaVersion match {
case Version(2, 11) =>
common ++ Agg(Deps.Scala_2_11.fastparse)
case _ =>
common ++ Agg(Deps.fastparse)
}
}
override def scalacPluginIvyDeps = T {
val original = super.scalacPluginIvyDeps()
val additional = crossScalaVersion match {
case Version(2, 11) =>
Agg(Deps.Scala_2_11.paradise)
case Version(2, 12) =>
Agg(Deps.Scala_2_12.paradise)
}
original ++ additional
}
object test extends Tests
}
// object spark extends ScalaProject {
// def moduleDeps = Seq(core)
// def ivyDeps = Agg(
// Deps.spark.sql()
// )
// object test extends Tests
// }
// object samples extends Module {
// object basic extends ScalaProject {
// def ivyDeps = Agg(
// Deps.zio()
// )
// def moduleDeps = Seq(flowz.core)
// }
// }
}
sealed abstract class Version extends Product with Serializable {
def major: Int
def minor: Int
def fullVersion: String
override def toString(): String = fullVersion
}
object Version {
def majorMinor(major: Int, minor: Int): Version =
MajorMinor(major, minor)
def withRevision(major: Int, minor: Int, revision: Int): Version =
MajorMinorRevision(major, minor, revision)
def unapply(version: Version): Option[(Int, Int)] = version match {
case MajorMinor(major, minor) => Some((major, minor))
case MajorMinorRevision(major, minor, _) => Some((major, minor))
case MajorMinorRevisionTag(major, minor, _, _) => Some((major, minor))
}
object MajorMinorVersion {
def unapply(version: Version): Option[(Int, Int)] = version match {
case MajorMinor(major, minor) => Some((major, minor))
case MajorMinorRevision(major, minor, _) => Some((major, minor))
case MajorMinorRevisionTag(major, minor, _, _) => Some((major, minor))
}
}
final case class MajorMinor(major: Int, minor: Int) extends Version {
def fullVersion: String = s"$major.$minor"
}
final case class MajorMinorRevision(major: Int, minor: Int, revision: Int) extends Version {
def fullVersion: String = s"$major.$minor.$revision"
}
final case class MajorMinorRevisionTag(major: Int, minor: Int, revision: Int, tag: String)
extends Version {
def fullVersion: String = s"$major.$minor.$revision-$tag"
}
}

Exception in thread "MillServerActionRunner" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at mill.define.Module$Internal.$anonfun$reflect$4(Module.scala:73) at scala.collection.ArrayOps$WithFilter.map(ArrayOps.scala:90) at mill.define.Module$Internal.reflect(Module.scala:64) at mill.define.Module$Internal.reflectAll(Module.scala:76) at mill.define.Module$Internal.reflectNestedObjects(Module.scala:84) at mill.define.Module.millModuleDirectChildren$lzycompute(Module.scala:27) at mill.define.Module.millModuleDirectChildren(Module.scala:27) at mill.define.Module$Internal.rec$1(Module.scala:42) at mill.define.Module$Internal.$anonfun$traverse$1(Module.scala:42) at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:117) at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:104) at scala.collection.immutable.ArraySeq.flatMap(ArraySeq.scala:35) at mill.define.Module$Internal.rec$1(Module.scala:42) at mill.define.Module$Internal.traverse(Module.scala:43) at mill.define.Module$Internal.modules$lzycompute(Module.scala:46) at mill.define.Module$Internal.modules(Module.scala:46) at mill.main.Resolve.resolve(Resolve.scala:378) at mill.main.RunScript$.$anonfun$resolveTasks$4(RunScript.scala:145) at scala.util.Either.map(Either.scala:382) at mill.main.RunScript$.$anonfun$resolveTasks$3(RunScript.scala:134) at scala.collection.immutable.List.map(List.scala:246) at mill.main.RunScript$.$anonfun$resolveTasks$2(RunScript.scala:133) at scala.util.Either.flatMap(Either.scala:352) at mill.main.RunScript$.resolveTasks(RunScript.scala:130) at mill.main.RunScript$.evaluateTasks(RunScript.scala:187) at mill.main.RunScript$.$anonfun$runScript$4(RunScript.scala:66) at ammonite.util.Res$Success.flatMap(Res.scala:62) at mill.main.RunScript$.runScript(RunScript.scala:65) at mill.main.MainRunner.$anonfun$runScript$1(MainRunner.scala:115) at mill.main.MainRunner.watchLoop2(MainRunner.scala:64) at mill.main.MainRunner.runScript(MainRunner.scala:90) at mill.MillMain$.main0(MillMain.scala:269) at mill.main.MillServerMain$.main0(MillServerMain.scala:67) at mill.main.Server.$anonfun$handleRun$1(MillServerMain.scala:154) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class ammonite.$file.build$Version (java.lang.Integer is in module java.base of loader 'bootstrap'; ammonite.$file.build$Version is in unnamed module of loader ammonite.runtime.SpecialClassLoader @42bf2083) at ammonite.$file.build$flowz$core$$anonfun$$lessinit$greater$1$$anon$1.(build.sc:122) at ammonite.$file.build$flowz$core$$anonfun$$lessinit$greater$1.apply(build.sc:122) at ammonite.$file.build$flowz$core$$anonfun$$lessinit$greater$1.apply(build.sc:122) at mill.define.Cross.$anonfun$items$1(Cross.scala:62) at scala.collection.immutable.List.map(List.scala:246) at mill.define.Cross.(Cross.scala:53) at ammonite.$file.build$flowz$core$.(build.sc:122) at ammonite.$file.build$flowz$.core$lzycompute$1(build.sc:122) at ammonite.$file.build$flowz$.core(build.sc:122) ... 39 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment