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

[BACKPORT] Separate resolvedRunIvyDeps and transitiveLocalClasspath into two stages when build assembly jar #4566

Merged
merged 10 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 31 additions & 2 deletions scalalib/src/mill/scalalib/AssemblyModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,44 @@ trait AssemblyModule extends mill.Module {

private[mill] def assemblyRules0: Seq[Assembly.Rule] = Assembly.defaultRules

/**
* Upstream classfiles and resources from third-party libraries
* necessary to build an executable assembly
*/
def upstreamIvyAssemblyClasspath: T[Agg[PathRef]] = Agg.empty[PathRef]

/**
* Upstream classfiles and resources from locally-built modules
* necessary to build an executable assembly, but without this module's contribution
*/
def upstreamLocalAssemblyClasspath: T[Agg[PathRef]] = upstreamAssemblyClasspath()

def upstreamAssemblyClasspath: T[Agg[PathRef]]

def localClasspath: T[Seq[PathRef]]

/**
* Build the assembly for third-party dependencies separate from the current
* classpath
*
* This should allow much faster assembly creation in the common case where
* third-party dependencies do not change
*/
def resolvedIvyAssembly: T[Assembly] = Task {
Assembly.create(
destJar = Task.dest / "out.jar",
inputPaths = upstreamIvyAssemblyClasspath().map(_.path),
manifest = manifest(),
assemblyRules = assemblyRules
)
}

private[mill] def upstreamAssembly2_0: T[Assembly] = Task {
Assembly.create(
destJar = Task.dest / "out.jar",
inputPaths = upstreamAssemblyClasspath().map(_.path),
inputPaths = upstreamLocalAssemblyClasspath().map(_.path),
manifest = manifest(),
base = Some(resolvedIvyAssembly().pathRef.path),
assemblyRules = assemblyRules
)
}
Expand Down Expand Up @@ -112,7 +141,7 @@ trait AssemblyModule extends mill.Module {
val problematicEntryCount = 65535
if (
prependScript.isDefined &&
(upstream.addedEntries + created.addedEntries) > problematicEntryCount
(resolvedIvyAssembly().addedEntries + upstream.addedEntries + created.addedEntries) > problematicEntryCount
) {
Result.Failure(
s"""The created assembly jar contains more than ${problematicEntryCount} ZIP entries.
Expand Down
8 changes: 8 additions & 0 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,14 @@ trait JavaModule
)
}

def upstreamIvyAssemblyClasspath: T[Agg[PathRef]] = Task {
resolvedRunIvyDeps()
}

def upstreamLocalAssemblyClasspath: T[Agg[PathRef]] = Task {
transitiveLocalClasspath()
}

/**
* All upstream classfiles and resources necessary to build and executable
* assembly, but without this module's contribution
Expand Down
Loading