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

Move scope-related tasks together in JavaModule #4076

Merged
Merged
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
68 changes: 34 additions & 34 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@ trait JavaModule
*/
def moduleDeps: Seq[JavaModule] = Seq.empty

/**
* The compile-only direct dependencies of this module. These are *not*
* transitive, and only take effect in the module that they are declared in.
*/
def compileModuleDeps: Seq[JavaModule] = Seq.empty

/**
* The runtime-only direct dependencies of this module. These *are* transitive,
* and so get propagated to downstream modules automatically
*/
def runModuleDeps: Seq[JavaModule] = Seq.empty

/**
* Same as [[moduleDeps]] but checked to not contain cycles.
* Prefer this over using [[moduleDeps]] directly.
Expand All @@ -327,6 +339,13 @@ trait JavaModule
moduleDeps
}

/** Same as [[compileModuleDeps]] but checked to not contain cycles. */
final def compileModuleDepsChecked: Seq[JavaModule] = {
// trigger initialization to check for cycles
recCompileModuleDeps
compileModuleDeps
}

/**
* Same as [[moduleDeps]] but checked to not contain cycles.
* Prefer this over using [[moduleDeps]] directly.
Expand All @@ -345,33 +364,6 @@ trait JavaModule
_.moduleDeps
)

/** Should only be called from [[runModuleDepsChecked]] */
private lazy val recRunModuleDeps: Seq[JavaModule] =
ModuleUtils.recursive[JavaModule](
(millModuleSegments ++ Seq(Segment.Label("runModuleDeps"))).render,
this,
m => m.runModuleDeps ++ m.moduleDeps
)

/**
* The compile-only direct dependencies of this module. These are *not*
* transitive, and only take effect in the module that they are declared in.
*/
def compileModuleDeps: Seq[JavaModule] = Seq.empty

/**
* The runtime-only direct dependencies of this module. These *are* transitive,
* and so get propagated to downstream modules automatically
*/
def runModuleDeps: Seq[JavaModule] = Seq.empty

/** Same as [[compileModuleDeps]] but checked to not contain cycles. */
final def compileModuleDepsChecked: Seq[JavaModule] = {
// trigger initialization to check for cycles
recCompileModuleDeps
compileModuleDeps
}

/** Should only be called from [[compileModuleDeps]] */
private lazy val recCompileModuleDeps: Seq[JavaModule] =
ModuleUtils.recursive[JavaModule](
Expand All @@ -380,6 +372,14 @@ trait JavaModule
_.compileModuleDeps
)

/** Should only be called from [[runModuleDepsChecked]] */
private lazy val recRunModuleDeps: Seq[JavaModule] =
ModuleUtils.recursive[JavaModule](
(millModuleSegments ++ Seq(Segment.Label("runModuleDeps"))).render,
this,
m => m.runModuleDeps ++ m.moduleDeps
)

/** The direct and indirect dependencies of this module */
def recursiveModuleDeps: Seq[JavaModule] = { recModuleDeps }

Expand Down Expand Up @@ -421,13 +421,6 @@ trait JavaModule
(runModuleDepsChecked ++ moduleDepsChecked).flatMap(_.transitiveRunModuleDeps).distinct
}

/** The compile-only transitive ivy dependencies of this module and all it's upstream compile-only modules. */
def transitiveCompileIvyDeps: T[Agg[BoundDep]] = Task {
// We never include compile-only dependencies transitively, but we must include normal transitive dependencies!
compileIvyDeps().map(bindDependency()) ++
T.traverse(compileModuleDepsChecked)(_.transitiveIvyDeps)().flatten
}

/**
* Show the module dependencies.
* @param recursive If `true` include all recursive module dependencies, else only show direct dependencies.
Expand Down Expand Up @@ -498,6 +491,13 @@ trait JavaModule
}
}

/** The compile-only transitive ivy dependencies of this module and all it's upstream compile-only modules. */
def transitiveCompileIvyDeps: T[Agg[BoundDep]] = Task {
// We never include compile-only dependencies transitively, but we must include normal transitive dependencies!
compileIvyDeps().map(bindDependency()) ++
T.traverse(compileModuleDepsChecked)(_.transitiveIvyDeps)().flatten
}

/**
* The transitive run ivy dependencies of this module and all it's upstream modules.
* This is calculated from [[runIvyDeps]], [[mandatoryIvyDeps]] and recursively from [[moduleDeps]].
Expand Down
Loading