Skip to content

Language Support

Bazelle provides support for multiple programming languages through Gazelle extensions. Each language extension must be explicitly enabled (except Go and Proto which are enabled by default).

Registered Languages

Go

Built-in Gazelle support for go_library, go_binary, and go_test rules. Enabled by default. Learn more →

Kotlin

Custom extension for kt_jvm_library and kt_jvm_test. Requires Maven-style layout. Learn more →

Python

Custom extension for py_library, py_binary, and py_test. Detects if __name__ == "__main__": blocks. Learn more →

C/C++

Via gazelle_cc for cc_library, cc_binary, and cc_test. Learn more →

Status Overview

LanguageRegisteredDefaultRules Generated
Go✅ YesEnabledgo_library, go_binary, go_test
Proto✅ YesEnabledproto_library, go_proto_library
Kotlin✅ YesDisabledkt_jvm_library, kt_jvm_test
Python✅ YesDisabledpy_library, py_binary, py_test
C/C++✅ YesDisabledcc_library, cc_binary, cc_test
Groovy✅ YesDisabledgroovy_library, groovy_test
Java❌ NoBlocked on Bazel 9 compatibility
Scala❌ NoPlanned
Rust❌ NoBlocked on proto dependencies

How It Works

Bazelle runs all enabled language extensions on your codebase. Each extension:

  1. Scans source files to detect language-specific patterns
  2. Parses files to extract imports and dependencies
  3. Generates appropriate BUILD rules with correct deps and srcs

Language Detection

When you run bazelle init, it detects languages by scanning for file extensions:

ExtensionsLanguage
.goGo
.kt, .ktsKotlin
.javaJava
.pyPython
.protoProto
.groovyGroovy
.cc, .cpp, .cxx, .c, .h, .hpp, .hxxC/C++

Ignored directories: bazel-*, .*, node_modules, __pycache__, vendor

Enabling Languages

Enable languages via BUILD file directives:

# In your root BUILD.bazel
# Enable Kotlin
# gazelle:kotlin_enabled true
# Enable Python
# gazelle:python_enabled true
# Enable Groovy
# gazelle:groovy_enabled true

Or filter at runtime:

Terminal window
# Only run Go and Kotlin extensions
bazelle update --languages go,kotlin