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

Migrate to bzlmod #5805

Merged
merged 18 commits into from
Dec 20, 2023
Merged

Migrate to bzlmod #5805

merged 18 commits into from
Dec 20, 2023

Conversation

agluszak
Copy link
Collaborator

@agluszak agluszak commented Dec 4, 2023

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: <please reference the issue number or url here>

Description of this change

Closes #5432.
Migration to bzlmod will be required at some point. I replaced all jvm_maven_import_external withrules_jvm_external's mechanism so that we have a single point for downloading jar dependencies. I bumped versions of some rules - these which had no support for bzlmod.

@agluszak agluszak marked this pull request as ready for review December 14, 2023 12:14
@github-actions github-actions bot added product: CLion CLion plugin product: IntelliJ IntelliJ plugin product: GoLand GoLand plugin awaiting-review Awaiting review from Bazel team on PRs labels Dec 14, 2023
MODULE.bazel Show resolved Hide resolved
MODULE.bazel Show resolved Hide resolved
MODULE.bazel Show resolved Hide resolved
MODULE.bazel Show resolved Hide resolved
MODULE.bazel Show resolved Hide resolved
@tpasternak
Copy link
Collaborator

So I don't think I have any other issues, I'll try to go through it once again tomorrow. Btw the change is really large and very significant, so it would be good to have more eyes checking and approving, may i ask you to review the change independently? @mai93 @blorente

.bazelversion Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
workspace(name = "intellij_with_bazel")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep both WORKSPACE files, at least for one release? That way we have a fallback in case something goes wrong.

We might need to migrate the current WORKSPACE to rules_jvm_external, but you've already done it in this PR anyway.

I also see that some tests (esp. the aspect tests) will only work on bzlmod. I think this is fine, I don't think we need to add extra code to handle non-bzlmod cases.

Copy link
Collaborator Author

@agluszak agluszak Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep both WORKSPACE files, at least for one release? That way we have a fallback in case something goes wrong.

Because then we will have to keep them in sync. If something goes wrong, we can just revert this PR, can't we?

Copy link
Collaborator

@blorente blorente Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If something goes wrong, we can just revert this PR, can't we?

Given the number of files this PR touches, it's likely that someone will merge a change that makes the revert difficult at some point. But, you've already done most of the work for this and it's likely only going to impact us working on the plugin, so I'm not going to block the PR.

@@ -191,7 +198,8 @@ public void getPendingExternalDeps_followJavaDeps_allBuilt() throws Exception {
assertThat(
dt.getPendingExternalDeps(
ImmutableSet.copyOf(TestData.JAVA_LIBRARY_EXTERNAL_DEP_QUERY.getAssumedLabels())))
.isEmpty();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this test case changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this test case is supposed to check, but after my changes dt.getPendingExternalDeps( ImmutableSet.copyOf(TestData.JAVA_LIBRARY_EXTERNAL_DEP_QUERY.getAssumedLabels()))) started returning guava.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mai93 , do you know what this test case was supposed to check?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be empty as expected. By debugging I found that this test returns the dependency @com_google_guava_guava//jar:jar in the getLiveCachedTargets() mock which is checked in getPendingExternalDeps() and only the dependencies not present in the cached targets are returned but since the name of this dependency with bzlmod enabled contains repo name with ~ the check fails and the dependency is returned. So what is added in line 197 here needs to be updated and this should assert that the result is empty.

# Conflicts:
#	.bazelrc
#	ext/BUILD
#	querysync/javatests/com/google/idea/blaze/qsync/BUILD
@blorente
Copy link
Collaborator

blorente commented Dec 19, 2023

I just tried to import this on my machine (commit 1931c3e899446c3bbc18), and found a couple of issues:

  • The plugin refuses to import the plugin:
Screenshot 2023-12-19 at 15 01 20
  • When I run bazel clean --expunge && bazel test ... --define=ij_product=intellij-ue-under-dev, I get:
❯ bazel test ... --define=ij_product=intellij-ue-under-dev
INFO: Invocation ID: 10dc268b-91d6-4f50-b4dd-4e2ea010edd0
WARNING: Build options --define and --java_runtime_version have changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
[1 / 1] checking cached actions
INFO: Repository rules_bazel_integration_test~0.20.0~bazel_binaries~bazel_binaries_bazelisk instantiated at:
  <builtin>: in <toplevel>
Repository rule bazelisk_binary defined at:
  /private/var/tmp/_bazel_blorente/99101ccc32544f31e060bfc1a1f5d4f8/external/rules_bazel_integration_test~0.20.0/bazel_integration_test/private/bazel_binaries.bzl:95:34: in <toplevel>
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
[1 / 1] checking cached actions
ERROR: no such package '@@[unknown repo 'remoteapis' requested from @@]//': The repository '@@[unknown repo 'remoteapis' requested from @@]' could not be resolved: No repository visible as '@remoteapis' from main repository
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
ERROR: /Volumes/code/github.com/bazelbuild/intellij/third_party/bazel/src/main/protobuf/BUILD:147:14: no such package '@@[unknown repo 'remoteapis' requested from @@]//': The repository '@@[unknown repo 'remoteapis' requested from @@]' could not be resolved: No repository visible as '@remoteapis' from main repository and referenced by '//third_party/bazel/src/main/protobuf:remote_execution_log_proto'
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
Use --verbose_failures to see the command lines of failed build steps.
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
ERROR: Analysis of target '//third_party/bazel/src/main/protobuf:remote_execution_log_proto' failed; build aborted: Analysis failed
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
INFO: Elapsed time: 1.107s, Critical Path: 0.00s
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
INFO: 1 process: 1 internal.
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
ERROR: Build did NOT complete successfully
FAILED:
FAILED:
ERROR: No test targets were found, yet testing was requested
FAILED:
    Fetching repository @@rules_java~7.1.0~toolchains~local_jdk; starting
    Fetching https://github.com/bazelbuild/bazelisk/releases/download/v1.18.0/bazelisk-darwin-arm64

@agluszak
Copy link
Collaborator Author

I just tried to import this on my machine (commit 1931c3e899446c3bbc18), and found a couple of issues:

* The plugin refuses to import the plugin:
Screenshot 2023-12-19 at 15 01 20
* When I run `bazel clean --expunge && bazel test ... --define=ij_product=intellij-ue-under-dev`, I get:
❯ bazel test ... --define=ij_product=intellij-ue-under-dev
INFO: Invocation ID: 10dc268b-91d6-4f50-b4dd-4e2ea010edd0
WARNING: Build options --define and --java_runtime_version have changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
[1 / 1] checking cached actions
INFO: Repository rules_bazel_integration_test~0.20.0~bazel_binaries~bazel_binaries_bazelisk instantiated at:
  <builtin>: in <toplevel>
Repository rule bazelisk_binary defined at:
  /private/var/tmp/_bazel_blorente/99101ccc32544f31e060bfc1a1f5d4f8/external/rules_bazel_integration_test~0.20.0/bazel_integration_test/private/bazel_binaries.bzl:95:34: in <toplevel>
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
[1 / 1] checking cached actions
ERROR: no such package '@@[unknown repo 'remoteapis' requested from @@]//': The repository '@@[unknown repo 'remoteapis' requested from @@]' could not be resolved: No repository visible as '@remoteapis' from main repository
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
ERROR: /Volumes/code/github.com/bazelbuild/intellij/third_party/bazel/src/main/protobuf/BUILD:147:14: no such package '@@[unknown repo 'remoteapis' requested from @@]//': The repository '@@[unknown repo 'remoteapis' requested from @@]' could not be resolved: No repository visible as '@remoteapis' from main repository and referenced by '//third_party/bazel/src/main/protobuf:remote_execution_log_proto'
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
Use --verbose_failures to see the command lines of failed build steps.
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
ERROR: Analysis of target '//third_party/bazel/src/main/protobuf:remote_execution_log_proto' failed; build aborted: Analysis failed
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
INFO: Elapsed time: 1.107s, Critical Path: 0.00s
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
INFO: 1 process: 1 internal.
Analyzing: 791 targets (163 packages loaded, 607 targets configured)
ERROR: Build did NOT complete successfully
FAILED:
FAILED:
ERROR: No test targets were found, yet testing was requested
FAILED:
    Fetching repository @@rules_java~7.1.0~toolchains~local_jdk; starting
    Fetching https://github.com/bazelbuild/bazelisk/releases/download/v1.18.0/bazelisk-darwin-arm64

The first one is trivial, I forgot to leave an empty WORKSPACE file. I'm investigating the second one now

@agluszak
Copy link
Collaborator Author

@blorente has bazel build ... ever worked in this repo? When I try running it on master I get this:

➜  old-bazel-plugin git:(master) bazel build ... --define=ij_product=intellij-ue-under-dev 
WARNING: Target pattern parsing failed.
ERROR: Skipping '../..': invalid target name '../..': target names may not contain up-level references '..'
ERROR: invalid target name '../..': target names may not contain up-level references '..'
INFO: Elapsed time: 0.054s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
➜  old-bazel-plugin git:(master) bazel build //third_party/bazel/src/main/protobuf/... --define=ij_product=intellij-ue-under-dev
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:action_cache_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:android_deploy_info_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:bazel_flags_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:build_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:builtin_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:crosstool_config_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:deps_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:desugar_deps_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:execution_statistics_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:extra_actions_base_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:invocation_policy_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:java_compilation_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:memory_pressure_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:test_status_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:worker_protocol_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:execution_graph_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:analysis_v2_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:cache_salt_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:command_line_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:command_server_java_grpc_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:command_server_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:failure_details_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:option_filters_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:profile_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:remote_execution_log_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:remote_scrubbing_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:spawn_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: //third_party/bazel/src/main/protobuf:dist_jars: missing input file '//third_party/bazel/src/main/protobuf:xcode_java_proto_srcs'
ERROR: /home/andrzej.gluszak/code/jetbrains/old-bazel-plugin/third_party/bazel/src/main/protobuf/BUILD:218:10: 28 input file(s) do not exist
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.072s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
➜  old-bazel-plugin git:(master) bazel build //... --define=ij_product=intellij-ue-under-dev
WARNING: Target pattern parsing failed.
ERROR: Skipping '//...': error loading package under directory '': error loading package 'querysync/javatests/com/google/idea/blaze/qsync/testdata/kotlinlib': Label '//tools/build_defs/kotlin:rules.bzl' is invalid because 'tools/build_defs/kotlin' is not a package; perhaps you meant to put the colon here: '//:tools/build_defs/kotlin/rules.bzl'?
ERROR: error loading package under directory '': error loading package 'querysync/javatests/com/google/idea/blaze/qsync/testdata/kotlinlib': Label '//tools/build_defs/kotlin:rules.bzl' is invalid because 'tools/build_defs/kotlin' is not a package; perhaps you meant to put the colon here: '//:tools/build_defs/kotlin/rules.bzl'?
INFO: Elapsed time: 0.060s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

@blorente
Copy link
Collaborator

blorente commented Dec 19, 2023

@agluszak Fair enough. This is a command line we run in our pre-submit CI, so I'd expect it to work:

$  bazel clean --expunge && bazel test --define=ij_product=clion-latest //:clwb_tests

INFO: Repository rules_java~7.1.0~toolchains~remote_java_tools instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_blorente/99101ccc32544f31e060bfc1a1f5d4f8/external/bazel_tools/tools/build_defs/repo/http.bzl:384:31: in <toplevel>
ERROR: no such package '@@[unknown repo 'io_netty_netty_transport_classes_kqueue' requested from @@]//jar': The repository '@@[unknown repo 'io_netty_netty_transport_classes_kqueue' requested from @@]' could not be resolved: No repository visible as '@io_netty_netty_transport_classes_kqueue' from main repository
ERROR: /Volumes/code/github.com/bazelbuild/intellij/ext/BUILD:9:13: no such package '@@[unknown repo 'io_netty_netty_transport_classes_kqueue' requested from @@]//jar': The repository '@@[unknown repo 'io_netty_netty_transport_classes_kqueue' requested from @@]' could not be resolved: No repository visible as '@io_netty_netty_transport_classes_kqueue' from main repository and referenced by '//ext:intellijext'
ERROR: Analysis of target '//skylark:unit_tests' failed; build aborted: Analysis failed
INFO: Elapsed time: 5.183s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested
FAILED:
    Fetching repository @@bazel_tools~cc_configure_extension~local_config_cc; starting
    Fetching repository @@rules_cc; starting
    Fetching repository @@com_google_absl; starting

@agluszak
Copy link
Collaborator Author

agluszak commented Dec 19, 2023

it's a macos vs linux thingy, because on my (linux) machine it works... let me know if the latest commit fixes it for you. kqueue is only used on macos

@tpasternak
Copy link
Collaborator

Yeah, //... was never working, you have to run either tests or //ijwb:ijwb_bazel_zip or //clwb:clwb_bazel_zip

@blorente
Copy link
Collaborator

@agluszak Yep, commit 799e06f8e1 seemed to do the trick! Thanks for looking into it :D

I think this surfaces how nice it would be to have macOS CI, but that's for another day. Thanks for putting in this much effort.

"io.netty:netty-tcnative-boringssl-static:2.0.61.Final",
"io.netty:netty-tcnative-classes:2.0.61.Final",
"io.netty:netty-transport-classes-epoll:4.1.97.Final",
"io.netty:netty-transport-native-epoll:4.1.97.Final",
Copy link
Collaborator

@tpasternak tpasternak Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this makes any difference, but previously it was x86_64 version (just a side note, don't care

"//conditions:default": ["@io_netty_netty_transport_native_epoll//jar"],
"//conditions:default": [
"@io_netty_netty_transport_classes_epoll//jar",
"@io_netty_netty_transport_native_epoll//jar",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be related to the missing x86_64 version of the library missed above? On the other hand thi looks better if we dont reference arch directly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, something was transitively loading com_google_protobuf, and probably invoking this transitievly 👍

@@ -54,7 +54,8 @@ public enum TestData {
this.srcPaths = stream(paths).map(Path::of).collect(toImmutableList());
}

private static final String WORKSPACE_NAME = "intellij_with_bazel";
// TODO: Probably there's a better way to do this.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the answer, but let's do it later https://bazel.build/external/migration#specify-repo-name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, adding

module(
    name = "intellij_with_bazel",
    repo_name = "intellij_with_bazel",
)

to MODULE.bazel doesn't seem to affect it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is related to bazelbuild/bazel#18128


load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the only new thing, compared to the old WORKSPACE, do you remember where it came from? If not, then let's merge it, and document later

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so previously something (I don't remember/didn't check) loaded com_google_protobuf as a transitive dependency and after I switched that something to bzlmod it became inaccessible

Copy link
Collaborator

@tpasternak tpasternak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, comments above should not block merge

@tpasternak
Copy link
Collaborator

tpasternak commented Dec 19, 2023

Oh no, I just noticed windows build doesn't work, but maybe we could address it later. It looks like I hit this problem protocolbuffers/protobuf#12947

EDIT:

I was able to workaround it by just shortening the output_base path so NVM

@agluszak agluszak merged commit 5c016c0 into master Dec 20, 2023
8 checks passed
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Dec 20, 2023
Copy link
Collaborator

@mai93 mai93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried using the plugin built with this change to import the simple java project defined in https://github.com/bazelbuild/intellij/blob/master/examples/java/greetings_project/hello/hello.bazelproject and the initial build failed with:

Error: Unable to initialize main class com.google.idea.blaze.aspect.PackageParser
Caused by: java.lang.UnsupportedClassVersionError: com/google/protobuf/MessageLite has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

It is working fine on the commit right before this.

.bazelversion Outdated Show resolved Hide resolved
WORKSPACE.bzlmod Show resolved Hide resolved
WORKSPACE.bzlmod Show resolved Hide resolved
MODULE.bazel Show resolved Hide resolved
@@ -191,7 +198,8 @@ public void getPendingExternalDeps_followJavaDeps_allBuilt() throws Exception {
assertThat(
dt.getPendingExternalDeps(
ImmutableSet.copyOf(TestData.JAVA_LIBRARY_EXTERNAL_DEP_QUERY.getAssumedLabels())))
.isEmpty();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be empty as expected. By debugging I found that this test returns the dependency @com_google_guava_guava//jar:jar in the getLiveCachedTargets() mock which is checked in getPendingExternalDeps() and only the dependencies not present in the cached targets are returned but since the name of this dependency with bzlmod enabled contains repo name with ~ the check fails and the dependency is returned. So what is added in line 197 here needs to be updated and this should assert that the result is empty.

@@ -34,8 +34,8 @@
public class BazelPluginProcessorJarTest extends BazelIntellijAspectTest {
// blaze and bazel have different annotation processor paths & names.
private static final String JAR_STR =
jarString("auto-value-1.6.2.jar", /*iJar=*/ null, /*sourceJar=*/ null);
private static final String OUTPUT_GROUP_FILES = "../auto_value/auto-value-1.6.2.jar";
jarString("external/rules_jvm_external~5.3~maven~maven/com/google/auto/value/auto-value/1.10.2/processed_auto-value-1.10.2.jar", /*iJar=*/ null, /*sourceJar=*/ null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right approach or we should update the aspect to correctly strip the new external dependencies path prefix. we need to look more into why it is needed.

@mai93
Copy link
Collaborator

mai93 commented Dec 20, 2023

Oh no, I just noticed windows build doesn't work, but maybe we could address it later. It looks like I hit this problem protocolbuffers/protobuf#12947

EDIT:

I was able to workaround it by just shortening the output_base path so NVM

@tpasternak is this considered a regression for using the plugin on windows or do you mean developing the plugin on windows?

@tpasternak
Copy link
Collaborator

@tpasternak is this considered a regression for using the plugin on windows or do you mean developing the plugin on windows?

Unfortunately it looks like a general bzlmod issue. Luckily it only affects development on Windows (and other platforms), not using the plugin

bazelbuild/rules_go#3703 (comment)

agluszak added a commit that referenced this pull request Dec 21, 2023
tpasternak pushed a commit that referenced this pull request Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: CLion CLion plugin product: GoLand GoLand plugin product: IntelliJ IntelliJ plugin
Projects
Development

Successfully merging this pull request may close these issues.

Migrate to Bzlmod for managing external dependencies
4 participants