Skip to content

[1.x] Remove generateVersionFile from ZincBuildUtil #1522

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

Open
wants to merge 1 commit into
base: 1.10.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,6 @@ lazy val compilerInterface = (projectMatrix in internalPath / "compiler-interfac
libraryDependencies ++= Seq(scalaLibrary.value % Test),
libraryDependencies ++= Seq(scalatest % Test),
exportJars := true,
Compile / resourceGenerators += Def.task {
val a = (Compile / compile).value
generateVersionFile(version.value, resourceManaged.value, streams.value, a)
}.taskValue,
Compile / generateContrabands / sourceManaged :=
(internalPath / "compiler-interface" / "src" / "main" / "contraband-java").getAbsoluteFile,
Compile / managedSourceDirectories += (Compile / generateContrabands / sourceManaged).value,
Expand Down
33 changes: 0 additions & 33 deletions project/ZincBuildUtil.scala
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
import sbt._
import Keys._
import xsbti.compile.CompileAnalysis

object ZincBuildUtil {
lazy val apiDefinitions = TaskKey[Seq[File]]("api-definitions")
lazy val genTestResTask = TaskKey[Seq[File]]("gen-test-resources")

def lastCompilationTime(analysis0: CompileAnalysis): Long = {
val analysis = analysis0 match { case a: sbt.internal.inc.Analysis => a }
val lastCompilation = analysis.compilations.allCompilations.lastOption
lastCompilation.map(_.getStartTime) getOrElse 0L
}
def generateVersionFile(
version: String,
dir: File,
s: TaskStreams,
analysis0: CompileAnalysis
): Seq[File] = {
import java.util.{ Date, TimeZone }
val analysis = analysis0 match { case a: sbt.internal.inc.Analysis => a }
val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss")
formatter.setTimeZone(TimeZone.getTimeZone("GMT"))
val timestamp = formatter.format(new Date)
val content = versionLine(version) + "\ntimestamp=" + timestamp
val f = dir / "incrementalcompiler.version.properties"
// TODO: replace lastModified() with sbt.io.IO.getModifiedTimeOrZero(), once the build
// has been upgraded to a version of sbt that includes that call.
if (
!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version)
) {
s.log.info("Writing version information to " + f + " :\n" + content)
IO.write(f, content)
}
f :: Nil
}
def versionLine(version: String): String = "version=" + version
def containsVersion(propFile: File, version: String): Boolean =
IO.read(propFile).contains(versionLine(version))

def sampleProjectSettings(ext: String) =
Seq(
(Compile / scalaSource) := baseDirectory.value / "src",
Expand Down
Loading