sbt / zinc

Scala incremental compiler library, used by sbt and other build tools
Apache License 2.0
334 stars 120 forks source link

A package object with a monadSynax import is alway recompiled even when no file is changed #659

Open Atry opened 5 years ago

Atry commented 5 years ago

I created a minimized project at https://github.com/Atry/zinc-package-object-recompile.

When cloning the repository and running sbt compile twice,

git clone git@github.com:Atry/zinc-package-object-recompile.git; cd zinc-package-object-recompile; sbt compile; sbt compile

the source file is recompiled in the second run.

正克隆到 'zinc-package-object-recompile'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
接收对象中: 100% (6/6), 完成.
[info] Loading global plugins from /Users/twer/.sbt/1.0/plugins/project
[info] Loading settings for project global-plugins from idea.sbt,mavenResolvers.sbt,metals.sbt ...
[info] Loading global plugins from /Users/twer/.sbt/1.0/plugins
[info] Loading project definition from /private/tmp/zinc-package-object-recompile/project
[info] Updating ProjectRef(uri("file:/private/tmp/zinc-package-object-recompile/project/"), "zinc-package-object-recompile-build")...
[info] Done updating.
[info] Loading settings for project zinc-package-object-recompile from build.sbt ...
[info] Set current project to zinc-package-object-recompile (in build file:/private/tmp/zinc-package-object-recompile/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] Updating ...
[info] Done updating.
[info] Compiling 1 Scala source to /private/tmp/zinc-package-object-recompile/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 1 s, completed 2019-4-23 13:58:21
[info] Loading global plugins from /Users/twer/.sbt/1.0/plugins/project
[info] Loading settings for project global-plugins from idea.sbt,mavenResolvers.sbt,metals.sbt ...
[info] Loading global plugins from /Users/twer/.sbt/1.0/plugins
[info] Loading project definition from /private/tmp/zinc-package-object-recompile/project
[info] Loading settings for project zinc-package-object-recompile from build.sbt ...
[info] Set current project to zinc-package-object-recompile (in build file:/private/tmp/zinc-package-object-recompile/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] Compiling 1 Scala source to /private/tmp/zinc-package-object-recompile/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 2 s, completed 2019-4-23 13:58:31

I expect the source file would not be recompiled because I did not change the file content nor it's dependencies.

Atry commented 5 years ago

Note that monadSyntax is a field defined in scalaz.Monad.

https://static.javadoc.io/com.thoughtworks.binding/binding_2.12/11.7.0/com/thoughtworks/binding/Binding$$BindingInstances$.html#monadSyntax:scalaz.syntax.MonadSyntax[F]

eed3si9n commented 5 years ago

@Atry Thanks for the report!