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>
  • Loading branch information
2 people authored and Borja Lorente committed Aug 2, 2023
1 parent f9523d8 commit 3de78a6
Show file tree
Hide file tree
Showing 46 changed files with 2,119 additions and 112 deletions.
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
common --experimental_downloader_config=tools/downloader.config

build --java_language_version=17 --javacopt=-source --javacopt=8 --javacopt=-target --javacopt=8
test --java_language_version=17 --javacopt=-source --javacopt=8 --javacopt=-target --javacopt=8 --java_runtime_version=17

# delete testdata package needed for bazel integration tests
build --deleted_packages=//aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata
query --deleted_packages=//aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/testdata

build:remote --remote_instance_name=undisclosed-projects

1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.2.0
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
16 changes: 16 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
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 @@ -98,3 +101,16 @@ test_suite(
"//python:unit_tests",
],
)

# 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
61 changes: 45 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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 = "7c5b12b68c01d7ed3114c71fe3f0f907d0a435f1215a2c99143676714e1564f7",
url = "https://artifacts.apple.com/pie-devtools-local/bazel/rules/apple-federation/0.93.0/apple-federation-0.93.0.tar.gz",
)

# 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 +288,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 @@ -643,16 +642,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 @@ -693,7 +689,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 @@ -784,3 +780,36 @@ jvm_maven_import_external(
licenses = ["notice"], # Apache 2.0
server_urls = ["https://repo1.maven.org/maven2"],
)

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()
2 changes: 1 addition & 1 deletion aspect/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
workspace(name = "intellij_aspect")
workspace(name = "intellij_aspect")
2 changes: 1 addition & 1 deletion aspect/artifacts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def to_artifact_location(exec_path, root_exec_path_fragment, is_source, is_exter
relative_path = relative_path,
is_source = is_source,
is_external = is_external,
root_execution_path_fragment = root_exec_path_fragment
root_execution_path_fragment = root_exec_path_fragment,
)

def is_external_artifact(label):
Expand Down
2 changes: 1 addition & 1 deletion aspect/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ java_library(
deps = [
":guava",
"//proto:proto_deps",
"@jsr305_annotations//jar",
"//third_party/bazel/src/main/protobuf:worker_protocol_java_proto",
"@jsr305_annotations//jar",
],
)

Expand Down
3 changes: 1 addition & 2 deletions base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ load(
)
load("//intellij_platform_sdk:build_defs.bzl", "java_version_flags")


licenses(["notice"])

java_library(
Expand Down Expand Up @@ -471,6 +470,7 @@ java_library(
"//base/tests/utils/testdata/java/com/test2",
"//base/tests/utils/testdata/java/com/test2:test2_srcs",
],
javacopts = java_version_flags(),
visibility = PLUGIN_PACKAGES_VISIBILITY,
deps = [
":base",
Expand All @@ -485,7 +485,6 @@ java_library(
"@com_google_guava_guava//jar",
"@junit//jar",
],
javacopts = java_version_flags()
)

stamped_plugin_xml(
Expand Down
2 changes: 1 addition & 1 deletion base/src/com/google/idea/blaze/base/util/SaveUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/** Utility for saving all files. */
public class SaveUtil {
public static void saveAllFiles() {
Transactions.submitTransactionAndWait(
Transactions.submitWriteActionTransactionAndWait(
() -> FileDocumentManager.getInstance().saveAllDocuments());
}
}
2 changes: 1 addition & 1 deletion examples/cpp/simple_project/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ http_archive(
name = "com_google_googletest",
sha256 = "ffa17fbc5953900994e2deec164bb8949879ea09b411e07f215bfbb1f87f4632",
strip_prefix = "googletest-1.13.0",
urls = ["https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip"]
urls = ["https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip"],
)
Empty file added examples/go/with_proto/go.mod
Empty file.
1 change: 1 addition & 0 deletions gazelle/src/META-INF/blaze-gazelle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<SyncListener implementation="com.google.idea.blaze.gazelle.GazelleSyncListener" />
<SyncPlugin implementation="com.google.idea.blaze.gazelle.GazelleSyncPlugin" />
<SettingsUiContributor implementation="com.google.idea.blaze.gazelle.GazelleUserSettingsConfigurable$UiContributor" />
<ProjectViewDefaultValueProvider implementation="com.google.idea.blaze.gazelle.GazelleSection$GazelleProjectViewDefaultValueProvider" />
</extensions>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="com.google.idea.blaze.gazelle.GazelleRunner"
Expand Down
34 changes: 33 additions & 1 deletion gazelle/src/com/google/idea/blaze/gazelle/GazelleSection.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@
package com.google.idea.blaze.gazelle;

import com.google.idea.blaze.base.model.primitives.Label;
import com.google.idea.blaze.base.projectview.ProjectView;
import com.google.idea.blaze.base.projectview.ProjectViewSet;
import com.google.idea.blaze.base.projectview.parser.ParseContext;
import com.google.idea.blaze.base.projectview.parser.ProjectViewParser;
import com.google.idea.blaze.base.projectview.section.ListSection;
import com.google.idea.blaze.base.projectview.section.ProjectViewDefaultValueProvider;
import com.google.idea.blaze.base.projectview.section.ScalarSection;
import com.google.idea.blaze.base.projectview.section.ScalarSectionParser;
import com.google.idea.blaze.base.projectview.section.Section;
import com.google.idea.blaze.base.projectview.section.SectionKey;
import com.google.idea.blaze.base.projectview.section.SectionParser;
import com.google.idea.blaze.base.projectview.section.sections.TextBlock;
import com.google.idea.blaze.base.projectview.section.sections.TextBlockSection;
import com.google.idea.blaze.base.settings.BuildSystemName;
import org.jdom.Text;
import org.jetbrains.annotations.Nullable;

/** Section for project-specific gazelle configuration. */
/**
* Section for project-specific gazelle configuration.
*/
public class GazelleSection {

public static final SectionKey<Label, ScalarSection<Label>> KEY = SectionKey.of("gazelle_target");
Expand Down Expand Up @@ -66,4 +77,25 @@ public String quickDocs() {
+ " sync.";
}
}

public static class GazelleProjectViewDefaultValueProvider implements
ProjectViewDefaultValueProvider {

@Override
public ProjectView addProjectViewDefaultValue(BuildSystemName buildSystemName,
ProjectViewSet projectViewSet, ProjectView topLevelProjectView) {
if (!topLevelProjectView.getSectionsOfType(KEY).isEmpty()) {
return topLevelProjectView;
}
TextBlockSection defaultGazelle = TextBlockSection.of(TextBlock.of(
"# Uncomment to run this target before every sync",
"# gazelle_target: //:gazelle"));
return ProjectView.builder(topLevelProjectView).add(defaultGazelle).build();
}

@Override
public SectionKey<?, ?> getSectionKey() {
return KEY;
}
}
}
61 changes: 61 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module github.com/bazelbuild/intellij

go 1.20

require (
github.pie.apple.com/bazel/apple_federation v0.0.0-20221110173607-530f8e4ddb1e

// Direct dependencies from the federation on Linux.
// This library is deprecated, and will be removed eventually, but as long as we don't update the federation, we need it.
// We import it in `release/fixdns_hack.go` so that `go mod tidy` doesn't remove it.
github.pie.apple.com/isd-dev/go-fixdns v0.0.0-20211011165817-7cdbea777a9c
go.starlark.net v0.0.0-20220817180228-f738f5508c12
)

require (
github.com/CycloneDX/cyclonedx-go v0.6.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/forPelevin/gomoji v1.1.6 // indirect
github.com/git-lfs/go-netrc v0.0.0-20210914205454-f0c862dd687a // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.4.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/snappy v0.0.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gookit/color v1.5.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jfrog/build-info-go v1.6.0 // indirect
github.com/jfrog/gofrog v1.2.1 // indirect
github.com/jfrog/jfrog-client-go v1.23.3 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/klauspost/compress v1.11.4 // indirect
github.com/klauspost/cpuid/v2 v2.0.6 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/minio/sha256-simd v1.0.1-0.20210617151322-99e45fae3395 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.3.4 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/xanzy/ssh-agent v0.3.2 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
github.pie.apple.com/isd-dev/go-debugflags v0.0.0-20211011163132-90a69a62cdcb // indirect
github.pie.apple.com/isd-dev/go-rioenv v0.0.0-20210611144753-d66265b9ca79 // indirect
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
Loading

0 comments on commit 3de78a6

Please sign in to comment.