diff --git a/main/src/main/contraband-scala/sbt/internal/remotecache/CompileRemoteCacheArtifact.scala b/main/src/main/contraband-scala/sbt/internal/remotecache/CompileRemoteCacheArtifact.scala new file mode 100644 index 000000000..1cb1bd77f --- /dev/null +++ b/main/src/main/contraband-scala/sbt/internal/remotecache/CompileRemoteCacheArtifact.scala @@ -0,0 +1,44 @@ +/** + * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. + */ + +// DO NOT EDIT MANUALLY +package sbt.internal.remotecache +final class CompileRemoteCacheArtifact private ( + artifact: sbt.librarymanagement.Artifact, + packaged: sbt.TaskKey[java.io.File], + val extractDirectory: java.io.File, + val analysisFile: java.io.File) extends sbt.internal.remotecache.RemoteCacheArtifact(artifact, packaged) with Serializable { + + + + override def equals(o: Any): Boolean = o match { + case x: CompileRemoteCacheArtifact => (this.artifact == x.artifact) && (this.packaged == x.packaged) && (this.extractDirectory == x.extractDirectory) && (this.analysisFile == x.analysisFile) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (37 * (37 * (17 + "sbt.internal.remotecache.CompileRemoteCacheArtifact".##) + artifact.##) + packaged.##) + extractDirectory.##) + analysisFile.##) + } + override def toString: String = { + "CompileRemoteCacheArtifact(" + artifact + ", " + packaged + ", " + extractDirectory + ", " + analysisFile + ")" + } + private[this] def copy(artifact: sbt.librarymanagement.Artifact = artifact, packaged: sbt.TaskKey[java.io.File] = packaged, extractDirectory: java.io.File = extractDirectory, analysisFile: java.io.File = analysisFile): CompileRemoteCacheArtifact = { + new CompileRemoteCacheArtifact(artifact, packaged, extractDirectory, analysisFile) + } + def withArtifact(artifact: sbt.librarymanagement.Artifact): CompileRemoteCacheArtifact = { + copy(artifact = artifact) + } + def withPackaged(packaged: sbt.TaskKey[java.io.File]): CompileRemoteCacheArtifact = { + copy(packaged = packaged) + } + def withExtractDirectory(extractDirectory: java.io.File): CompileRemoteCacheArtifact = { + copy(extractDirectory = extractDirectory) + } + def withAnalysisFile(analysisFile: java.io.File): CompileRemoteCacheArtifact = { + copy(analysisFile = analysisFile) + } +} +object CompileRemoteCacheArtifact { + + def apply(artifact: sbt.librarymanagement.Artifact, packaged: sbt.TaskKey[java.io.File], extractDirectory: java.io.File, analysisFile: java.io.File): CompileRemoteCacheArtifact = new CompileRemoteCacheArtifact(artifact, packaged, extractDirectory, analysisFile) +} diff --git a/main/src/main/contraband-scala/sbt/internal/remotecache/CustomRemoteCacheArtifact.scala b/main/src/main/contraband-scala/sbt/internal/remotecache/CustomRemoteCacheArtifact.scala new file mode 100644 index 000000000..0c9e83b51 --- /dev/null +++ b/main/src/main/contraband-scala/sbt/internal/remotecache/CustomRemoteCacheArtifact.scala @@ -0,0 +1,44 @@ +/** + * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. + */ + +// DO NOT EDIT MANUALLY +package sbt.internal.remotecache +final class CustomRemoteCacheArtifact private ( + artifact: sbt.librarymanagement.Artifact, + packaged: sbt.TaskKey[java.io.File], + val extractDirectory: java.io.File, + val preserveLastModified: Boolean) extends sbt.internal.remotecache.RemoteCacheArtifact(artifact, packaged) with Serializable { + + + + override def equals(o: Any): Boolean = o match { + case x: CustomRemoteCacheArtifact => (this.artifact == x.artifact) && (this.packaged == x.packaged) && (this.extractDirectory == x.extractDirectory) && (this.preserveLastModified == x.preserveLastModified) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (37 * (37 * (17 + "sbt.internal.remotecache.CustomRemoteCacheArtifact".##) + artifact.##) + packaged.##) + extractDirectory.##) + preserveLastModified.##) + } + override def toString: String = { + "CustomRemoteCacheArtifact(" + artifact + ", " + packaged + ", " + extractDirectory + ", " + preserveLastModified + ")" + } + private[this] def copy(artifact: sbt.librarymanagement.Artifact = artifact, packaged: sbt.TaskKey[java.io.File] = packaged, extractDirectory: java.io.File = extractDirectory, preserveLastModified: Boolean = preserveLastModified): CustomRemoteCacheArtifact = { + new CustomRemoteCacheArtifact(artifact, packaged, extractDirectory, preserveLastModified) + } + def withArtifact(artifact: sbt.librarymanagement.Artifact): CustomRemoteCacheArtifact = { + copy(artifact = artifact) + } + def withPackaged(packaged: sbt.TaskKey[java.io.File]): CustomRemoteCacheArtifact = { + copy(packaged = packaged) + } + def withExtractDirectory(extractDirectory: java.io.File): CustomRemoteCacheArtifact = { + copy(extractDirectory = extractDirectory) + } + def withPreserveLastModified(preserveLastModified: Boolean): CustomRemoteCacheArtifact = { + copy(preserveLastModified = preserveLastModified) + } +} +object CustomRemoteCacheArtifact { + + def apply(artifact: sbt.librarymanagement.Artifact, packaged: sbt.TaskKey[java.io.File], extractDirectory: java.io.File, preserveLastModified: Boolean): CustomRemoteCacheArtifact = new CustomRemoteCacheArtifact(artifact, packaged, extractDirectory, preserveLastModified) +} diff --git a/main/src/main/contraband-scala/sbt/internal/remotecache/PomRemoteCacheArtifact.scala b/main/src/main/contraband-scala/sbt/internal/remotecache/PomRemoteCacheArtifact.scala new file mode 100644 index 000000000..2e956f0ef --- /dev/null +++ b/main/src/main/contraband-scala/sbt/internal/remotecache/PomRemoteCacheArtifact.scala @@ -0,0 +1,36 @@ +/** + * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. + */ + +// DO NOT EDIT MANUALLY +package sbt.internal.remotecache +final class PomRemoteCacheArtifact private ( + artifact: sbt.librarymanagement.Artifact, + packaged: sbt.TaskKey[java.io.File]) extends sbt.internal.remotecache.RemoteCacheArtifact(artifact, packaged) with Serializable { + + + + override def equals(o: Any): Boolean = o match { + case x: PomRemoteCacheArtifact => (this.artifact == x.artifact) && (this.packaged == x.packaged) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (17 + "sbt.internal.remotecache.PomRemoteCacheArtifact".##) + artifact.##) + packaged.##) + } + override def toString: String = { + "PomRemoteCacheArtifact(" + artifact + ", " + packaged + ")" + } + private[this] def copy(artifact: sbt.librarymanagement.Artifact = artifact, packaged: sbt.TaskKey[java.io.File] = packaged): PomRemoteCacheArtifact = { + new PomRemoteCacheArtifact(artifact, packaged) + } + def withArtifact(artifact: sbt.librarymanagement.Artifact): PomRemoteCacheArtifact = { + copy(artifact = artifact) + } + def withPackaged(packaged: sbt.TaskKey[java.io.File]): PomRemoteCacheArtifact = { + copy(packaged = packaged) + } +} +object PomRemoteCacheArtifact { + + def apply(artifact: sbt.librarymanagement.Artifact, packaged: sbt.TaskKey[java.io.File]): PomRemoteCacheArtifact = new PomRemoteCacheArtifact(artifact, packaged) +} diff --git a/main/src/main/contraband-scala/sbt/internal/remotecache/RemoteCacheArtifact.scala b/main/src/main/contraband-scala/sbt/internal/remotecache/RemoteCacheArtifact.scala new file mode 100644 index 000000000..0014ba6ac --- /dev/null +++ b/main/src/main/contraband-scala/sbt/internal/remotecache/RemoteCacheArtifact.scala @@ -0,0 +1,27 @@ +/** + * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. + */ + +// DO NOT EDIT MANUALLY +package sbt.internal.remotecache +abstract class RemoteCacheArtifact( + val artifact: sbt.librarymanagement.Artifact, + val packaged: sbt.TaskKey[java.io.File]) extends Serializable { + + + + + override def equals(o: Any): Boolean = o match { + case x: RemoteCacheArtifact => (this.artifact == x.artifact) && (this.packaged == x.packaged) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (17 + "sbt.internal.remotecache.RemoteCacheArtifact".##) + artifact.##) + packaged.##) + } + override def toString: String = { + "RemoteCacheArtifact(" + artifact + ", " + packaged + ")" + } +} +object RemoteCacheArtifact { + +} diff --git a/main/src/main/contraband-scala/sbt/internal/remotecache/TestRemoteCacheArtifact.scala b/main/src/main/contraband-scala/sbt/internal/remotecache/TestRemoteCacheArtifact.scala new file mode 100644 index 000000000..d6336ec97 --- /dev/null +++ b/main/src/main/contraband-scala/sbt/internal/remotecache/TestRemoteCacheArtifact.scala @@ -0,0 +1,48 @@ +/** + * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. + */ + +// DO NOT EDIT MANUALLY +package sbt.internal.remotecache +final class TestRemoteCacheArtifact private ( + artifact: sbt.librarymanagement.Artifact, + packaged: sbt.TaskKey[java.io.File], + val extractDirectory: java.io.File, + val analysisFile: java.io.File, + val testResult: java.io.File) extends sbt.internal.remotecache.RemoteCacheArtifact(artifact, packaged) with Serializable { + + + + override def equals(o: Any): Boolean = o match { + case x: TestRemoteCacheArtifact => (this.artifact == x.artifact) && (this.packaged == x.packaged) && (this.extractDirectory == x.extractDirectory) && (this.analysisFile == x.analysisFile) && (this.testResult == x.testResult) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.internal.remotecache.TestRemoteCacheArtifact".##) + artifact.##) + packaged.##) + extractDirectory.##) + analysisFile.##) + testResult.##) + } + override def toString: String = { + "TestRemoteCacheArtifact(" + artifact + ", " + packaged + ", " + extractDirectory + ", " + analysisFile + ", " + testResult + ")" + } + private[this] def copy(artifact: sbt.librarymanagement.Artifact = artifact, packaged: sbt.TaskKey[java.io.File] = packaged, extractDirectory: java.io.File = extractDirectory, analysisFile: java.io.File = analysisFile, testResult: java.io.File = testResult): TestRemoteCacheArtifact = { + new TestRemoteCacheArtifact(artifact, packaged, extractDirectory, analysisFile, testResult) + } + def withArtifact(artifact: sbt.librarymanagement.Artifact): TestRemoteCacheArtifact = { + copy(artifact = artifact) + } + def withPackaged(packaged: sbt.TaskKey[java.io.File]): TestRemoteCacheArtifact = { + copy(packaged = packaged) + } + def withExtractDirectory(extractDirectory: java.io.File): TestRemoteCacheArtifact = { + copy(extractDirectory = extractDirectory) + } + def withAnalysisFile(analysisFile: java.io.File): TestRemoteCacheArtifact = { + copy(analysisFile = analysisFile) + } + def withTestResult(testResult: java.io.File): TestRemoteCacheArtifact = { + copy(testResult = testResult) + } +} +object TestRemoteCacheArtifact { + + def apply(artifact: sbt.librarymanagement.Artifact, packaged: sbt.TaskKey[java.io.File], extractDirectory: java.io.File, analysisFile: java.io.File, testResult: java.io.File): TestRemoteCacheArtifact = new TestRemoteCacheArtifact(artifact, packaged, extractDirectory, analysisFile, testResult) +} diff --git a/main/src/main/contraband/remotecache.json b/main/src/main/contraband/remotecache.json new file mode 100644 index 000000000..486d25f9b --- /dev/null +++ b/main/src/main/contraband/remotecache.json @@ -0,0 +1,83 @@ +{ + "codecNamespace": "sbt.internal.remotecache", + "fullCodec": "RemoteCacheArtifactCodec", + "types": [ + { + "name": "RemoteCacheArtifact", + "namespace": "sbt.internal.remotecache", + "target": "Scala", + "type": "interface", + "fields": [ + { + "name": "artifact", + "type": "sbt.librarymanagement.Artifact" + }, + { + "name": "packaged", + "type": "sbt.TaskKey[java.io.File]" + } + ], + "types": [ + { + "name": "PomRemoteCacheArtifact", + "namespace": "sbt.internal.remotecache", + "target": "Scala", + "type": "record", + "fields": [] + }, + { + "name": "CompileRemoteCacheArtifact", + "namespace": "sbt.internal.remotecache", + "target": "Scala", + "type": "record", + "fields": [ + { + "name": "extractDirectory", + "type": "java.io.File" + }, + { + "name": "analysisFile", + "type": "java.io.File" + } + ] + }, + { + "name": "TestRemoteCacheArtifact", + "namespace": "sbt.internal.remotecache", + "target": "Scala", + "type": "record", + "fields": [ + { + "name": "extractDirectory", + "type": "java.io.File" + }, + { + "name": "analysisFile", + "type": "java.io.File" + }, + { + "name": "testResult", + "type": "java.io.File" + } + ] + }, + { + "name": "CustomRemoteCacheArtifact", + "namespace": "sbt.internal.remotecache", + "target": "Scala", + "type": "record", + "fields": [ + { + "name": "extractDirectory", + "type": "java.io.File" + }, + { + "name": "preserveLastModified", + "type": "Boolean" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 4faf06755..3cd8340e5 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -25,6 +25,7 @@ import sbt.internal.bsp._ import sbt.internal.inc.ScalaInstance import sbt.internal.io.WatchState import sbt.internal.librarymanagement.{ CompatibilityWarningOptions, IvySbt } +import sbt.internal.remotecache.RemoteCacheArtifact import sbt.internal.server.ServerHandler import sbt.internal.util.{ AttributeKey, ProgressState, SourcePosition } import sbt.io._ diff --git a/main/src/main/scala/sbt/internal/RemoteCache.scala b/main/src/main/scala/sbt/internal/RemoteCache.scala index 011c00396..828421143 100644 --- a/main/src/main/scala/sbt/internal/RemoteCache.scala +++ b/main/src/main/scala/sbt/internal/RemoteCache.scala @@ -20,6 +20,7 @@ import sbt.librarymanagement.syntax._ import sbt.internal.librarymanagement._ import sbt.io.IO import sbt.io.syntax._ +import sbt.internal.remotecache._ import sbt.internal.inc.JarUtils import sbt.util.Logger @@ -93,7 +94,7 @@ object RemoteCache { val p = remoteCacheProjectId.value val ids = remoteCacheIdCandidates.value val artifacts = (pushRemoteCacheConfiguration / remoteCacheArtifacts).value - val applicable = artifacts.filterNot(RemoteCacheArtifact.isPomArtifact) + val applicable = artifacts.filterNot(isPomArtifact) val classifiers = applicable.flatMap(_.artifact.classifier).toVector var found = false @@ -133,7 +134,7 @@ object RemoteCache { config.file.get }, remoteCachePom / remoteCacheArtifact := { - RemoteCacheArtifact.Pom((makePom / artifact).value, remoteCachePom) + PomRemoteCacheArtifact((makePom / artifact).value, remoteCachePom) } ) ++ inTask(pushRemoteCache)( Seq( @@ -204,11 +205,17 @@ object RemoteCache { ) ) + def isPomArtifact(artifact: RemoteCacheArtifact): Boolean = + artifact match { + case _: PomRemoteCacheArtifact => true + case _ => false + } + def compileArtifact( configuration: Configuration, classifier: String - ): Def.Initialize[Task[RemoteCacheArtifact.Compile]] = Def.task { - RemoteCacheArtifact.Compile( + ): Def.Initialize[Task[CompileRemoteCacheArtifact]] = Def.task { + CompileRemoteCacheArtifact( Artifact(moduleName.value, classifier), configuration / packageCache, (configuration / classDirectory).value, @@ -219,8 +226,8 @@ object RemoteCache { def testArtifact( configuration: Configuration, classifier: String - ): Def.Initialize[Task[RemoteCacheArtifact.Test]] = Def.task { - RemoteCacheArtifact.Test( + ): Def.Initialize[Task[TestRemoteCacheArtifact]] = Def.task { + TestRemoteCacheArtifact( Artifact(moduleName.value, classifier), configuration / packageCache, (configuration / classDirectory).value, @@ -260,21 +267,21 @@ object RemoteCache { private def extractJar(cacheArtifact: RemoteCacheArtifact, jar: File): Unit = cacheArtifact match { - case RemoteCacheArtifact.Compile(_, _, extractDirectory, analysisFile) => - extractCache(jar, extractDirectory, preserveLastModified = true) { output => - extractAnalysis(output, analysisFile) + case a: CompileRemoteCacheArtifact => + extractCache(jar, a.extractDirectory, preserveLastModified = true) { output => + extractAnalysis(output, a.analysisFile) } - case RemoteCacheArtifact.Test(_, _, extractDirectory, analysisFile, testResult) => - extractCache(jar, extractDirectory, preserveLastModified = true) { output => - extractAnalysis(output, analysisFile) - extractTestResult(output, testResult) + case a: TestRemoteCacheArtifact => + extractCache(jar, a.extractDirectory, preserveLastModified = true) { output => + extractAnalysis(output, a.analysisFile) + extractTestResult(output, a.testResult) } - case RemoteCacheArtifact.Custom(_, _, extractDirectory, preserveLastModified) => - extractCache(jar, extractDirectory, preserveLastModified)(_ => ()) + case a: CustomRemoteCacheArtifact => + extractCache(jar, a.extractDirectory, a.preserveLastModified)(_ => ()) - case RemoteCacheArtifact.Pom(_, _) => + case _ => () } @@ -304,11 +311,7 @@ object RemoteCache { } private def defaultArtifactTasks: Seq[TaskKey[File]] = - Seq( - remoteCachePom, - Compile / packageCache, - Test / packageCache - ) + Seq(remoteCachePom, Compile / packageCache, Test / packageCache) private def enabledOnly[A]( key: SettingKey[A], @@ -319,45 +322,3 @@ object RemoteCache { case (a, true) => a }) } - -sealed trait RemoteCacheArtifact { - def artifact: Artifact - def packaged: TaskKey[File] -} - -object RemoteCacheArtifact { - - final case class Pom( - artifact: Artifact, - packaged: TaskKey[File] - ) extends RemoteCacheArtifact - - final case class Compile( - artifact: Artifact, - packaged: TaskKey[File], - extractDirectory: File, - analysisFile: File - ) extends RemoteCacheArtifact - - final case class Test( - artifact: Artifact, - packaged: TaskKey[File], - extractDirectory: File, - analysisFile: File, - testResult: File - ) extends RemoteCacheArtifact - - final case class Custom( - artifact: Artifact, - packaged: TaskKey[File], - extractDirectory: File, - preserveLastModified: Boolean - ) extends RemoteCacheArtifact - - def isPomArtifact(artifact: RemoteCacheArtifact): Boolean = - artifact match { - case _: RemoteCacheArtifact.Pom => true - case _ => false - } - -}