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

[FR]: Document how to use gazelle Kotlin plugin from a bzlmod project #750

Open
gonzojive opened this issue Oct 2, 2024 · 1 comment
Open
Labels
enhancement New feature or request untriaged Requires traige

Comments

@gonzojive
Copy link

gonzojive commented Oct 2, 2024

What is the current behavior?

The documentation for setting up the Kotlin gazelle plugin is a bit sparse. I can't tell how to compile it into a custom gazelle binary from a bzlmod project.

Describe the feature

Document how to install the gazelle plugin in a bzlmod project. For example, I have the following MODULE.bazel. What's required to plug in Kotlin gazelle?

module(
    name = "dir_find_and_replace",
    version = "0.0.1",
)

bazel_dep(name = "rules_kotlin", version = "1.9.6")
bazel_dep(name = "rules_jvm_external", version = "6.4")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")

# When updating a dependency, run REPIN=1 bazel run @maven//:pin
maven.install(
    artifacts = [
        "com.google.truth:truth:1.1.2",
        "junit:junit:4.13.2",
    ],
    lock_file = "//:maven_install.json",
    repositories = [
        "https://repo1.maven.org/maven2",
    ],
)
use_repo(maven, "maven")

bazel_dep(name = "gazelle", version = "0.39.0", dev_dependency = True)
bazel_dep(name = "rules_go", version = "0.50.1", dev_dependency = True)

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
# BUILD.bazel

load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")

# gazelle:prefix github.com/bazel-gazelle/tests/bcr
gazelle_binary(
    name = "gazelle",
    languages = [
        # "@gazelle_kotlin//gazelle/kotlin:kotlin", Presumably I want something like this
        "@gazelle//language/go",
        "@gazelle//language/proto",
    ],
    visibility = ["//visibility:private"],
)

For the sake of getting something working, I split off the gazelle code from the rest of aspect-cli, made it work with bzlmod instead of WORKSPACE, and started using the fork in an example project. Would Aspect prefer to keep the gazelle plugin(s) within aspect-cli, or are you open to splitting of the gazelle plugins into a separate repo or repos? If kept in this repo, could/should they be packaged into distinct bzlmod module (by putting a MODULE.bazel file and a go.mod file within /gazelle or something, presumably)?

From the outside, having a tightly scoped project concerned only with the Kotlin gazelle plugin could be nice and simple. It might make it slightly more inviting to contribute improvements. But Aspect might have its reasons for keeping the gazelle stuff inside aspect-cli.

@gonzojive gonzojive added the enhancement New feature or request label Oct 2, 2024
@github-actions github-actions bot added the untriaged Requires traige label Oct 2, 2024
@manfredlift
Copy link

I am interested in the same for JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged Requires traige
Projects
None yet
Development

No branches or pull requests

2 participants