javaconfig

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// JavaExcludeArtifact tells the resolver to disregard a given maven artifact.
	// Can be repeated.
	JavaExcludeArtifact = "java_exclude_artifact"

	// JavaExtensionDirective represents the directive that controls whether
	// this Java extension is enabled or not. Sub-packages inherit this value.
	// Can be either "enabled" or "disabled". Defaults to "enabled".
	JavaExtensionDirective = "java_extension"

	// JavaMavenInstallFile represents the directive that controls where the
	// maven_install.json file is located.
	// Defaults to "maven_install.json".
	JavaMavenInstallFile = "java_maven_install_file"

	// MavenIndexFile represents the directive that controls where the index
	// file generated by `rules_jvm_external` is located.
	// Defaults to "maven_index.json"
	MavenIndexFile = "maven_index_file"

	// JavaModuleGranularityDirective represents the directive that controls whether
	// this Java module has a module granularity (Gradle) or a package
	// granularity (bazel).
	// Can be either "package" or "module". Defaults to "package".
	JavaModuleGranularityDirective = "java_module_granularity"

	// JavaTestFileSuffixes indicates within a test directory which files are test classes vs utility classes,
	// based on their basename.
	// It should be set up to match the value used for java_test_suite's test_suffixes attribute.
	// Accepted values are a comma-delimited list of strings.
	JavaTestFileSuffixes = "java_test_file_suffixes"

	// JavaTestMode allows user to choose from per file test or per directory test suite.
	JavaTestMode = "java_test_mode"

	// JavaGenerateProto tells the code generator whether to generate `java_proto_library` (and `java_library`)
	// rules when a `proto_library` rule is present.
	// Can be either "true" or "false". Defaults to "true".
	JavaGenerateProto = "java_generate_proto"

	// JavaGenerateProtoServices tells the code generator whether to generate `java_grpc_library`
	// rules when a `proto_library` rule with services is present.
	// Can be either "true" or "false". Defaults to "true".
	JavaGenerateProtoServices = "java_generate_proto_services"

	// JavaMavenRepositoryName tells the code generator what the repository name that contains all maven dependencies is.
	// Defaults to "maven"
	JavaMavenRepositoryName = "java_maven_repository_name"

	// JavaAnnotationProcessorPlugin tells the code generator about specific java_plugin targets needed to process
	// specific annotations.
	JavaAnnotationProcessorPlugin = "java_annotation_processor_plugin"

	// JavaResolveToJavaExports tells the code generator to favour resolving dependencies to java_exports where possible.
	// If enabled, generated libraries will try to depend on java_exports targets that export a given package, instead of the underlying library.
	// This allows monorepos to closely match a traditional Gradle/Maven model where subprojects are published in jars.
	// Can be either "true" or "false". Defaults to "true".
	// Inherited by children packages, can only be set at the root of the repository.
	JavaResolveToJavaExports = "java_resolve_to_java_exports"

	// JavaSourcesetRoot explicitly marks a directory as the root of a sourceset.
	// This provides a clear override to the auto-detection algorithm.
	// Example: # gazelle:java_sourceset_root my/custom/src
	JavaSourcesetRoot = "java_sourceset_root"

	// JavaStripResourcesPrefix overrides the path-stripping behavior for resources.
	// This is a direct way to specify the resource_strip_prefix for all resources in a directory.
	// Example: # gazelle:java_strip_resources_prefix my/data/config
	JavaStripResourcesPrefix = "java_strip_resources_prefix"

	//JavaGenerateBinary tells the code generator to generate the `java_binary` rules
	// Can be either "true" or "false". Defaults to "true"
	JavaGenerateBinary = "java_generate_binary"

	// JvmKotlinEnabled tells the code generator whether to support `kt_jvm_library` rules for Kotlin sources.
	// Can be either "true" or "false". Defaults to "true".
	// This requires importing the `@rules_kotlin` repository into your workspace if there are any Kotlin sources in the repo.
	JvmKotlinEnabled = "jvm_kotlin_enabled"

	// Tells the code generator to generate `pkg_files` rules for the resources directories
	JavaGenerateResources = "java_generate_resources"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents a config extension for a specific Bazel package.

func New

func New(repoRoot string) *Config

New creates a new Config.

func (*Config) AddAnnotationProcessorPlugin added in v0.26.0

func (c *Config) AddAnnotationProcessorPlugin(annotationClass types.ClassName, processorClass types.ClassName)

func (*Config) AddExcludedArtifact added in v0.10.0

func (c *Config) AddExcludedArtifact(s string) error

func (*Config) AttributesForAnnotation added in v0.6.0

func (c *Config) AttributesForAnnotation(annotation string) (map[string]bzl.Expr, bool)

func (*Config) CanSetResolveToJavaExports added in v0.30.0

func (c *Config) CanSetResolveToJavaExports() bool

func (Config) ExcludedArtifacts added in v0.10.0

func (c Config) ExcludedArtifacts() map[string]struct{}

func (*Config) ExtensionEnabled added in v0.6.0

func (c *Config) ExtensionEnabled() bool

ExtensionEnabled returns whether the extension is enabled or not.

func (*Config) GenerateBinary added in v0.31.0

func (c *Config) GenerateBinary() bool

func (*Config) GenerateProto added in v0.14.0

func (c *Config) GenerateProto() bool

func (*Config) GenerateProtoServices added in v0.33.0

func (c *Config) GenerateProtoServices() bool

func (*Config) GenerateResources added in v0.32.0

func (c *Config) GenerateResources() bool

func (*Config) GetAnnotationProcessorPluginClasses added in v0.26.0

func (c *Config) GetAnnotationProcessorPluginClasses(annotationClass types.ClassName) *sorted_set.SortedSet[types.ClassName]

func (*Config) GetCustomJavaTestFileSuffixes added in v0.10.0

func (c *Config) GetCustomJavaTestFileSuffixes() *[]string

func (*Config) IsJavaTestFile added in v0.10.0

func (c *Config) IsJavaTestFile(basename string) bool

func (Config) IsModuleRoot

func (c Config) IsModuleRoot() bool

func (*Config) IsTestRule added in v0.24.0

func (c *Config) IsTestRule(ruleKind string) bool

func (*Config) KotlinEnabled added in v0.31.0

func (c *Config) KotlinEnabled() bool

func (*Config) MapAnnotationToAttribute added in v0.6.0

func (c *Config) MapAnnotationToAttribute(annotation string, key string, value bzl.Expr)

func (*Config) MapAnnotationToWrapper added in v0.24.0

func (c *Config) MapAnnotationToWrapper(annotation string, wrapper string)

func (Config) MavenIndexFile added in v0.33.0

func (c Config) MavenIndexFile() string

func (Config) MavenInstallFile

func (c Config) MavenInstallFile() string

func (*Config) MavenRepositoryName added in v0.18.0

func (c *Config) MavenRepositoryName() string

func (Config) ModuleGranularity

func (c Config) ModuleGranularity() string

func (*Config) NewChild

func (c *Config) NewChild() *Config

NewChild creates a new child Config. It inherits desired values from the current Config and sets itself as the parent to the child.

func (*Config) ResolveToJavaExports added in v0.30.0

func (c *Config) ResolveToJavaExports() bool

func (*Config) SetExtensionEnabled added in v0.6.0

func (c *Config) SetExtensionEnabled(enabled bool)

SetExtensionEnabled sets whether the extension is enabled or not.

func (*Config) SetGenerateBinary added in v0.31.0

func (c *Config) SetGenerateBinary(generate bool)

func (*Config) SetGenerateProto added in v0.14.0

func (c *Config) SetGenerateProto(generate bool)

func (*Config) SetGenerateProtoServices added in v0.33.0

func (c *Config) SetGenerateProtoServices(generate bool)

func (*Config) SetGenerateResources added in v0.32.0

func (c *Config) SetGenerateResources(enabled bool)

func (*Config) SetJavaTestFileSuffixes added in v0.10.0

func (c *Config) SetJavaTestFileSuffixes(suffixesString string) error

func (*Config) SetKotlinEnabled added in v0.31.0

func (c *Config) SetKotlinEnabled(enabled bool)

func (*Config) SetMavenIndexFile added in v0.33.0

func (c *Config) SetMavenIndexFile(filename string)

func (*Config) SetMavenInstallFile

func (c *Config) SetMavenInstallFile(filename string)

func (*Config) SetMavenRepositoryName added in v0.18.0

func (c *Config) SetMavenRepositoryName(name string)

func (*Config) SetModuleGranularity

func (c *Config) SetModuleGranularity(granularity string) error

func (*Config) SetResolveToJavaExports added in v0.30.0

func (c *Config) SetResolveToJavaExports(resolve bool)

func (*Config) SetSourcesetRoot added in v0.31.0

func (c *Config) SetSourcesetRoot(root string)

func (*Config) SetStripResourcesPrefix added in v0.31.0

func (c *Config) SetStripResourcesPrefix(prefix string)

func (*Config) SetTestMode

func (c *Config) SetTestMode(mode string) error

func (*Config) SourcesetRoot added in v0.31.0

func (c *Config) SourcesetRoot() string

func (*Config) StripResourcesPrefix added in v0.31.0

func (c *Config) StripResourcesPrefix() string

func (Config) TestMode

func (c Config) TestMode() string

func (*Config) WrapperForAnnotation added in v0.24.0

func (c *Config) WrapperForAnnotation(annotation string) (string, bool)

type Configs

type Configs map[string]*Config

Configs is an extension of map[string]*Config. It provides finding methods on top of the mapping.

func (*Configs) ParentForPackage

func (c *Configs) ParentForPackage(pkg string) *Config

ParentForPackage returns the parent Config for the given Bazel package.

type LoadInfo added in v0.6.0

type LoadInfo struct {
	From   string
	Symbol string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL