Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Oct 6, 2024
1 parent 29fad7e commit 6231831
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/main/scala-3/PluginCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ object PluginCompat:
type JarManifest = PackageOption.JarManifest
type MainClass = PackageOption.MainClass
type ManifestAttributes = PackageOption.ManifestAttributes
type FixedTimestamp = PackageOption.FixedTimestamp

val CollectionConverters = scala.collection.parallel.CollectionConverters

Expand Down
16 changes: 3 additions & 13 deletions src/main/scala/sbtassembly/Assembly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package sbtassembly
import com.eed3si9n.jarjarabrams._
import sbt.Def.Initialize
import sbt.Keys._
import sbt.Package.{ manifestFormat, JarManifest, MainClass, ManifestAttributes }
import sbt.Package.{ manifestFormat, JarManifest, MainClass, ManifestAttributes, FixedTimestamp }
import sbt.internal.inc.classpath.ClasspathUtil
import sbt.io.{ DirectoryFilter => _, IO => _, Path => _, Using }
import sbt.util.{ FilesInfo, Level, ModifiedFileInfo }
Expand Down Expand Up @@ -564,19 +564,9 @@ object Assembly {
case JarManifest(mergeManifest) => Package.mergeManifests(manifest, mergeManifest)
case MainClass(mainClassName) => main.put(JAttributes.Name.MAIN_CLASS, mainClassName)
case ManifestAttributes(attrs @ _*) => main ++= attrs
case FixedTimestamp(value) => time = value
case _ =>
// use reflection for compatibility
if (option.getClass.getName == "sbt.Package$FixedTimestamp") {
try
// https://github.com/sbt/sbt/blob/59130d4703e9238e/main-actions/src/main/scala/sbt/Package.scala#L50
time = option.asInstanceOf[{ def value: Option[Long] }].value
catch {
case e: Throwable =>
log.debug(e.toString)
}
} else {
log.warn("Ignored unknown package option " + option)
}
log.warn("Ignored unknown package option " + option)
}
if (!main.contains(JAttributes.Name.MANIFEST_VERSION)) main.put(JAttributes.Name.MANIFEST_VERSION, "1.0")
manifest -> time
Expand Down
8 changes: 8 additions & 0 deletions src/sbt-test/caching/caching/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ lazy val root = (project in file(".")).
()
}
)

TaskKey[Unit]("fileCheck1") := {
assert((crossTarget.value / "foo.jar").exists())
}

TaskKey[Unit]("fileCheck2") := {
assert((crossTarget.value / "jarHash.txt").exists())
}
6 changes: 3 additions & 3 deletions src/sbt-test/caching/caching/test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# check if the file gets created
> clean
> assembly
$ exists target/scala-2.12/foo.jar
> fileCheck1

# run to cache the hash, then check it's consistent
> check
> checkhash
$ exists target/scala-2.12/jarHash.txt
> fileCheck2
> checkhash

> assembly
Expand All @@ -16,7 +16,7 @@ $ exists target/scala-2.12/jarHash.txt
# when the unzipped jars are read from cache
# on disk
> checkhash
$ newer target/scala-2.12/jarHash.txt target/scala-2.12/foo.jar
# $ newer target/scala-2.12/jarHash.txt target/scala-2.12/foo.jar

# generate file
> genresource
Expand Down
21 changes: 16 additions & 5 deletions src/sbt-test/sbt-assembly/piecemeal/build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
ThisBuild / version := "0.1"
ThisBuild / scalaVersion := "2.12.18"

ThisBuild / assemblyPackageScala / assembleArtifact := false
ThisBuild / assemblyPackageDependency / assembleArtifact := false
version := "0.1"
scalaVersion := "2.12.18"
assemblyPackageScala / assembleArtifact := false
assemblyPackageDependency / assembleArtifact := false

lazy val root = (project in file("."))
.settings(
Expand Down Expand Up @@ -33,3 +32,15 @@ lazy val root = (project in file("."))
()
}
)

TaskKey[Unit]("fileCheck1") := {
assert((crossTarget.value / "foo-assembly-0.1.jar").exists())
}

TaskKey[Unit]("fileCheck2") := {
assert((crossTarget.value / "foo-assembly-0.1-deps.jar").exists())
}

TaskKey[Unit]("fileCheck3") := {
assert((crossTarget.value / "scala-library-2.12.18-assembly.jar").exists())
}
6 changes: 3 additions & 3 deletions src/sbt-test/sbt-assembly/piecemeal/test
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# check if the file gets created
> assembly
$ exists target/scala-2.12/foo-assembly-0.1.jar
> fileCheck1

# try running this JAR. this should fail
-> check1

# check if the file gets created
> assemblyPackageDependency
$ exists target/scala-2.12/foo-assembly-0.1-deps.jar
> fileCheck2

# check if the file gets created
> assemblyPackageScala
$ exists target/scala-2.12/scala-library-2.12.18-assembly.jar
> fileCheck3

# check if it says hello
> check2

0 comments on commit 6231831

Please sign in to comment.