pureconfig无法派生具有许多属性的案例类

时间:2018-06-25 19:38:07

标签: scala gradle shapeless case-class pureconfig

我无法派生具有许多属性的案例类。奇怪的是,输出在SBT和Gradle之间变化。在https://github.com/geoHeil/pureconfig-issue找到了一个最小的可复制示例,下面列出了代码:

sbt

sbt compile
[error] Caused by: java.lang.ClassNotFoundException: scala.runtime.LazyRef

渐变

./gradlew compileScala
ould not find implicit value for parameter reader: pureconfig.ConfigReader[Foo.XXX]
  pureconfig.ConfigReader[XXX]

用于以下代码:

object Foo extends App {
  println("here")

  case class MyNestedThing(foo: String)
  case class XXX(
                  a: String,
                  b: String,
                  c: String,
                  d: String,
                  e: String,
                  f: String,
                  g: String,
                  h: String,
                  i: String,
                  j: String,
                  k: String,
                  l: String,
                  m: String,
                  n: String,
                  o: String,
                  p: String,
                  q: String,
                  r: String,
                  s: String,
                  t: String,
                  u: String,
                  v: String,
                  w: String,
                  x: String,
                  y: String,
                  z: String,
                  aa: String,
                  ab: String,
                  ac: String,
                  ad: String,
                  ae: String,
                  af: String,
                  ag: String,
                  ah: String,
                  ai: String,
                  aj: String,
                  ak: String,
                  al: String,
                  am: String,
                  an: String,
                  ao: String,
                  ap: String,
                  aq: String,
                  someLonglllllllllllllllllllllllllll: String,
                  so1meLonglllllllllllllllllllllllllll: String,
                  som2eLonglllllllllllllllllllllllllll: String,
                  ar: MyNestedThing,
                  as: MyNestedThing
                )

  pureconfig.ConfigReader[XXX]
}

虽然在使用时效果很好:

object Foo extends App {
  println("here")

  case class MyNestedThing(foo: String)

  case class XXX(
                  a: String,
                  b: String,
                  som2eLonglllllllllllllllllllllllllll: String,
                  ar: MyNestedThing,
                  as: MyNestedThing
                )

  pureconfig.ConfigReader[XXX]
}

编辑

有趣的是,我在scala版本中有一个混淆,因此在将其修复为所有2.11 SBT时都可以正常编译,但是gradle仍然显示相同的问题。

1 个答案:

答案 0 :(得分:0)

当为scala编译器提供更多内存时,它可以正常工作。 https://github.com/pureconfig/pureconfig/issues/391

tasks.withType(ScalaCompile) {
    configure(scalaCompileOptions.forkOptions) {
        jvmArgs = ["-Xss2m"]
    }
}