forked from softprops/assembly-sbt
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from sbt/wip/cross-build
Cross build to sbt 2.x
- Loading branch information
Showing
43 changed files
with
403 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.9.9 | ||
sbt.version=1.10.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package sbtassembly | ||
|
||
import java.nio.file.{ Path => NioPath } | ||
import java.util.jar.{ Manifest => JManifest } | ||
import sbt.* | ||
import sbt.internal.util.HNil | ||
import sbt.internal.util.Types.:+: | ||
import sbt.util.FileInfo.lastModified | ||
import sbt.util.Tracked.{ inputChanged, lastOutput } | ||
import xsbti.FileConverter | ||
|
||
private[sbtassembly] object PluginCompat { | ||
type Out = java.io.File | ||
type MainClass = sbt.Package.MainClass | ||
|
||
object CollectionConverters | ||
|
||
val moduleIDStr = Keys.moduleID.key | ||
def parseModuleIDStrAttribute(m: ModuleID): ModuleID = m | ||
|
||
def toNioPath(a: Attributed[File])(implicit conv: FileConverter): NioPath = | ||
a.data.toPath() | ||
def toFile(a: Attributed[File])(implicit conv: FileConverter): File = | ||
a.data | ||
def toOutput(x: File)(implicit conv: FileConverter): File = | ||
x | ||
def toNioPaths(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[NioPath] = | ||
cp.map(_.data.toPath()).toVector | ||
def toFiles(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[File] = | ||
cp.map(_.data).toVector | ||
|
||
type CacheKey = FilesInfo[ModifiedFileInfo] :+: | ||
Map[String, (Boolean, String)] :+: // map of target paths that matched a merge strategy | ||
JManifest :+: | ||
// Assembly options... | ||
Boolean :+: | ||
Option[Seq[String]] :+: | ||
Option[Int] :+: | ||
Boolean :+: | ||
HNil | ||
|
||
val HListFormats = sbt.internal.util.HListFormats | ||
val Streamable = scala.tools.nsc.io.Streamable | ||
|
||
private[sbtassembly] def makeCacheKey( | ||
classes: Vector[NioPath], | ||
filteredJars: Vector[Attributed[File]], | ||
mergeStrategiesByPathList: Map[String, (Boolean, String)], | ||
jarManifest: JManifest, | ||
ao: AssemblyOption, | ||
): CacheKey = | ||
lastModified(classes.map(_.toFile()).toSet ++ filteredJars.map(_.data).toSet) :+: | ||
mergeStrategiesByPathList :+: | ||
jarManifest :+: | ||
ao.repeatableBuild :+: | ||
ao.prependShellScript :+: | ||
ao.maxHashLength :+: | ||
ao.appendContentHash :+: | ||
HNil | ||
|
||
// sbt 1.x style disk cache | ||
private[sbtassembly] def cachedAssembly(inputs: CacheKey, cacheDir: File, scalaVersion: String, log: Logger)( | ||
buildAssembly: () => File | ||
): File = { | ||
import CacheImplicits._ | ||
import sbt.internal.util.HListFormats._ | ||
import sbt.Package.manifestFormat | ||
val cacheBlock = inputChanged(cacheDir / s"assembly-cacheKey-$scalaVersion") { (inputChanged, _: CacheKey) => | ||
lastOutput(cacheDir / s"assembly-outputs-$scalaVersion") { (_: Unit, previousOutput: Option[File]) => | ||
val outputExists = previousOutput.exists(_.exists()) | ||
(inputChanged, outputExists) match { | ||
case (false, true) => | ||
log.info("Assembly jar up to date: " + previousOutput.get.toPath) | ||
previousOutput.get | ||
case (true, true) => | ||
log.debug("Building assembly jar due to changed inputs...") | ||
IO.delete(previousOutput.get) | ||
buildAssembly() | ||
case (_, _) => | ||
log.debug("Building assembly jar due to missing output...") | ||
buildAssembly() | ||
} | ||
} | ||
} | ||
cacheBlock(inputs)(Unit) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package sbtassembly | ||
|
||
import java.io.File | ||
import java.nio.file.{ Path => NioPath } | ||
import java.util.jar.{ Manifest => JManifest } | ||
import sbt.* | ||
import sbt.librarymanagement.ModuleID | ||
import xsbti.{ FileConverter, HashedVirtualFileRef } | ||
|
||
object PluginCompat: | ||
type Out = HashedVirtualFileRef | ||
type JarManifest = PackageOption.JarManifest | ||
type MainClass = PackageOption.MainClass | ||
type ManifestAttributes = PackageOption.ManifestAttributes | ||
type FixedTimestamp = PackageOption.FixedTimestamp | ||
|
||
val CollectionConverters = scala.collection.parallel.CollectionConverters | ||
|
||
val moduleIDStr = Keys.moduleIDStr | ||
def parseModuleIDStrAttribute(str: String): ModuleID = | ||
Classpaths.moduleIdJsonKeyFormat.read(str) | ||
|
||
def toNioPath(a: Attributed[HashedVirtualFileRef])(implicit conv: FileConverter): NioPath = | ||
conv.toPath(a.data) | ||
inline def toFile(a: Attributed[HashedVirtualFileRef])(implicit conv: FileConverter): File = | ||
toNioPath(a).toFile() | ||
def toOutput(x: File)(implicit conv: FileConverter): HashedVirtualFileRef = | ||
conv.toVirtualFile(x.toPath()) | ||
def toNioPaths(cp: Seq[Attributed[HashedVirtualFileRef]])(implicit conv: FileConverter): Vector[NioPath] = | ||
cp.map(toNioPath).toVector | ||
inline def toFiles(cp: Seq[Attributed[HashedVirtualFileRef]])(implicit conv: FileConverter): Vector[File] = | ||
toNioPaths(cp).map(_.toFile()) | ||
|
||
object HListFormats | ||
val Streamable = scala.reflect.io.Streamable | ||
|
||
extension [A1](init: Def.Initialize[Task[A1]]) | ||
def ? : Def.Initialize[Task[Option[A1]]] = Def.optional(init) { | ||
case None => sbt.std.TaskExtra.task { None } | ||
case Some(t) => t.map(Some.apply) | ||
} | ||
|
||
def or[A2 >: A1](i: Def.Initialize[Task[A2]]): Def.Initialize[Task[A2]] = | ||
init.?.zipWith(i) { (toa1: Task[Option[A1]], ta2: Task[A2]) => | ||
(toa1, ta2).mapN { | ||
case (oa1: Option[A1], a2: A2) => oa1.getOrElse(a2) | ||
} | ||
} | ||
|
||
val inTask = Project.inTask | ||
|
||
type CacheKey = Int | ||
private[sbtassembly] def makeCacheKey( | ||
classes: Vector[NioPath], | ||
filteredJars: Vector[Attributed[HashedVirtualFileRef]], | ||
mergeStrategiesByPathList: Map[String, (Boolean, String)], | ||
jarManifest: JManifest, | ||
ao: AssemblyOption, | ||
): CacheKey = 0 | ||
|
||
private[sbtassembly] def cachedAssembly(inputs: CacheKey, cacheDir: File, scalaVersion: String, log: Logger)( | ||
buildAssembly: () => PluginCompat.Out | ||
): PluginCompat.Out = | ||
buildAssembly() | ||
end PluginCompat |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.