sbt / contraband

http://www.scala-sbt.org/contraband/
Other
69 stars 22 forks source link

Cache generated output per Scala version #138

Closed jeffmay closed 5 years ago

jeffmay commented 5 years ago

Attempting to fix #137

I tried to do something similar in a local project and it seemed promising. I used:

lazy val myProject = (project in file("myProject")).enablePlugins(ContrabandPlugin).settings(
  inConfig(Compile)(Seq(
    scalacOptions := Seq(),  // this avoids turning warnings to compiler errors
    // This avoids the "not found: type Builder" errors in the compiled output
    libraryDependencies ++= (generateContrabands / contrabandCodecsDependencies).value,
    generateContrabands := {
      val result = generateContrabands.value
      val s = streams.value
      (s.cacheDirectory / "gen-api").delete()
      result
    }
  ))
)

This produces two distinct src_managed directories with separate class files.

NOTE: I was having trouble getting the code to compile, but that was because my failed results were cached without the contrabandCodecsDependencies present. When I cleaned the target directory and re-ran compile it worked as expected.

Anyway, I tried to push something I think will fix it, but I am seeing the following error locally on master when I run the tests:

[error] Modules were resolved with conflicting cross-version suffixes in {file:/Users/jeffmay/code/personal/contraband/}plugin:
[error]    org.spire-math:jawn-parser _2.12, _2.10
[error]    org.json4s:json4s-ast _2.12, _2.10
[error]    org.json4s:json4s-core _2.12, _2.10
[trace] Stack trace suppressed: run last plugin/*:update for the full output.
[error] (plugin/*:update) Conflicting cross-version suffixes in: org.spire-math:jawn-parser, org.json4s:json4s-ast, org.json4s:json4s-core
[error] Total time: 1 s, completed Jul 12, 2019 5:36:49 PM

Does this look right to you? Any good way to test this locally?

lightbend-cla-validator commented 5 years ago

Hi @jeffmay,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

jeffmay commented 5 years ago

Weird error from CI. Any idea what this means @eed3si9n ?

[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.7: configuration not found in org.scala-lang#scala-library;2.10.7: 'master(compile)'. Missing configuration: 'compile'. It was required from org.json4s#json4s-native_2.10;3.2.10 compile
eed3si9n commented 5 years ago

Let me restart Travis job.

eed3si9n commented 5 years ago

@jeffmay Merged. Thanks for the contribution.