Skip to content

Commit

Permalink
Apply Apple-specific patches to the plugin
Browse files Browse the repository at this point in the history
feat: Add commented-out gazelle target to default project view (bazelbuild#104)

feat(release): Publish IntelliJ CE version of the plugin. (bazelbuild#103)

feat(tools): Add script to check versions (bazelbuild#105)

Radar: rdar://110389652 (Opening section of Bazel plugin setup confusing.)

Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>

build: Add release pipeline for version checker (bazelbuild#109)

Co-authored-by: Gibson Fahnestock <gib@apple.com>

feat: capture sdk and bazel plugin info for radar (bazelbuild#117)

* feat: capture sdk and bazel plugin info for radar

* Fix issues for clion plugin version

Co-authored-by: Joshua Harris <jharris33@apple.com>

build(prb): Make prb test every version of released products

build(ci): Increase timeout in Rio

build(ci): Key version counters by product

build(ci): Make apple version checker publish optional

fix: Default to workspace to infer project name (bazelbuild#122)

Instead of defaulting to "the parent directory of the project view
file", which is rarely what we want.

feat: Add support for cc_gtest_testsuite in BUILD files (bazelbuild#121)

cleanup: Enable --test_output=errors by default
  • Loading branch information
Simon Stewart authored and Borja Lorente committed Oct 24, 2023
1 parent a0bd15c commit da3508e
Show file tree
Hide file tree
Showing 63 changed files with 2,529 additions and 166 deletions.
22 changes: 20 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build --java_language_version=17
test --java_language_version=17 --java_runtime_version=17
common --experimental_downloader_config=tools/downloader.config

# delete testdata package needed for bazel integration tests
build --deleted_packages=//aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata
Expand All @@ -8,3 +7,22 @@ query --deleted_packages=//aspect/testing/tests/src/com/google/idea/blaze/aspect
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
# https://github.com/bazelbuild/intellij/issues/5432
common --noenable_bzlmod

# Apple-specific flags:

# Select our toolchains to pick the right platform for the RBE
build --java_language_version=17
build --java_runtime_version=applejdk_17
build --tool_java_language_version=17
build --tool_java_runtime_version=applejdk_17
build --extra_toolchains=@apple_federation//tools/jdk:applejdk17_toolchain_definition

# Enable RBE
build:remote --remote_instance_name=undisclosed-projects
build:remote --remote_download_toplevel

# Enable Xcode cache for faster development
build --xcode_version_config=@cached_local_xcode//:all_xcodes

# This is almost universally what we want
test --test_output=errors
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.3.2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bazel-*
/.ijwb/
/.aswb/
/.clwb/
.cicd
15 changes: 15 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
load("@apple_federation//go:defs.bzl", "gazelle")

#
# Description: Blaze plugin for various IntelliJ products.
#
load("@apple_federation//tools/buildifier:defs.bzl", "buildifier")
load(
"//:build-visibility.bzl",
"BAZEL_PLUGIN_SUBPACKAGES",
Expand Down Expand Up @@ -127,3 +129,16 @@ package_group(
"//third_party/bazel/src/main/protobuf/...",
],
)

# gazelle:prefix github.com/bazelbuild/intellij
gazelle(
# Why this name? Because otherwise the output dir conflicts with the `gazelle` top level directory.
name = "gazelle_bin",
mode = "fix",
)

buildifier(
name = "buildifier",
lint_mode = "fix",
lint_warnings = ["all"],
)
6 changes: 3 additions & 3 deletions README-apple.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

This assumes that you have a git remote called `apple` that points to our internal Apple fork, and one called `upstream` that points to the opensource repo:

- Set some variables (amend accordingly if your remote names differ): `apple=apple; upstream=upstream`
- Create the apple remote if not done yet: `git remote add $apple git@github.pie.apple.com:bazel-mirror/intellij.git`
- Create the upstream remote if not done yet: `git remote add $upstream https://github.com/bazelbuild/intellij.git`
* Set some variables (amend accordingly if your remote names differ): `apple=apple; upstream=upstream`
* Create the apple remote if not done yet: `git remote add $apple git@github.pie.apple.com:bazel-mirror/intellij.git`
* Create the upstream remote if not done yet: `git remote add $upstream https://github.com/bazelbuild/intellij.git`

To publish a version of the plugin that supports a new version of IntelliJ:

Expand Down
79 changes: 54 additions & 25 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")

http_archive(
name = "apple_federation",
sha256 = "1480d4e195e3a6d5d08a87ba987471df3ef44c5d17a67c12d1a87442182b4299",
url = "https://artifacts.apple.com/pie-devtools-local/bazel/rules/apple-federation/0.100.0/apple-federation-0.100.0.tar.gz",
)

# We load it before anything else because some of the upstream dependencies of the plugin load an outdated version of rules_go.
load("@apple_federation//internal/repositories/io_bazel_rules_go:repositories.bzl", "io_bazel_rules_go")

io_bazel_rules_go()

# Long-lived download links available at: https://www.jetbrains.com/intellij-repository/releases

# The plugin api for IntelliJ 2021.2. This is required to build IJwB,
Expand Down Expand Up @@ -282,13 +293,6 @@ http_archive(
url = PYTHON_PLUGIN_232_URL,
)

http_archive(
name = "python_2023_1",
build_file_content = _PYTHON_CE_BUILD_FILE,
sha256 = "825c30d2cbcce405fd18fddf356eb1f425607e9c780f8eff95d21ac23f8d90fd",
url = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/231.8770.65/PythonCore-231.8770.65.zip",
)

_GO_BUILD_FILE = """
java_import(
name = "go",
Expand Down Expand Up @@ -659,16 +663,13 @@ new_git_repository(
shallow_since = "1518210648 -0800",
)

http_archive(
name = "rules_python",
sha256 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e",
strip_prefix = "rules_python-0.19.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz",
)
load("@apple_federation//python:repositories.bzl", "python_deps")

load("@rules_python//python:repositories.bzl", "py_repositories")
python_deps()

py_repositories()
load("@apple_federation//python:setup.bzl", "python_setup")

python_setup()

http_archive(
name = "bazel_skylib",
Expand Down Expand Up @@ -709,7 +710,7 @@ bazel_binaries(versions = [
"6.0.0",
])

# LICENSE: The Apache Software License, Version 2.0
# # LICENSE: The Apache Software License, Version 2.0
http_archive(
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
Expand Down Expand Up @@ -801,15 +802,6 @@ jvm_maven_import_external(
server_urls = ["https://repo1.maven.org/maven2"],
)

http_archive(
name = "io_bazel_rules_go",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)

# gRPC Java
http_archive(
name = "io_grpc_grpc_java",
Expand Down Expand Up @@ -898,3 +890,40 @@ compat_repositories()

# Register custom java 17 toolchain
register_toolchains("//:custom_java_17_toolchain_definition")

load("@apple_federation//common:repositories.bzl", "common_deps")

common_deps()

load("@apple_federation//common:setup.bzl", "common_setup")

common_setup()

load("@apple_federation//go:repositories.bzl", "go_deps")

go_deps()

load("@apple_federation//go:setup.bzl", "go_setup")
load("//third_party/go:repositories.bzl", "go_dependencies")

# This has to go before go_setup, otherwise outdated versions of deps get downloaded.
# gazelle:repository_macro third_party/go/repositories.bzl%go_dependencies
go_dependencies()

# Directive to tell gazelle that we already defined the repository
# gazelle:repo bazel_gazelle

# Keep go_version in sync with go.mod
go_setup(go_version = "1.20")

load("@apple_federation//rbe:repositories.bzl", "rbe_deps")

rbe_deps()

load("@apple_federation//rbe:setup.bzl", "rbe_setup")

rbe_setup()

load("@apple_federation//common/xcode:workspace.bzl", "setup_cached_xcode_config")

setup_cached_xcode_config()
33 changes: 33 additions & 0 deletions apple/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load(
"//build_defs:build_defs.bzl",
"intellij_plugin",
"intellij_plugin_library",
"stamped_plugin_xml",
)
load(
"//:build-visibility.bzl",
"INTELLIJ_PLUGINS_VISIBILITY",
"PLUGIN_PACKAGES_VISIBILITY",
)

java_library(
name = "apple",
srcs = glob(["src/**/*.java"]),
javacopts = ["-Xep:FutureReturnValueIgnored:OFF"],
resources = glob(["src/resources/**/*"]),
visibility = PLUGIN_PACKAGES_VISIBILITY,
deps = [
"//base",
"//common/actions",
"//intellij_platform_sdk:jsr305", # unuseddeps: keep for @Nullable
"//intellij_platform_sdk:plugin_api",
"//sdkcompat",
],
)

intellij_plugin_library(
name = "plugin_library",
plugin_xmls = ["src/META-INF/apple.xml"],
visibility = PLUGIN_PACKAGES_VISIBILITY,
deps = [":apple"],
)
25 changes: 25 additions & 0 deletions apple/src/META-INF/apple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

<idea-plugin>
<actions>
<action
id="Apple.Bazel.OpenFAQ"
class="com.apple.idea.extensions.actions.OpenFAQ"
text="Open IntelliJ Plugin FAQ"
>
</action>
<action
id="Apple.Bazel.FileRadar"
class="com.apple.idea.extensions.actions.FileRadar"
text="File a Radar"
icon="apple.src.icons.AppleIcons.Radar"
>
</action>
</actions>

<extensions defaultExtensionNs="com.intellij">
<notificationGroup
displayType="BALLOON"
id="Apple.Bazel.NotificationGroup"
/>
</extensions>
</idea-plugin>
28 changes: 28 additions & 0 deletions apple/src/com/actions/BazelAppleMenuGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.apple.idea.extensions.actions;

import apple.src.icons.AppleIcons;
import com.google.idea.blaze.base.settings.Blaze;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.Project;

public class BazelAppleMenuGroup extends DefaultActionGroup {
@Override
public final void update(AnActionEvent e) {
// Don't hide the menu if project is null: it will be null temporarily while loading a
// Blaze project, and sometimes stays hidden permanently if we hide it during loading.
Project project = e.getProject();
if (project != null && !Blaze.isBlazeProject(project)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}

e.getPresentation().setEnabledAndVisible(true);
e.getPresentation().setText("&🍏Apple");
}

@Override
public boolean isDumbAware() {
return true;
}
}
Loading

0 comments on commit da3508e

Please sign in to comment.