Skip to content

Commit

Permalink
Generate OutputGroupInfo in a new phase
Browse files Browse the repository at this point in the history
Previously, it was generated in the "javainfo" phase, which runs before
the "depscheck" phase. "javainfo" can't run after "depscheck" because
"compile" depends on "javainfo", and "depscheck" can't run before
"javainfo" because it depends on "compile".
  • Loading branch information
Jaden Peterson committed Oct 30, 2024
1 parent 6919531 commit 21add76
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/newdocs/phases.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def _scala_binary_implementation(ctx):
("ijinfo", _phase_ijinfo),
("binary_deployjar", _phase_binary_deployjar),
("binary_launcher", _phase_binary_launcher),
("outputgroupinfo", _phase_outputgroupinfo),
("coda", _phase_coda),
]).coda
```
Expand Down
3 changes: 3 additions & 0 deletions rules/private/phases.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ load(":phases/phase_ijinfo.bzl", _phase_ijinfo = "phase_ijinfo")
load(":phases/phase_javainfo.bzl", _phase_javainfo = "phase_javainfo")
load(":phases/phase_library_defaultinfo.bzl", _phase_library_defaultinfo = "phase_library_defaultinfo")
load(":phases/phase_noop.bzl", _phase_noop = "phase_noop")
load(":phases/phase_outputgroupinfo.bzl", _phase_outputgroupinfo = "phase_outputgroupinfo")
load(":phases/phase_resources.bzl", _phase_resources = "phase_resources")
load(":phases/phase_scalafmt_nondefault_outputs.bzl", _phase_scalafmt_nondefault_outputs = "phase_scalafmt_nondefault_outputs")
load(":phases/phase_semanticdb.bzl", _phase_semanticdb = "phase_semanticdb")
Expand Down Expand Up @@ -41,6 +42,8 @@ phase_library_defaultinfo = _phase_library_defaultinfo

phase_noop = _phase_noop

phase_outputgroupinfo = _phase_outputgroupinfo

phase_resources = _phase_resources

phase_scalafmt_nondefault_outputs = _phase_scalafmt_nondefault_outputs
Expand Down
13 changes: 2 additions & 11 deletions rules/private/phases/phase_javainfo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ load(
# PHASE: javainfo
#
# Builds up the JavaInfo provider. And the ScalaInfo, while we're at it.
# And DefaultInfo.
#

def phase_javainfo(ctx, g):
Expand Down Expand Up @@ -65,18 +64,10 @@ def phase_javainfo(ctx, g):
scala_configuration = g.init.scala_configuration,
)

output_group_info = OutputGroupInfo(
**g.out.output_groups
)

g.out.providers.extend([
output_group_info,
java_info,
scala_info,
])
g.out.providers.append(java_info)
g.out.providers.append(scala_info)

return struct(
java_info = java_info,
output_group_info = output_group_info,
scala_info = scala_info,
)
8 changes: 8 additions & 0 deletions rules/private/phases/phase_outputgroupinfo.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# PHASE: outputgroupinfo
#
# Generates the `OutputGroupInfo` provider.
#

def phase_outputgroupinfo(ctx, g):
g.out.providers.append(OutputGroupInfo(**g.out.output_groups))
4 changes: 4 additions & 0 deletions rules/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ load(
_phase_javainfo = "phase_javainfo",
_phase_library_defaultinfo = "phase_library_defaultinfo",
_phase_noop = "phase_noop",
_phase_outputgroupinfo = "phase_outputgroupinfo",
_phase_resources = "phase_resources",
_phase_singlejar = "phase_singlejar",
_phase_test_launcher = "phase_test_launcher",
Expand Down Expand Up @@ -218,6 +219,7 @@ def _scala_library_implementation(ctx):
("coverage", _phase_coverage_jacoco),
("ijinfo", _phase_ijinfo),
("library_defaultinfo", _phase_library_defaultinfo),
("outputgroupinfo", _phase_outputgroupinfo),
("coda", _phase_coda),
]).coda

Expand All @@ -232,6 +234,7 @@ def _scala_binary_implementation(ctx):
("ijinfo", _phase_ijinfo),
("binary_deployjar", _phase_binary_deployjar),
("binary_launcher", _phase_binary_launcher),
("outputgroupinfo", _phase_outputgroupinfo),
("coda", _phase_coda),
]).coda

Expand All @@ -245,6 +248,7 @@ def _scala_test_implementation(ctx):
("coverage", _phase_coverage_jacoco),
("ijinfo", _phase_ijinfo),
("test_launcher", _phase_test_launcher),
("outputgroupinfo", _phase_outputgroupinfo),
("coda", _phase_coda),
]).coda

Expand Down

0 comments on commit 21add76

Please sign in to comment.