Skip to content
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

Recompiles even if there is no changes #3501

Closed
joan38 opened this issue Sep 6, 2017 · 13 comments
Assignees
Milestone

Comments

@joan38
Copy link

@joan38 joan38 commented Sep 6, 2017

steps

mkdir -p test/project
cd test
echo "sbt.version=1.0.1" > project/build.properties
echo "addSbtPlugin(\"com.eed3si9n\" % \"sbt-buildinfo\" % \"0.7.0\")" > project/plugins.sbt
echo "enablePlugins(BuildInfoPlugin)" > build.sbt
mkdir -p src/main/scala
echo "object Test {}" > src/main/scala/Test.scala
sbt ~test:compile
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /Users/joangoyeau/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /Users/joangoyeau/Code/test/project
[info] Loading settings from build.sbt ...
[info] Set current project to test (in build file:/Users/joangoyeau/Code/test/)
[info] Compiling 2 Scala sources to /Users/joangoyeau/Code/test/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 5 s, completed 08-Sep-2017 14:26:50
1. Waiting for source changes... (press enter to interrupt)
[info] Compiling 2 Scala sources to /Users/joangoyeau/Code/test/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 1 s, completed 08-Sep-2017 14:26:57
2. Waiting for source changes... (press enter to interrupt)
[info] Compiling 2 Scala sources to /Users/joangoyeau/Code/test/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 1 s, completed 08-Sep-2017 14:27:06
3. Waiting for source changes... (press enter to interrupt)
[info] Compiling 2 Scala sources to /Users/joangoyeau/Code/test/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 1 s, completed 08-Sep-2017 14:27:16
4. Waiting for source changes... (press enter to interrupt)
[success] Total time: 0 s, completed 08-Sep-2017 14:27:16
5. Waiting for source changes... (press enter to interrupt)
[info] Compiling 2 Scala sources to /Users/joangoyeau/Code/test/target/scala-2.12/classes ...
[info] Done compiling.
[success] Total time: 1 s, completed 08-Sep-2017 14:27:26
6. Waiting for source changes... (press enter to interrupt)

problem

It recompiles even if there is no changes.

expectation

Should recompile only if there is changes?

notes

sbt version: 1.0.1

@joan38

This comment has been minimized.

Copy link
Author

@joan38 joan38 commented Sep 7, 2017

Seems to happen with sbt-buildinfo enabled or whenever there is something generating sources

@dwijnand

This comment has been minimized.

Copy link
Member

@dwijnand dwijnand commented Sep 8, 2017

@joan38 Could you provide a minimised reproduction of the problem, please?

@joan38 joan38 changed the title Impossible to interrupt continuous compilation Recompiles even if there is no changes Sep 8, 2017
@joan38

This comment has been minimized.

Copy link
Author

@joan38 joan38 commented Sep 8, 2017

Hi @dwijnand, sorry I didn't give that before.
I updated with the issue with the reproduction steps.

@joan38

This comment has been minimized.

Copy link
Author

@joan38 joan38 commented Sep 11, 2017

Should we label that as Bug and remove the Needs Reproduction Test Case?

@dwijnand

This comment has been minimized.

Copy link
Member

@dwijnand dwijnand commented Sep 21, 2017

#3565 shows a variant using source generators.

@dwijnand dwijnand added this to the 1.0.3 milestone Sep 21, 2017
@tpolecat

This comment has been minimized.

Copy link

@tpolecat tpolecat commented Sep 21, 2017

Yep @dwijnand it looks like the same thing. My little buildinfo equivalent gives you runtime access to the compilation time, which is useless enough that I'm happy to turn it off if there's no easy fix on your end.

@eed3si9n eed3si9n added the Regression label Oct 2, 2017
@dwijnand dwijnand self-assigned this Oct 2, 2017
@dwijnand

This comment has been minimized.

Copy link
Member

@dwijnand dwijnand commented Oct 9, 2017

Minimised:

sourceGenerators in Compile += Def.task {
  val f = (sourceManaged in Compile).value / "f.scala"
  IO.write(f, "")
  Seq(f)
}.taskValue
@dwijnand

This comment has been minimized.

Copy link
Member

@dwijnand dwijnand commented Oct 9, 2017

It's possible that sbt-buildinfo might need to modify its behaviour too. To that end I've also minimised its code to this minimisation:

sourceGenerators in Compile += Def.task {
  val outFile = (sourceManaged in Compile).value / "sbt-buildinfo" / s"BuildInfo.scala"

  val cacheDir = streams.value.cacheDirectory
  val tempFile = cacheDir / "sbt-buildinfo" / s"BuildInfo.scala"

  val cachedCopyFile =
    Tracked.inputChanged(cacheDir / "sbtbuildinfo-inputs") { (inChanged, _: HashFileInfo) =>
      if (inChanged || !outFile.exists) {
        IO.copyFile(tempFile, outFile, preserveLastModified = true)
      }
    }

  // 1. make the file under cache/sbtbuildinfo.
  // 2. compare its SHA1 against cache/sbtbuildinfo-inputs
  IO.write(tempFile, "")
  cachedCopyFile(FileInfo.hash(tempFile))
  Seq(outFile)
}.taskValue
dwijnand added a commit to dwijnand/sbt that referenced this issue Oct 12, 2017
Using a recursive Source meant that ~ looked into target. If you have
any source generators and use ~ with anything the invokes them, like
~compile, that means that the act of generating sources triggers ~ to
re-execute compile (perhaps only on macOS where the NIO WatchService
just polls, after an initial delay).

Requires sbt/io#78

Fixes sbt#3501
dwijnand added a commit to dwijnand/sbt that referenced this issue Oct 13, 2017
Using a recursive Source meant that ~ looked into target. If you have
any source generators and use ~ with anything the invokes them, like
~compile, that means that the act of generating sources triggers ~ to
re-execute compile (perhaps only on macOS where the NIO WatchService
just polls, after an initial delay).

Requires sbt/io#78

Fixes sbt#3501
@eed3si9n eed3si9n removed the in progress label Oct 24, 2017
@dwijnand dwijnand reopened this Oct 24, 2017
@dwijnand

This comment has been minimized.

Copy link
Member

@dwijnand dwijnand commented Oct 24, 2017

Keeping this open to track it needs a new version of io to be fixed in sbt 1.0.3.

dwijnand added a commit to dwijnand/sbt that referenced this issue Oct 24, 2017
Using a recursive Source meant that ~ looked into target. If you have
any source generators and use ~ with anything the invokes them, like
~compile, that means that the act of generating sources triggers ~ to
re-execute compile (perhaps only on macOS where the NIO WatchService
just polls, after an initial delay).

Requires sbt/io#78

Fixes sbt#3501
@dwijnand dwijnand closed this Oct 24, 2017
@dwijnand

This comment has been minimized.

Copy link
Member

@dwijnand dwijnand commented Oct 26, 2017

Closed with #3634.

@joan38

This comment has been minimized.

Copy link
Author

@joan38 joan38 commented Oct 31, 2017

@dwijnand It seems that with SBT 1.0.3 we've been too strong. Now it doesn't pick up changes.

Steps to reproduce:

git clone https://github.com/joan38/kubernetes-client
cd kubernetes-client
sbt ~compile

Should I open a new issue?

@eed3si9n

This comment has been minimized.

Copy link
Member

@eed3si9n eed3si9n commented Oct 31, 2017

Someone reported #3695

@joan38

This comment has been minimized.

Copy link
Author

@joan38 joan38 commented Oct 31, 2017

Great, thanks @eed3si9n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.