Skip to content

Changes to Contraband json files don't trigger invalidation of source that uses the generated *.java code #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smarter opened this issue Apr 5, 2017 · 12 comments
Assignees
Labels

Comments

@smarter
Copy link
Contributor

smarter commented Apr 5, 2017

I have no idea if this is a bug in sbt, zinc, contraband, or a combination of all the above:

steps

  1. Edit type.json, add a random field to any class, (for example add: { "name": "quack", "type": "String" }, to Projection
  2. Run compile, notice that java files are generated from the json file as expected and they are recompiled

problem

but notice also that you don't get any compilation error, even though you just changed the constructor of Projection which is used in internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala for example.

expectation

internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala etc should no longer compile.

notes

  1. Do ;clean;compile, notice that everything still compiles, very weird!
  2. Stop sbt. Start sbt again, do ;clean;compile, finally you get error messages!

Any clue what's going on? /cc @eed3si9n

@smarter smarter changed the title Change to json definition files does not cause other projects to be recompiled, requires restarting sbt Changes to json definition files does not cause other projects to be recompiled, requires restarting sbt Apr 5, 2017
@jvican
Copy link
Member

jvican commented Apr 5, 2017

Is this issue reproducible in Zinc 1.0 or 0.13? If it's in 0.13.x it may make more sense to file a ticket there 😄.

Regarding the issue, this looks indeed weird. The third point is baffling... Is this how the universe is set up to work?

@smarter
Copy link
Contributor Author

smarter commented Apr 5, 2017

Well this issue happens when trying to work on zinc itself, so I think the zinc bugtracker is appropriate until we figure out what causes the issue (it might be a pecularity of the zinc build.sbt for example).

@jvican jvican closed this as completed Apr 5, 2017
@jvican jvican reopened this Apr 5, 2017
@jvican
Copy link
Member

jvican commented Apr 5, 2017

Closed by accident. Let's see what's making this happen.

@jvican jvican changed the title Changes to json definition files does not cause other projects to be recompiled, requires restarting sbt Changes to Contraband json files don't trigger recompilation Apr 5, 2017
@jvican jvican added the bug label Apr 5, 2017
@jvican
Copy link
Member

jvican commented Apr 5, 2017

Note to myself: this is a bug of our current setup and only affects people hacking on Zinc. It is not a bug of Zinc 1.0 per se.

@smarter
Copy link
Contributor Author

smarter commented Apr 6, 2017

While working on #287 I've run into the same issue when changing AnalysisCallback.java so this doesn't seem to be specifc to contraband-generated java files, but happen with any kind of java files. As before, stopping and restarting sbt is the only way to get things to work.

@jvican
Copy link
Member

jvican commented May 16, 2017

@smarter I've run into this lately when making lots of changes to contraband.

@eed3si9n Please, can you have a look at this? I'm losing way too much time cleaning, removing all dirs and exiting sbt to make changes in the API. If you help me here, I'll be able to make progress much much faster 😄.

@dwijnand
Copy link
Member

Related to sbt/contraband#75.

@eed3si9n
Copy link
Member

I always thought "hey this works for me" until I read it more carefully.
Guillaume is actually talking about transitive invalidation caused by the change in signature of generated Java code. There's some change that Contraband plugin is not coded correctly somehow, but it feels more like a bug in sbt 0.13's incremental compiler.

@eed3si9n eed3si9n changed the title Changes to Contraband json files don't trigger recompilation Changes to Contraband json files don't trigger invalidation of source that uses the generated *.java code May 19, 2017
@eed3si9n
Copy link
Member

I'm now more certain it's sbt issue because it won't happen if I comment out:

    exportJars := true,

so exportJars is making other subprojects treat compilerInterface as if it's a "library" dependency, which in a way is true, but even if that's the case it should invalidate.
I'm curious if Zinc inherits this bug from sbt/sbt, and if I should now move and/or open issue under sbt/sbt as well.

@smarter
Copy link
Contributor Author

smarter commented May 19, 2017

@eed3si9n Does this only happen when compiling with Scala 2.12? If so I bet this is scala/bug#10295

@eed3si9n
Copy link
Member

Interesting. You might be right. Using Scala 2.11.8 it did detect the Java signature change in the JAR:

> compile
...
[info] Compiling 10 Scala sources to /xxx/zinc/internal/zinc-apiinfo/target/scala-2.11/classes...
[error] /xxx/zinc/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala:192: not enough arguments for constructor Projection: (x$1: xsbti.api.Type, x$2: String, x$3: String)xsbti.api.Projection.
[error] Unspecified value parameter x$3.
[error]     else new xsbti.api.Projection(processType(in, pre), simpleName(sym))
[error]          ^
[error] one error found

@smarter
Copy link
Contributor Author

smarter commented May 19, 2017

If -YdisableFlatCpCaching fixes it for 2.12, could you comment on scala/bug#10295 ? I think it's a pretty serious issue but it hasn't gotten any attention yet.

eed3si9n added a commit to eed3si9n/zinc that referenced this issue May 19, 2017
Fixes sbt#282
Ref scala/bug#10295

exportJars := true exposes JAR file as subproject dependency.
Scala 2.12.2 fails to invalidate the source it's used. `-YdisableFlatCpCaching` apparently works aruond this.
@eed3si9n eed3si9n self-assigned this May 19, 2017
cunei pushed a commit to cunei/zinc that referenced this issue Oct 25, 2017
Improve retryUntil's behavior during failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants