Search code examples
scalagradleshapelesscase-classpureconfig

pureconfig can't derive case class with many attributes


I can't derive a case class with many attributes. Strangely the output varies between SBT and gradle. A minimal reproducible example is found at https://github.com/geoHeil/pureconfig-issue, also the code is listed below:

sbt

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

gradle

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

for code of:

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]
}

Though works just fine when using:

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]
}

edit

interestingly, I had a mixup in scala versions so when fixing it to be all of 2.11 SBT compiles fine, however gradle still shows the same problem.


Solution

  • When giving more memory to the scala compiler it works fine. https://github.com/pureconfig/pureconfig/issues/391

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