-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy aspect files to workspace (#7202)
Copy all aspects into the workspace instead of using a `--override_repository` or `--inject_repository` flag to point to the bundled aspects. This provides some benefits: - No more caching problems caused by `--override_repository` - No different logic for Bazel 8, since `--inject_repository` is also not required
- Loading branch information
Showing
48 changed files
with
768 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
load("@rules_pkg//pkg:pkg.bzl", "pkg_zip") | ||
load("@rules_java//java:defs.bzl", "java_import") | ||
load("@bazel_skylib//lib:paths.bzl", "paths") | ||
|
||
def _java_8_transition_impl(settings, attr): | ||
return {"//command_line_option:javacopt": ["-source", "8", "-target", "8"]} | ||
|
||
_java_8_transition = transition( | ||
implementation = _java_8_transition_impl, | ||
inputs = [], | ||
outputs = ["//command_line_option:javacopt"], | ||
) | ||
|
||
def _java_8_cfg_impl(ctx): | ||
files = [] | ||
|
||
for jar in ctx.attr.jars: | ||
files.extend(jar[DefaultInfo].files.to_list()) | ||
|
||
return [DefaultInfo(files = depset(files))] | ||
|
||
_java_8_cfg = rule( | ||
implementation = _java_8_cfg_impl, | ||
attrs = { | ||
"jars": attr.label_list(mandatory = True, allow_files = True, cfg = _java_8_transition), | ||
}, | ||
) | ||
|
||
def aspect_library(name, namespace = "/", files = [], jars = [], **kwargs): | ||
""" | ||
Creates an aspect library for a set of files. | ||
An aspect library is a zip file imported as a java library to have more precise | ||
control over the file layout. Also configures all included jars to be build with | ||
java 8, to ensure compatability. | ||
Args: | ||
name (str): The name of the target. Also used to generate the JAR file name. | ||
namespace (str, optional): The parent directory inside the JAR file. | ||
files (list, optional): A list of files to include in the JAR. | ||
jars (list, optional): A list of jars to include in the JAR (configured for java 8). | ||
**kwargs: Additional arguments forwarded to the `java_import` rule. | ||
""" | ||
|
||
cfg_java_name = "%s_java" % name | ||
_java_8_cfg( | ||
name = cfg_java_name, | ||
jars = jars, | ||
) | ||
|
||
pkg_zip_name = "%s_zip" % name | ||
pkg_zip( | ||
name = pkg_zip_name, | ||
package_file_name = "%s.jar" % name, | ||
package_dir = namespace, | ||
srcs = files + [cfg_java_name], | ||
) | ||
|
||
java_import( | ||
name = name, | ||
jars = [pkg_zip_name], | ||
**kwargs | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
20 changes: 6 additions & 14 deletions
20
aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
load( | ||
"@rules_bazel_integration_test//bazel_integration_test:defs.bzl", | ||
"bazel_integration_tests", | ||
) | ||
load("@bazel_binaries//:defs.bzl", "bazel_binaries") | ||
load("//testing:test_defs.bzl", "bazel_integration_tests") | ||
|
||
java_binary( | ||
name = "BazelInvokingIntegrationTestRunner", | ||
testonly = True, | ||
srcs = ["BazelInvokingIntegrationTestRunner.java"], | ||
data = [ | ||
"//aspect:aspect_files", | ||
"//aspect_template:aspect_files", | ||
], | ||
main_class = "com.google.idea.blaze.aspect.integration.BazelInvokingIntegrationTestRunner", | ||
deps = [ | ||
"//aspect/testing:guava", | ||
"//base", | ||
"//intellij_platform_sdk:jsr305", | ||
"//intellij_platform_sdk:plugin_api_for_tests", | ||
"//intellij_platform_sdk:test_libs", | ||
"//sdkcompat", | ||
], | ||
) | ||
|
||
bazel_integration_tests( | ||
name = "bazel_invocation_integration_tests", | ||
bazel_versions = bazel_binaries.versions.all, | ||
# set tags = [] because otherwise bazel_integration_tests sets | ||
# tags = ["manual"] and the target is not be detected via test //pkg/... | ||
tags = [], | ||
name = "bazel_invocation_integration_test", | ||
test_runner = ":BazelInvokingIntegrationTestRunner", | ||
workspace_path = "testdata", | ||
) |
Oops, something went wrong.