Skip to content
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

chore: enforce assembly execution order #1076

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
10 changes: 8 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,19 @@ lazy val protobufV3 = pekkoModule("protobuf-v3")
Compile / packageBin / packagedArtifact := Scoped.mkTuple2(
(Compile / packageBin / artifact).value,
ReproducibleBuildsPlugin.postProcessJar(OsgiKeys.bundle.value)),
Compile / packageBin := ReproducibleBuildsPlugin
.postProcessJar((Compile / assembly).value), // package by running assembly
// we don't want to change the package task define/semantic here, let osgi be responsible it.
(Compile / assembly) := ReproducibleBuildsPlugin
.postProcessJar((Compile / assembly).value),
// Prevent cyclic task dependencies, see https://github.com/sbt/sbt-assembly/issues/365 by
// redefining the fullClasspath with just what we need to avoid the cyclic task dependency
assembly / fullClasspath := (Runtime / managedClasspath).value ++ (Compile / products).value.map(Attributed.blank),
assembly / test := {}, // assembly runs tests for unknown reason which introduces another cyclic dependency to packageBin via exportedJars
// Both assembly and osgi change the (Compile / packageBin) task define/semantic, so when we apply assembly then we have to
// let osgi first, and let osgi dependOn assembly.
OsgiKeys.explodedJars += assembly.value,
description := "Apache Pekko Protobuf V3 is a shaded version of the protobuf runtime. Original POM: https://github.com/protocolbuffers/protobuf/blob/v3.9.0/java/pom.xml")
.settings(PekkoDependWalker.protobufV3Settings)
.enablePlugins(DependWalkerPlugin)

lazy val pki =
pekkoModule("pki")
Expand Down
17 changes: 6 additions & 11 deletions project/OSGi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

import com.github.sbt.osgi.OsgiKeys
import com.github.sbt.osgi.SbtOsgi._
import sbt._
import sbt.Keys._
import sbtassembly.AssemblyKeys.assembly
import net.bzzt.reproduciblebuilds.ReproducibleBuildsPlugin
import sbt.Keys._
import sbt._

object OSGi {

Expand All @@ -43,7 +42,9 @@ object OSGi {
// figuring that out from the JDK it was built with)
OsgiKeys.requireCapability := "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version>=1.8))\"",
// Recent versions of BND create corrupted jars so use JDK jar instead, see https://github.com/sbt/sbt-osgi/pull/81
OsgiKeys.packageWithJVMJar := true)
OsgiKeys.packageWithJVMJar := true,
// Enable caching to avoid duplicate execution.
OsgiKeys.cacheStrategy := Some(OsgiKeys.CacheStrategy.Hash))

lazy val actor = osgiSettings ++ Seq(
OsgiKeys.exportPackage := Seq("org.apache.pekko*"),
Expand Down Expand Up @@ -82,13 +83,7 @@ object OSGi {
configImport(),
"*"),
OsgiKeys.exportPackage := Seq("org.apache.pekko.protobufv3.internal.*"),
OsgiKeys.privatePackage := Seq("google.protobuf.*"),
// Since the jar's generated by sbt-assembly are not added in dependencyClasspath
// we need to manually add it to sbt-osgi so it can pick it up. Note that since this
// is a fatjar from sbt-assembly we don't have to worry about incorrect osgi
// Import-Package header since the protobuf-V3 sbt-project has no real dependencies
// (including typical ones such as scala runtime)
OsgiKeys.explodedJars := Seq(assembly.value))
OsgiKeys.privatePackage := Seq("google.protobuf.*"))

lazy val jackson = exports(Seq("org.apache.pekko.serialization.jackson.*"))

Expand Down
8 changes: 8 additions & 0 deletions project/PekkoDependWalker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
*/

import Jdk9.CompileJdk9
import com.github.sbt.osgi.OsgiKeys
import io.github.roiocam.DependWalkerPlugin.autoImport.walkTasks
import io.github.roiocam.TaskDefine._
import io.github.roiocam._
import sbt.Keys._
import sbt._
import sbtassembly.AssemblyKeys

object PekkoDependWalker {

Expand All @@ -30,4 +32,10 @@ object PekkoDependWalker {
ScopeKeyMatcher((Compile / packageBin).scopedKey, CheckBoth),
ScopeKeyMatcher((CompileJdk9 / compile).scopedKey, CheckConfig))))

lazy val protobufV3Settings = Seq(
walkTasks := Seq(
WalkTask(
ScopeKeyMatcher(OsgiKeys.bundle.scopedKey, CheckTask),
ScopeKeyMatcher(AssemblyKeys.assembly.scopedKey, CheckTask))))
Roiocam marked this conversation as resolved.
Show resolved Hide resolved

}
Loading