Skip to content

Commit 60e4b7d

Browse files
authored
Simplify sbt-osgi interop (#42)
1 parent 693dcca commit 60e4b7d

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/main/scala/ReproducibleBuildsPlugin.scala

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,7 @@ object ReproducibleBuildsPlugin extends AutoPlugin {
3939
disambiguation in Compile := ((packagedFiles: Iterable[File]) =>
4040
Some(sys.env.get("USER").orElse(sys.env.get("USERNAME")).map(_ + "-").getOrElse("") + packagedFiles.map(_.lastModified()).max)
4141
),
42-
packageBin in Compile := {
43-
val bin = (packageBin in Compile).value
44-
val dir = bin.getParentFile.toPath.resolve("stripped")
45-
dir.toFile.mkdir()
46-
val out = dir.resolve(bin.getName).toFile
47-
new ZipStripper()
48-
.addFileStripper("META-INF/MANIFEST.MF", new ManifestStripper())
49-
.addFileStripper("META-INF/maven/\\S*/pom.properties", new PomPropertiesStripper())
50-
.strip(bin, out)
51-
out
52-
},
42+
packageBin in Compile := postProcessJar((packageBin in Compile).value),
5343
artifactPath in reproducibleBuildsCertification := artifactPathSetting(artifact in reproducibleBuildsCertification).value,
5444
reproducibleBuildsPackageName := moduleName.value + "_" + scalaBinaryVersion.value,
5545
reproducibleBuildsCertification := {
@@ -136,6 +126,17 @@ object ReproducibleBuildsPlugin extends AutoPlugin {
136126
}
137127
)
138128

129+
def postProcessJar(jar: File): File = {
130+
val dir = jar.getParentFile.toPath.resolve("stripped")
131+
dir.toFile.mkdir()
132+
val out = dir.resolve(jar.getName).toFile
133+
new ZipStripper()
134+
.addFileStripper("META-INF/MANIFEST.MF", new ManifestStripper())
135+
.addFileStripper("META-INF/maven/\\S*/pom.properties", new PomPropertiesStripper())
136+
.strip(jar, out)
137+
out
138+
}
139+
139140
private def checkVerification(ours: File, uri: URI): Unit = {
140141
import scala.collection.JavaConverters._
141142
val ourSums = parseChecksums(Files.readAllLines(ours.toPath, Charset.forName("UTF-8")).asScala.toList)

src/sbt-test/sbt-reproducible-builds/osgi/build.sbt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ enablePlugins(SbtOsgi)
55

66
OsgiKeys.exportPackage := Seq("net.bzzt")
77

8-
// When replacing packageBin with the OSGi bundle...
9-
Compile / packageBin := OsgiKeys.bundle.value
10-
11-
// We need to explicitly load the rb settings again to
12-
// make sure the OSGi package is post-processed:
13-
ReproducibleBuildsPlugin.projectSettings
8+
// When replacing packageBin with the OSGi bundle,
9+
// we need to explicitly post-process it:
10+
Compile / packageBin := ReproducibleBuildsPlugin.postProcessJar(OsgiKeys.bundle.value)
1411

1512
// Make the filename static for easier validation:
1613
disambiguation in Compile := (_ => Some("STATIC"))

0 commit comments

Comments
 (0)