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

Use hashing instead of other algorithms to guarantee scala classes re… #308

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/scala/sbtprotoc/ProtocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ object ProtocPlugin extends AutoPlugin {
val cached = FileFunction.cached(
streams.cacheDirectory / dep.name,
inStyle = FilesInfo.lastModified,
outStyle = FilesInfo.exists
outStyle = FilesInfo.hash
) { deps =>
IO.createDirectory(extractTarget)
deps.flatMap { dep =>
Expand Down Expand Up @@ -539,7 +539,7 @@ object ProtocPlugin extends AutoPlugin {
private[this] val classloaderCache =
new java.util.concurrent.ConcurrentHashMap[
BridgeArtifact,
(FilesInfo[ModifiedFileInfo], URLClassLoader)
(FilesInfo[HashFileInfo], URLClassLoader)
]

private[this] def sourceGeneratorTask(key: TaskKey[Seq[File]]): Def.Initialize[Task[Seq[File]]] =
Expand Down Expand Up @@ -607,7 +607,7 @@ object ProtocPlugin extends AutoPlugin {
// stamped and compared with the previous stamp to reload the classloader upon changes. Artifact resolution is
// memoized across invocations for the entire sbt session, unless cacheArtifactResolution is false.
val stampedClassLoadersByArtifact
: Map[BridgeArtifact, (FilesInfo[ModifiedFileInfo], ClassLoader)] =
: Map[BridgeArtifact, (FilesInfo[HashFileInfo], ClassLoader)] =
targets
.collect { case Target(SandboxedJvmGenerator(_, artifact, _, _), _, _) => artifact }
.distinct
Expand All @@ -617,7 +617,7 @@ object ProtocPlugin extends AutoPlugin {
{ (_, prevValue) =>
def stampClasspath(files: Seq[File]) =
// artifact paths can be JARs or directories, so a recursive stamp is needed
FileInfo.lastModified(files.toSet[File].allPaths.get.toSet)
FileInfo.hash(files.toSet[File].allPaths.get.toSet)

if (prevValue == null) {
// first time this classpath is requested since the start of sbt
Expand Down Expand Up @@ -676,7 +676,7 @@ object ProtocPlugin extends AutoPlugin {
}

import CacheImplicits._
type Stamp = (Arguments, Seq[FilesInfo[ModifiedFileInfo]])
type Stamp = (Arguments, Seq[FilesInfo[HashFileInfo]])
val cachedCompile = Tracked.inputChanged[Stamp, Set[File]](
cacheFile / "input"
) { case (inChanged, _) =>
Expand Down Expand Up @@ -706,7 +706,7 @@ object ProtocPlugin extends AutoPlugin {
val sandboxedArtifactsStamps =
stampedClassLoadersByArtifact.values.map(_._1).toSeq
val inputStamp =
FileInfo.lastModified(schemas ++ arguments.includePaths.allPaths.get)
FileInfo.hash(schemas ++ arguments.includePaths.allPaths.get)
cachedCompile((arguments, sandboxedArtifactsStamps :+ inputStamp)).toSeq
}
}
Expand Down