From e3febd04db757b775172ffb3c63307acff316ca8 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 4 Aug 2023 07:03:08 -0700 Subject: [PATCH 1/9] docs: add directives help topic as docs guide (#3044) I'm not sure if we have to reference this somewhere to get it onto the site? Where are the .md files converted to HTML? Just copying the directives.md might be fine for now, but I think this could also use some re-arranging and organizing. It's quite confusing what should go into: * [guides/configure.md](https://github.com/aspect-build/silo/blob/main/docs/versioned/cli/commands/aspect_configure.md) * [commands/configure.md](https://github.com/aspect-build/silo/blob/main/docs/versioned/cli/commands/aspect_configure.md) * [help/topics/directives.md](cli/core/docs/help/topics/directives.md) Currently information is spread and a bit duplicated across all of those, and it's unclear which direction thing should be linking etc. --------- Co-authored-by: Jason Bedard Co-authored-by: Alex Eagle GitOrigin-RevId: a6f3b2503be36b1d512495ea1564153b416c17d9 --- cmd/aspect/configure/configure.go | 4 ++++ cmd/aspect/root/BUILD.bazel | 2 +- cmd/aspect/root/root.go | 4 ++-- docs/help/topics/directives.md | 34 +++++++++++++++++++++++++++++-- gazelle/js/config.go | 2 +- pkg/plugin/sdk/v1alpha3/README.md | 2 +- pkg/plugin/sdk/v1alpha4/README.md | 2 +- 7 files changed, 42 insertions(+), 8 deletions(-) diff --git a/cmd/aspect/configure/configure.go b/cmd/aspect/configure/configure.go index 1fcc6be2e..4b8b8b95b 100644 --- a/cmd/aspect/configure/configure.go +++ b/cmd/aspect/configure/configure.go @@ -53,6 +53,10 @@ configure is based on [gazelle]. We are very grateful to the authors of that sof The advantage of configure in Aspect CLI is that you don't need to compile the tooling before running it. [gazelle]: https://github.com/bazelbuild/bazel-gazelle + +To change the behavior of configure, you add "directives" to your BUILD files, which are comments +in a special syntax. +Run 'aspect help directives' or see https://docs.aspect.build/v/cli/help/directives for more info. `, GroupID: "aspect", RunE: interceptors.Run( diff --git a/cmd/aspect/root/BUILD.bazel b/cmd/aspect/root/BUILD.bazel index cd11b19bb..e5e53747f 100644 --- a/cmd/aspect/root/BUILD.bazel +++ b/cmd/aspect/root/BUILD.bazel @@ -33,10 +33,10 @@ go_library( "//cmd/aspect/sync", "//cmd/aspect/test", "//cmd/aspect/version", - "//docs/help/topics", "//pkg/aspect/root/flags", "//pkg/ioutils", "//pkg/plugin/system", + "//docs/help/topics", "@com_github_fatih_color//:color", "@com_github_mattn_go_isatty//:go-isatty", "@com_github_spf13_cobra//:cobra", diff --git a/cmd/aspect/root/root.go b/cmd/aspect/root/root.go index 71fa0d747..6f11f7310 100644 --- a/cmd/aspect/root/root.go +++ b/cmd/aspect/root/root.go @@ -51,10 +51,10 @@ import ( "aspect.build/cli/cmd/aspect/sync" "aspect.build/cli/cmd/aspect/test" "aspect.build/cli/cmd/aspect/version" - "aspect.build/cli/docs/help/topics" "aspect.build/cli/pkg/aspect/root/flags" "aspect.build/cli/pkg/ioutils" "aspect.build/cli/pkg/plugin/system" + help_docs "github.com/aspect-build/silo/docs/help/topics" ) var ( @@ -168,7 +168,7 @@ func NewCmd( } func mustReadFile(f string) string { - result, err := topics.Content.ReadFile(f) + result, err := help_docs.Content.ReadFile(f) if err != nil { panic(fmt.Errorf("Internal error: embed data was not readable: %w", err)) } diff --git a/docs/help/topics/directives.md b/docs/help/topics/directives.md index 5c76f55e9..ff853177e 100644 --- a/docs/help/topics/directives.md +++ b/docs/help/topics/directives.md @@ -6,11 +6,39 @@ within the Bazel package rooted at that file. ## Go -Go directives for generating BUILD files are from the standard [gazelle go plugin](https://github.com/bazelbuild/bazel-gazelle#directives). +Go directives for generating BUILD files are from the standard [gazelle directives]. ## JavaScript -JavaScript directives for generating BUILD files follow the same format as [gazelle](https://github.com/bazelbuild/bazel-gazelle). In addition to the generic directives from the [standard gazelle directives](https://github.com/bazelbuild/bazel-gazelle#directives) JavaScript (and TypeScript) specific directives are as follows: +JavaScript directives for generating BUILD files follow the same format as gazelle. +You can use generic directives from the [gazelle directives], as well as the following JS/TS +specific directives. + +TypeScript source files are those ending in `.ts`, `.tsx` as well as `.js`, `.mjs`. +Test source files are source files ending with `.spec.ts` (and other ts extensions). +The test file pattern can be configured with the 'js*test*\*' directives. + +By default `aspect configure` creates new BUILD files for each directory containing source files. +This can be configured to only edit existing BUILD files using the `js_generation_mode` directive. + +Each BUILD file may have a `ts_project` rule for sources, another for tests, +a `npm_package` rule for pnpm workspace projects, and `npm_link_all_packages` for linking node_modules. +Which rules are configured depends on the source files and directives that apply. + +Next, all source files are collected into the `srcs` of the `ts_project`, +either the primary rule or tests rule. + +Finally, the `import` statements in the source files are parsed, and +dependencies are added to the `deps` attribute of the appropriate +`ts_project` rule which the source file belongs to. + +Dependencies may also be found other ways such as from the CommonJS `require` function. + +If a `package.json` file exists declaring npm dependencies, a `npm_link_all_packages` rule +is generated for declaring depending on individual NPM packages. + +If the `package.json` is a pnpm workspace project a `npm_package` rule may be generated to +enable other projects to declare dependencies on the package. | **Directive** | **Default value** | @@ -40,3 +68,5 @@ JavaScript directives for generating BUILD files follow the same format as [gaze | `# gazelle:js_tsconfig _filename_` | `tsconfig.json` | | Path to a `tsconfig.json` file used to help generate TypeScript rules.
This value is inherited by sub-directories and applied relative to each BUILD.
The `ts_project(tsconfig)` attribute is *NOT* set and must be done manually if necessary | + +[gazelle directives]: https://github.com/bazelbuild/bazel-gazelle#directives diff --git a/gazelle/js/config.go b/gazelle/js/config.go index 032158a52..9d02ee79b 100644 --- a/gazelle/js/config.go +++ b/gazelle/js/config.go @@ -13,7 +13,7 @@ import ( "github.com/emirpasic/gods/sets/treeset" ) -// Directives. Keep in sync with documentation in cli/core/docs/help/topics/directives.md +// Directives. Keep in sync with documentation in /docs/help/topics/directives.md const ( // Directive_TypeScriptExtension represents the directive that controls whether // this TypeScript generation is enabled or not. Sub-packages inherit this value. diff --git a/pkg/plugin/sdk/v1alpha3/README.md b/pkg/plugin/sdk/v1alpha3/README.md index e31142163..d80dabcb5 100644 --- a/pkg/plugin/sdk/v1alpha3/README.md +++ b/pkg/plugin/sdk/v1alpha3/README.md @@ -2,4 +2,4 @@ This is the SDK for creating plugins for the Aspect CLI using the Go language. -See https://aspect-build.github.io/aspect-cli/help/topics/plugins +See https://docs.aspect.build/v/cli/plugins diff --git a/pkg/plugin/sdk/v1alpha4/README.md b/pkg/plugin/sdk/v1alpha4/README.md index 0e348fb44..5bf9e6031 100644 --- a/pkg/plugin/sdk/v1alpha4/README.md +++ b/pkg/plugin/sdk/v1alpha4/README.md @@ -2,4 +2,4 @@ This is the SDK for creating plugins for the Aspect CLI using the Go language. -See https://aspect-build.github.io/aspect-cli/help/topics/plugins +See https://docs.aspect.build/v/cli/plugins From 3f712fe1a57fdf78a97abb9f1e56e71aec77fac5 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 4 Aug 2023 07:17:18 -0700 Subject: [PATCH 2/9] docs: add gazelle extensions READMEs (#3034) Anything else you can think of to add now? --------- Co-authored-by: Alex Eagle GitOrigin-RevId: 0ef391edfcdb89ed24e253b27cde85301f215c6e --- gazelle/js/README.md | 20 ++++++++++++++++++++ gazelle/kotlin/README.md | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 gazelle/js/README.md create mode 100644 gazelle/kotlin/README.md diff --git a/gazelle/js/README.md b/gazelle/js/README.md new file mode 100644 index 000000000..75f660f7e --- /dev/null +++ b/gazelle/js/README.md @@ -0,0 +1,20 @@ +# JavaScript/TypeScript BUILD file generation + +This package automates the creation and maintenance of BUILD files for JavaScript and TypeScript, using [rules_js](https://github.com/aspect-build/rules_js) and [rules_ts](https://github.com/aspect-build/rules_ts). It is a [Gazelle](https://github.com/bazelbuild/bazel-gazelle) `Language` implementation. + +## Usage + +This feature is included in the [Aspect CLI](https://github.com/aspect-build/aspect-cli), accessed with the [`configure` command](https://docs.aspect.build/v/cli/commands/aspect_configure). +It's also possible to build into your own Gazelle binary. + +## Rules + +Generated targets include: + +- `ts_project` targets for source, tests, and custom targets and their ts/js/npm dependencies +- `npm_package` targets for projects within a pnpm workspace +- `npm_link_all_packages` for linking npm packages + +### Directives + +See [Aspect CLI Directives](/cli/core/docs/help/topics/directives.md#JavaScript) for a list of supported directives. diff --git a/gazelle/kotlin/README.md b/gazelle/kotlin/README.md new file mode 100644 index 000000000..68d080de8 --- /dev/null +++ b/gazelle/kotlin/README.md @@ -0,0 +1,5 @@ +# Kotlin Gazelle Extension + +EXPERIMENTAL: This is a work in progress and is not yet ready for use. Work is ongoing including upcoming support for rules_jvm maven dependencies. + +This is a [Gazelle](https://github.com/bazelbuild/bazel-gazelle) `Language` implementation for Kotlin using the [rules_kotlin](https://github.com/bazelbuild/rules_kotlin) `jvm` rules. From dde3bbd5e0a7a7358541c957e6cd1c08570bebf9 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 4 Aug 2023 16:06:32 -0700 Subject: [PATCH 3/9] feat(gazelle): generate kt_jvm_binary targets (#2990) GitOrigin-RevId: 762169dfe192a8c5ac31f269fe59908f335ea078 --- gazelle/kotlin/BUILD.bazel | 1 + gazelle/kotlin/generate.go | 50 +++++++++++++-- gazelle/kotlin/kotlin.go | 64 ++++++++++++++----- gazelle/kotlin/language.go | 13 ++++ gazelle/kotlin/parser/parser.go | 6 ++ gazelle/kotlin/parser/parser_test.go | 24 +++++++ gazelle/kotlin/resolver.go | 40 +++++++----- gazelle/kotlin/tests/bin/BUILD.in | 0 gazelle/kotlin/tests/bin/BUILD.out | 19 ++++++ gazelle/kotlin/tests/bin/Hello.kt | 3 + gazelle/kotlin/tests/bin/PkgHello.kt | 7 ++ gazelle/kotlin/tests/bin/WORKSPACE | 2 + gazelle/kotlin/tests/bin/lib.kt | 5 ++ gazelle/kotlin/tests/local_deps/BUILD.in | 1 + gazelle/kotlin/tests/local_deps/BUILD.out | 4 +- .../tests/local_deps/{main.kt => root.kt} | 6 +- gazelle/kotlin/tests/native_deps/BUILD.out | 2 +- .../tests/native_deps/{main.kt => lib.kt} | 2 +- gazelle/kotlin/tests/simple_file/BUILD.out | 4 +- .../tests/simple_file/{main.kt => lib.kt} | 2 +- .../tests/simple_file/{mains.kts => libs.kts} | 2 +- gazelle/kotlin/tests/unknown_imports/BUILD.in | 1 + .../kotlin/tests/unknown_imports/BUILD.out | 10 ++- .../tests/unknown_imports/expectedStdout.txt | 4 ++ gazelle/kotlin/tests/unknown_imports/lib.kt | 5 ++ 25 files changed, 229 insertions(+), 48 deletions(-) create mode 100644 gazelle/kotlin/tests/bin/BUILD.in create mode 100644 gazelle/kotlin/tests/bin/BUILD.out create mode 100644 gazelle/kotlin/tests/bin/Hello.kt create mode 100644 gazelle/kotlin/tests/bin/PkgHello.kt create mode 100644 gazelle/kotlin/tests/bin/WORKSPACE create mode 100644 gazelle/kotlin/tests/bin/lib.kt rename gazelle/kotlin/tests/local_deps/{main.kt => root.kt} (54%) rename gazelle/kotlin/tests/native_deps/{main.kt => lib.kt} (95%) rename gazelle/kotlin/tests/simple_file/{main.kt => lib.kt} (79%) rename gazelle/kotlin/tests/simple_file/{mains.kts => libs.kts} (79%) create mode 100644 gazelle/kotlin/tests/unknown_imports/lib.kt diff --git a/gazelle/kotlin/BUILD.bazel b/gazelle/kotlin/BUILD.bazel index 1193bfa81..bff56173e 100644 --- a/gazelle/kotlin/BUILD.bazel +++ b/gazelle/kotlin/BUILD.bazel @@ -31,6 +31,7 @@ go_library( "@bazel_gazelle//resolve:go_default_library", "@bazel_gazelle//rule:go_default_library", "@com_github_bazel_contrib_rules_jvm//java/gazelle/javaconfig", + "@com_github_emirpasic_gods//maps/treemap", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", ], diff --git a/gazelle/kotlin/generate.go b/gazelle/kotlin/generate.go index 2ceb4b48f..67ac8db76 100644 --- a/gazelle/kotlin/generate.go +++ b/gazelle/kotlin/generate.go @@ -5,6 +5,7 @@ import ( "math" "os" "path" + "strings" "sync" gazelle "aspect.build/cli/gazelle/common" @@ -14,6 +15,7 @@ import ( "github.com/bazelbuild/bazel-gazelle/language" "github.com/bazelbuild/bazel-gazelle/resolve" "github.com/bazelbuild/bazel-gazelle/rule" + "github.com/emirpasic/gods/maps/treemap" "github.com/emirpasic/gods/sets/treeset" ) @@ -34,13 +36,25 @@ func (kt *kotlinLang) GenerateRules(args language.GenerateArgs) language.Generat // Collect all source files. sourceFiles := kt.collectSourceFiles(cfg, args) - // TODO: multiple targets (lib, test, ...) - target := NewKotlinTarget() + // TODO: multiple library targets (lib, test, ...) + libTarget := NewKotlinLibTarget() + binTargets := treemap.NewWithStringComparator() // Parse all source files and group information into target(s) for p := range kt.parseFiles(args, sourceFiles) { - target.Files.Add(p.File) - target.Packages.Add(p.Package) + var target *KotlinTarget + + if p.HasMain { + binTarget := NewKotlinBinTarget(p.File, p.Package) + binTargets.Put(p.File, binTarget) + + target = &binTarget.KotlinTarget + } else { + libTarget.Files.Add(p.File) + libTarget.Packages.Add(p.Package) + + target = &libTarget.KotlinTarget + } for _, impt := range p.Imports { target.Imports.Add(ImportStatement{ @@ -55,14 +69,19 @@ func (kt *kotlinLang) GenerateRules(args language.GenerateArgs) language.Generat var result language.GenerateResult - targetName := gazelle.ToDefaultTargetName(args, "root") + libTargetName := gazelle.ToDefaultTargetName(args, "root") + kt.addLibraryRule(libTargetName, libTarget, args, false, &result) - kt.addLibraryRule(targetName, target, args, false, &result) + for _, v := range binTargets.Values() { + binTarget := v.(*KotlinBinTarget) + binTargetName := toBinaryTargetName(binTarget.File) + kt.addBinaryRule(binTargetName, binTarget, args, &result) + } return result } -func (kt *kotlinLang) addLibraryRule(targetName string, target *KotlinTarget, args language.GenerateArgs, isTestRule bool, result *language.GenerateResult) { +func (kt *kotlinLang) addLibraryRule(targetName string, target *KotlinLibTarget, args language.GenerateArgs, isTestRule bool, result *language.GenerateResult) { // TODO: check for rule collisions // Generate nothing if there are no source files. Remove any existing rules. @@ -96,6 +115,23 @@ func (kt *kotlinLang) addLibraryRule(targetName string, target *KotlinTarget, ar BazelLog.Infof("add rule '%s' '%s:%s'", ktLibrary.Kind(), args.Rel, ktLibrary.Name()) } +func (kt *kotlinLang) addBinaryRule(targetName string, target *KotlinBinTarget, args language.GenerateArgs, result *language.GenerateResult) { + main_class := strings.TrimSuffix(target.File, ".kt") + if target.Package != "" { + main_class = target.Package + "." + main_class + } + + ktBinary := rule.NewRule(KtJvmBinary, targetName) + ktBinary.SetAttr("srcs", []string{target.File}) + ktBinary.SetAttr("main_class", main_class) + ktBinary.SetPrivateAttr(packagesKey, target) + + result.Gen = append(result.Gen, ktBinary) + result.Imports = append(result.Imports, target) + + BazelLog.Infof("add rule '%s' '%s:%s'", ktBinary.Kind(), args.Rel, ktBinary.Name()) +} + // TODO: put in common? func (kt *kotlinLang) parseFiles(args language.GenerateArgs, sources *treeset.Set) chan *parser.ParseResult { // The channel of all files to parse. diff --git a/gazelle/kotlin/kotlin.go b/gazelle/kotlin/kotlin.go index 9f289720b..dd43e3de7 100644 --- a/gazelle/kotlin/kotlin.go +++ b/gazelle/kotlin/kotlin.go @@ -1,39 +1,73 @@ package gazelle -import "strings" +import ( + "path" + "strings" +) + import "github.com/emirpasic/gods/sets/treeset" func IsNativeImport(impt string) bool { return strings.HasPrefix(impt, "kotlin.") || strings.HasPrefix(impt, "kotlinx.") || strings.HasPrefix(impt, "java.") || strings.HasPrefix(impt, "javax.") } +type KotlinTarget struct { + Imports *treeset.Set +} + /** * Information for kotlin library target including: - * - BUILD package name + * - kotlin files * - kotlin import statements from all files * - kotlin packages implemented - * - kotlin files with main() methods */ -type KotlinTarget struct { - Name string +type KotlinLibTarget struct { + KotlinTarget - Imports *treeset.Set Packages *treeset.Set - - Mains *treeset.Set - - Files *treeset.Set + Files *treeset.Set } -func NewKotlinTarget() *KotlinTarget { - return &KotlinTarget{ - Imports: treeset.NewWith(importStatementComparator), +func NewKotlinLibTarget() *KotlinLibTarget { + return &KotlinLibTarget{ + KotlinTarget: KotlinTarget{ + Imports: treeset.NewWith(importStatementComparator), + }, Packages: treeset.NewWithStringComparator(), - Mains: treeset.NewWithStringComparator(), Files: treeset.NewWithStringComparator(), } } +/** + * Information for kotlin binary (main() method) including: + * - kotlin import statements from all files + * - the package + * - the file + */ +type KotlinBinTarget struct { + KotlinTarget + + File string + Package string +} + +func NewKotlinBinTarget(file, pkg string) *KotlinBinTarget { + return &KotlinBinTarget{ + KotlinTarget: KotlinTarget{ + Imports: treeset.NewWith(importStatementComparator), + }, + File: file, + Package: pkg, + } +} + // packagesKey is the name of a private attribute set on generated kt_library // rules. This attribute contains the KotlinTarget for the target. -const packagesKey = "_java_packages" +const packagesKey = "_kotlin_package" + +func toBinaryTargetName(mainFile string) string { + base := strings.ToLower(strings.TrimSuffix(path.Base(mainFile), path.Ext(mainFile))) + + // TODO: move target name template to directive + return base + "_bin" +} diff --git a/gazelle/kotlin/language.go b/gazelle/kotlin/language.go index abd3ab93c..fcec59345 100644 --- a/gazelle/kotlin/language.go +++ b/gazelle/kotlin/language.go @@ -13,6 +13,7 @@ const LanguageName = "kotlin" const ( KtJvmLibrary = "kt_jvm_library" + KtJvmBinary = "kt_jvm_binary" RulesKotlinRepositoryName = "io_bazel_rules_kotlin" ) @@ -61,6 +62,17 @@ var kotlinKinds = map[string]rule.KindInfo{ "deps": true, }, }, + + KtJvmBinary: { + MatchAny: false, + NonEmptyAttrs: map[string]bool{ + "srcs": true, + "main_class": true, + }, + SubstituteAttrs: map[string]bool{}, + MergeableAttrs: map[string]bool{}, + ResolveAttrs: map[string]bool{}, + }, } var kotlinLoads = []rule.LoadInfo{ @@ -68,6 +80,7 @@ var kotlinLoads = []rule.LoadInfo{ Name: "@" + RulesKotlinRepositoryName + "//kotlin:jvm.bzl", Symbols: []string{ KtJvmLibrary, + KtJvmBinary, }, }, } diff --git a/gazelle/kotlin/parser/parser.go b/gazelle/kotlin/parser/parser.go index b09291146..99fed7850 100644 --- a/gazelle/kotlin/parser/parser.go +++ b/gazelle/kotlin/parser/parser.go @@ -16,6 +16,7 @@ type ParseResult struct { File string Imports []string Package string + HasMain bool } type Parser interface { @@ -93,6 +94,11 @@ func (p *treeSitterParser) Parse(filePath, source string) (*ParseResult, []error } result.Package = readIdentifier(getLoneChild(nodeI, "identifier"), sourceCode, false) + } else if nodeI.Type() == "function_declaration" { + nodeJ := getLoneChild(nodeI, "simple_identifier") + if nodeJ.Content(sourceCode) == "main" { + result.HasMain = true + } } } diff --git a/gazelle/kotlin/parser/parser_test.go b/gazelle/kotlin/parser/parser_test.go index 130d787ca..ada6d1c5e 100644 --- a/gazelle/kotlin/parser/parser_test.go +++ b/gazelle/kotlin/parser/parser_test.go @@ -69,6 +69,30 @@ func TestTreesitterParser(t *testing.T) { } }) } + + t.Run("main detection", func(t *testing.T) { + res, _ := NewParser().Parse("main.kt", "fun main() {}") + if !res.HasMain { + t.Errorf("main method should be detected") + } + + res, _ = NewParser().Parse("x.kt", ` +package my.demo +fun main() {} + `) + if !res.HasMain { + t.Errorf("main method should be detected with package") + } + + res, _ = NewParser().Parse("x.kt", ` +package my.demo +import kotlin.text.* +fun main() {} + `) + if !res.HasMain { + t.Errorf("main method should be detected with imports") + } + }) } func equal[T comparable](a, b []T) bool { diff --git a/gazelle/kotlin/resolver.go b/gazelle/kotlin/resolver.go index 0bc420721..da077f8c3 100644 --- a/gazelle/kotlin/resolver.go +++ b/gazelle/kotlin/resolver.go @@ -47,22 +47,24 @@ func (*Resolver) Name() string { func (kt *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec { BazelLog.Debugf("Imports: '%s:%s'", f.Pkg, r.Name()) - target := r.PrivateAttr(packagesKey).(*KotlinTarget) - - provides := make([]resolve.ImportSpec, 0, target.Packages.Size()) - for _, pkg := range target.Packages.Values() { - provides = append(provides, resolve.ImportSpec{ - Lang: LanguageName, - Imp: pkg.(string), - }) - } + if r.PrivateAttr(packagesKey) != nil { + target, isLib := r.PrivateAttr(packagesKey).(*KotlinLibTarget) + if isLib { + provides := make([]resolve.ImportSpec, 0, target.Packages.Size()) + for _, pkg := range target.Packages.Values() { + provides = append(provides, resolve.ImportSpec{ + Lang: LanguageName, + Imp: pkg.(string), + }) + } - // TODO: why nil instead of just returning empty? - if len(provides) == 0 { - return nil + if len(provides) > 0 { + return provides + } + } } - return provides + return nil } func (kt *Resolver) Embeds(r *rule.Rule, from label.Label) []label.Label { @@ -73,8 +75,16 @@ func (kt *Resolver) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.Re start := time.Now() BazelLog.Infof("Resolve '%s' dependencies", from.String()) - if r.Kind() == KtJvmLibrary { - deps, err := kt.resolveImports(c, ix, importData.(*KotlinTarget).Imports, from) + if r.Kind() == KtJvmLibrary || r.Kind() == KtJvmBinary { + var target KotlinTarget + + if r.Kind() == KtJvmLibrary { + target = importData.(*KotlinLibTarget).KotlinTarget + } else { + target = importData.(*KotlinBinTarget).KotlinTarget + } + + deps, err := kt.resolveImports(c, ix, target.Imports, from) if err != nil { log.Fatal("Resolution Error: ", err) os.Exit(1) diff --git a/gazelle/kotlin/tests/bin/BUILD.in b/gazelle/kotlin/tests/bin/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/kotlin/tests/bin/BUILD.out b/gazelle/kotlin/tests/bin/BUILD.out new file mode 100644 index 000000000..5719f9738 --- /dev/null +++ b/gazelle/kotlin/tests/bin/BUILD.out @@ -0,0 +1,19 @@ +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary", "kt_jvm_library") + +kt_jvm_library( + name = "bin", + srcs = ["lib.kt"], +) + +kt_jvm_binary( + name = "hello_bin", + srcs = ["Hello.kt"], + main_class = "Hello", +) + +kt_jvm_binary( + name = "pkghello_bin", + srcs = ["PkgHello.kt"], + main_class = "foo.pkg.PkgHello", + deps = [":bin"], +) diff --git a/gazelle/kotlin/tests/bin/Hello.kt b/gazelle/kotlin/tests/bin/Hello.kt new file mode 100644 index 000000000..3708dd833 --- /dev/null +++ b/gazelle/kotlin/tests/bin/Hello.kt @@ -0,0 +1,3 @@ +fun main() { + println("Hello world!") +} \ No newline at end of file diff --git a/gazelle/kotlin/tests/bin/PkgHello.kt b/gazelle/kotlin/tests/bin/PkgHello.kt new file mode 100644 index 000000000..dc676e271 --- /dev/null +++ b/gazelle/kotlin/tests/bin/PkgHello.kt @@ -0,0 +1,7 @@ +package foo.pkg + +import test.lib.* + +fun main() { + println("Hello world from ", Constants.NAME) +} \ No newline at end of file diff --git a/gazelle/kotlin/tests/bin/WORKSPACE b/gazelle/kotlin/tests/bin/WORKSPACE new file mode 100644 index 000000000..d74158eba --- /dev/null +++ b/gazelle/kotlin/tests/bin/WORKSPACE @@ -0,0 +1,2 @@ +# This is a Bazel workspace for the Gazelle test data. +workspace(name = "bin") diff --git a/gazelle/kotlin/tests/bin/lib.kt b/gazelle/kotlin/tests/bin/lib.kt new file mode 100644 index 000000000..bb29d89d5 --- /dev/null +++ b/gazelle/kotlin/tests/bin/lib.kt @@ -0,0 +1,5 @@ +package test.lib + +object Constants { + const val NAME = "bin test" +} \ No newline at end of file diff --git a/gazelle/kotlin/tests/local_deps/BUILD.in b/gazelle/kotlin/tests/local_deps/BUILD.in index e69de29bb..a26f92563 100644 --- a/gazelle/kotlin/tests/local_deps/BUILD.in +++ b/gazelle/kotlin/tests/local_deps/BUILD.in @@ -0,0 +1 @@ +package(default_visibility = ["//visibility:public"]) \ No newline at end of file diff --git a/gazelle/kotlin/tests/local_deps/BUILD.out b/gazelle/kotlin/tests/local_deps/BUILD.out index 2771a1b97..896d1cb33 100644 --- a/gazelle/kotlin/tests/local_deps/BUILD.out +++ b/gazelle/kotlin/tests/local_deps/BUILD.out @@ -1,8 +1,10 @@ load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +package(default_visibility = ["//visibility:public"]) + kt_jvm_library( name = "local_deps", - srcs = ["main.kt"], + srcs = ["root.kt"], deps = [ "//impt", "//impt-star", diff --git a/gazelle/kotlin/tests/local_deps/main.kt b/gazelle/kotlin/tests/local_deps/root.kt similarity index 54% rename from gazelle/kotlin/tests/local_deps/main.kt rename to gazelle/kotlin/tests/local_deps/root.kt index 31d282317..a858fce06 100644 --- a/gazelle/kotlin/tests/local_deps/main.kt +++ b/gazelle/kotlin/tests/local_deps/root.kt @@ -4,7 +4,7 @@ package test.root import test.impt.Rectangle import test.imptstar.* -fun main() { - A.f() - Rectangle.f() +fun use_imports() { + Rectangle(1.0, 2.0) + Rectangle2(3.0, 4.0) } \ No newline at end of file diff --git a/gazelle/kotlin/tests/native_deps/BUILD.out b/gazelle/kotlin/tests/native_deps/BUILD.out index b86e26690..5887dbfb8 100644 --- a/gazelle/kotlin/tests/native_deps/BUILD.out +++ b/gazelle/kotlin/tests/native_deps/BUILD.out @@ -2,5 +2,5 @@ load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") kt_jvm_library( name = "native_deps", - srcs = ["main.kt"], + srcs = ["lib.kt"], ) diff --git a/gazelle/kotlin/tests/native_deps/main.kt b/gazelle/kotlin/tests/native_deps/lib.kt similarity index 95% rename from gazelle/kotlin/tests/native_deps/main.kt rename to gazelle/kotlin/tests/native_deps/lib.kt index ea003a853..feefcece5 100644 --- a/gazelle/kotlin/tests/native_deps/main.kt +++ b/gazelle/kotlin/tests/native_deps/lib.kt @@ -13,6 +13,6 @@ import kotlinx.serialization.json.Json as Jason @Serializable data class Data(val a: Int, val b: String) -fun main() { +fun other() { val json = Jason.encodeToString(Data(42, "str")) } \ No newline at end of file diff --git a/gazelle/kotlin/tests/simple_file/BUILD.out b/gazelle/kotlin/tests/simple_file/BUILD.out index addf541e1..270482690 100644 --- a/gazelle/kotlin/tests/simple_file/BUILD.out +++ b/gazelle/kotlin/tests/simple_file/BUILD.out @@ -3,7 +3,7 @@ load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") kt_jvm_library( name = "simple_file", srcs = [ - "main.kt", - "mains.kts", + "lib.kt", + "libs.kts", ], ) diff --git a/gazelle/kotlin/tests/simple_file/main.kt b/gazelle/kotlin/tests/simple_file/lib.kt similarity index 79% rename from gazelle/kotlin/tests/simple_file/main.kt rename to gazelle/kotlin/tests/simple_file/lib.kt index 4130457ff..1367bdf69 100644 --- a/gazelle/kotlin/tests/simple_file/main.kt +++ b/gazelle/kotlin/tests/simple_file/lib.kt @@ -1,5 +1,5 @@ // Hello World Program -fun main() { +fun hello() { println("Hello world!") } \ No newline at end of file diff --git a/gazelle/kotlin/tests/simple_file/mains.kts b/gazelle/kotlin/tests/simple_file/libs.kts similarity index 79% rename from gazelle/kotlin/tests/simple_file/mains.kts rename to gazelle/kotlin/tests/simple_file/libs.kts index 4130457ff..1367bdf69 100644 --- a/gazelle/kotlin/tests/simple_file/mains.kts +++ b/gazelle/kotlin/tests/simple_file/libs.kts @@ -1,5 +1,5 @@ // Hello World Program -fun main() { +fun hello() { println("Hello world!") } \ No newline at end of file diff --git a/gazelle/kotlin/tests/unknown_imports/BUILD.in b/gazelle/kotlin/tests/unknown_imports/BUILD.in index e69de29bb..a26f92563 100644 --- a/gazelle/kotlin/tests/unknown_imports/BUILD.in +++ b/gazelle/kotlin/tests/unknown_imports/BUILD.in @@ -0,0 +1 @@ +package(default_visibility = ["//visibility:public"]) \ No newline at end of file diff --git a/gazelle/kotlin/tests/unknown_imports/BUILD.out b/gazelle/kotlin/tests/unknown_imports/BUILD.out index 2d2af8416..5ac4ff47b 100644 --- a/gazelle/kotlin/tests/unknown_imports/BUILD.out +++ b/gazelle/kotlin/tests/unknown_imports/BUILD.out @@ -1,6 +1,14 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary", "kt_jvm_library") + +package(default_visibility = ["//visibility:public"]) kt_jvm_library( name = "simple_file", + srcs = ["lib.kt"], +) + +kt_jvm_binary( + name = "main_bin", srcs = ["main.kt"], + main_class = "main", ) diff --git a/gazelle/kotlin/tests/unknown_imports/expectedStdout.txt b/gazelle/kotlin/tests/unknown_imports/expectedStdout.txt index 7d8ea5bea..95d524094 100644 --- a/gazelle/kotlin/tests/unknown_imports/expectedStdout.txt +++ b/gazelle/kotlin/tests/unknown_imports/expectedStdout.txt @@ -1,3 +1,7 @@ +Resolution error Import "lib.not" from "lib.kt" is an unknown dependency. Possible solutions: + 1. Instruct Gazelle to resolve to a known dependency using a directive: + # gazelle:resolve [src-lang] kotlin import-string label + Resolution error Import "foo" from "main.kt" is an unknown dependency. Possible solutions: 1. Instruct Gazelle to resolve to a known dependency using a directive: # gazelle:resolve [src-lang] kotlin import-string label diff --git a/gazelle/kotlin/tests/unknown_imports/lib.kt b/gazelle/kotlin/tests/unknown_imports/lib.kt new file mode 100644 index 000000000..e70ea4e5d --- /dev/null +++ b/gazelle/kotlin/tests/unknown_imports/lib.kt @@ -0,0 +1,5 @@ +import lib.not.found + +fun lib() { + +} \ No newline at end of file From ec99c468d2e29c93e561d00d36a4270843941065 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 00:47:24 +0000 Subject: [PATCH 4/9] chore(deps): update dependency bazel to v6.3.1 (#3022) GitOrigin-RevId: 9d6f904f0c50ec48d81767b6b264db7b300327e0 --- integration_tests/bazel_binary.bzl | 10 ++++++++-- pkg/aspect/init/template/.bazelversion_ | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/integration_tests/bazel_binary.bzl b/integration_tests/bazel_binary.bzl index 66d516028..838f60ed6 100644 --- a/integration_tests/bazel_binary.bzl +++ b/integration_tests/bazel_binary.bzl @@ -23,12 +23,18 @@ BAZEL_VERSIONS = { "linux-arm64": "647ccd5269c12ba724aa041b10e3dad8d7a0cfeeae4b9eac3ebcaa0774e8fcac", "linux-x86_64": "d64606c17e6b6a7fc119150420b4c109315982319ff3229587e200c47bf36946", }, + "6.3.1": { + "darwin-arm64": "b31a3dd7d5cfa7eb25856075fe85ef6180d0a25499f8183a7bb85e5b88d6158b", + "darwin-x86_64": "49a6d5f96ce89a9cfb320378293de214df5a4ac22b002a978e1f8a23fb3ceb83", + "linux-arm64": "ac70546fd207a98d500f118f621c6e15f918786cb5f0a5bb9ca709b433fb5a9b", + "linux-x86_64": "81130d324e145dcf3192338b875669fe5f410fef26344985dd4cdcdb1c7cab5b", + }, } def _bazel_binary_impl(rctx): # TODO: make this configurable if needed in the future. - version = "6.3.0" - version_without_rc = "6.3.0" + version = "6.3.1" + version_without_rc = "6.3.1" release_type = "release" platform = repo_utils.platform(rctx).replace("_", "-").replace("amd64", "x86_64") diff --git a/pkg/aspect/init/template/.bazelversion_ b/pkg/aspect/init/template/.bazelversion_ index 798e38995..dc0208aba 100644 --- a/pkg/aspect/init/template/.bazelversion_ +++ b/pkg/aspect/init/template/.bazelversion_ @@ -1 +1 @@ -6.3.0 +6.3.1 From b50fa3a8d6258d7f9b7268984b0304398111f403 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Mon, 7 Aug 2023 18:22:49 -0700 Subject: [PATCH 5/9] feat(gazelle): add kotlin support for rules_jvm_external maven_install deps (#2998) GitOrigin-RevId: ed09073be587906135e32de4089a9c75ae1d45de --- gazelle/kotlin/BUILD.bazel | 12 +- gazelle/kotlin/configure.go | 32 +- gazelle/kotlin/kotlin.go | 18 +- gazelle/kotlin/kotlin_test.go | 27 ++ gazelle/kotlin/language.go | 4 + gazelle/kotlin/parser/parser.go | 2 +- gazelle/kotlin/resolver.go | 19 +- gazelle/kotlin/tests/native_deps/lib.kt | 12 + gazelle/kotlin/tests/rules_jvm-maven/BUILD.in | 1 + .../kotlin/tests/rules_jvm-maven/BUILD.out | 1 + .../kotlin/tests/rules_jvm-maven/README.md | 8 + .../kotlin/tests/rules_jvm-maven/WORKSPACE | 27 ++ .../tests/rules_jvm-maven/maven_install.json | 363 ++++++++++++++++++ .../main/java/com/example/compare/BUILD.in | 0 .../main/java/com/example/compare/BUILD.out | 8 + .../main/java/com/example/compare/Compare.kt | 17 + .../main/java/com/example/myproject/App.kt | 17 + .../main/java/com/example/myproject/BUILD.in | 0 .../main/java/com/example/myproject/BUILD.out | 8 + .../java/com/example/myproject/AppTest.kt | 14 + .../test/java/com/example/myproject/BUILD.in | 0 .../test/java/com/example/myproject/BUILD.out | 7 + 22 files changed, 587 insertions(+), 10 deletions(-) create mode 100644 gazelle/kotlin/kotlin_test.go create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/BUILD.in create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/BUILD.out create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/README.md create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/WORKSPACE create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/maven_install.json create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.in create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.out create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/Compare.kt create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/App.kt create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.in create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.out create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/AppTest.kt create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.in create mode 100644 gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.out diff --git a/gazelle/kotlin/BUILD.bazel b/gazelle/kotlin/BUILD.bazel index bff56173e..de0e456eb 100644 --- a/gazelle/kotlin/BUILD.bazel +++ b/gazelle/kotlin/BUILD.bazel @@ -1,5 +1,5 @@ load("@bazel_gazelle//:def.bzl", "gazelle_binary") -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") load("//gazelle:gazelle.bzl", "gazelle_generation_test") # Disable the kotlin extension @@ -31,9 +31,13 @@ go_library( "@bazel_gazelle//resolve:go_default_library", "@bazel_gazelle//rule:go_default_library", "@com_github_bazel_contrib_rules_jvm//java/gazelle/javaconfig", + "@com_github_bazel_contrib_rules_jvm//java/gazelle/private/java", + "@com_github_bazel_contrib_rules_jvm//java/gazelle/private/maven", + "@com_github_bazel_contrib_rules_jvm//java/gazelle/private/types", "@com_github_emirpasic_gods//maps/treemap", "@com_github_emirpasic_gods//sets/treeset", "@com_github_emirpasic_gods//utils", + "@com_github_rs_zerolog//:zerolog", ], ) @@ -53,3 +57,9 @@ gazelle_binary( ) for test_workspace in glob(["tests/**/WORKSPACE"]) ] + +go_test( + name = "kotlin_test", + srcs = ["kotlin_test.go"], + embed = [":kotlin"], +) diff --git a/gazelle/kotlin/configure.go b/gazelle/kotlin/configure.go index 3dc998354..ca6879ddc 100644 --- a/gazelle/kotlin/configure.go +++ b/gazelle/kotlin/configure.go @@ -5,15 +5,19 @@ import ( . "aspect.build/cli/gazelle/common/log" "aspect.build/cli/gazelle/kotlin/kotlinconfig" - "github.com/bazel-contrib/rules_jvm/java/gazelle/javaconfig" + jvm_javaconfig "github.com/bazel-contrib/rules_jvm/java/gazelle/javaconfig" + jvm_maven "github.com/bazel-contrib/rules_jvm/java/gazelle/private/maven" "github.com/bazelbuild/bazel-gazelle/config" "github.com/bazelbuild/bazel-gazelle/rule" + "github.com/rs/zerolog" ) type Configurer struct { config.Configurer lang *kotlinLang + + mavenInstallFile string } func NewConfigurer(lang *kotlinLang) *Configurer { @@ -24,7 +28,7 @@ func NewConfigurer(lang *kotlinLang) *Configurer { func (kt *Configurer) KnownDirectives() []string { return []string{ - javaconfig.JavaMavenInstallFile, + jvm_javaconfig.JavaMavenInstallFile, } } @@ -56,15 +60,35 @@ func (kt *Configurer) Configure(c *config.Config, rel string, f *rule.File) { for _, d := range f.Directives { switch d.Key { - // TODO: invoke java gazelle.Configure()? - case javaconfig.JavaMavenInstallFile: + // TODO: invoke java gazelle.Configure() to support all jvm directives? + // TODO: JavaMavenRepositoryName: https://github.com/bazel-contrib/rules_jvm/commit/e46bb11bedb2ead45309eae04619caca684f6243 + + case jvm_javaconfig.JavaMavenInstallFile: cfg.SetMavenInstallFile(d.Value) } } } + + if kt.lang.mavenResolver == nil { + BazelLog.Tracef("Creating Maven resolver: %s", cfg.MavenInstallFile()) + + // TODO: better zerolog configuration + logger := zerolog.New(BazelLog.Out).Level(zerolog.TraceLevel) + + resolver, err := jvm_maven.NewResolver( + cfg.MavenInstallFile(), + cfg.ExcludedArtifacts(), + logger, + ) + if err != nil { + BazelLog.Fatalln("error creating Maven resolver: %s", err.Error()) + } + kt.lang.mavenResolver = &resolver + } } func (kc *Configurer) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) { + // TODO: support rules_jvm flags such as 'java-maven-install-file'? (see rules_jvm java/gazelle/configure.go) } func (kc *Configurer) CheckFlags(fs *flag.FlagSet, c *config.Config) error { diff --git a/gazelle/kotlin/kotlin.go b/gazelle/kotlin/kotlin.go index dd43e3de7..017b7771f 100644 --- a/gazelle/kotlin/kotlin.go +++ b/gazelle/kotlin/kotlin.go @@ -7,8 +7,24 @@ import ( import "github.com/emirpasic/gods/sets/treeset" +import ( + jvm_java "github.com/bazel-contrib/rules_jvm/java/gazelle/private/java" + jvm_types "github.com/bazel-contrib/rules_jvm/java/gazelle/private/types" +) + func IsNativeImport(impt string) bool { - return strings.HasPrefix(impt, "kotlin.") || strings.HasPrefix(impt, "kotlinx.") || strings.HasPrefix(impt, "java.") || strings.HasPrefix(impt, "javax.") + if strings.HasPrefix(impt, "kotlin.") || strings.HasPrefix(impt, "kotlinx.") { + return true + } + + jvm_import := jvm_types.NewPackageName(impt) + + // Java native/standard libraries + if jvm_java.IsStdlib(jvm_import) { + return true + } + + return false } type KotlinTarget struct { diff --git a/gazelle/kotlin/kotlin_test.go b/gazelle/kotlin/kotlin_test.go new file mode 100644 index 000000000..43f54a7de --- /dev/null +++ b/gazelle/kotlin/kotlin_test.go @@ -0,0 +1,27 @@ +package gazelle + +import ( + "testing" +) + +func assertTrue(t *testing.T, b bool, msg string) { + if !b { + t.Error(msg) + } +} + +func TestKotlinNative(t *testing.T) { + t.Run("kotlin native libraries", func(t *testing.T) { + assertTrue(t, IsNativeImport("kotlin.io"), "kotlin.io should be native") + assertTrue(t, IsNativeImport("kotlinx.foo"), "kotlinx.* should be native") + }) + + t.Run("java native libraries", func(t *testing.T) { + assertTrue(t, IsNativeImport("java.foo"), "java.* should be native") + assertTrue(t, IsNativeImport("javax.accessibility"), "javax should be native") + assertTrue(t, IsNativeImport("javax.net"), "javax should be native") + assertTrue(t, IsNativeImport("javax.sql"), "javax should be native") + assertTrue(t, IsNativeImport("javax.xml"), "javax should be native") + assertTrue(t, IsNativeImport("org.xml.sax"), "org.xml.sax should be native") + }) +} diff --git a/gazelle/kotlin/language.go b/gazelle/kotlin/language.go index fcec59345..4703b48b4 100644 --- a/gazelle/kotlin/language.go +++ b/gazelle/kotlin/language.go @@ -2,6 +2,7 @@ package gazelle import ( "aspect.build/cli/gazelle/common/git" + jvm_maven "github.com/bazel-contrib/rules_jvm/java/gazelle/private/maven" "github.com/bazelbuild/bazel-gazelle/config" "github.com/bazelbuild/bazel-gazelle/label" "github.com/bazelbuild/bazel-gazelle/language" @@ -33,6 +34,9 @@ type kotlinLang struct { // Ignore configurations for the workspace. gitignore *git.GitIgnore + + // TODO: extend rules_jvm extension instead of duplicating? + mavenResolver *jvm_maven.Resolver } // NewLanguage initializes a new TypeScript that satisfies the language.Language diff --git a/gazelle/kotlin/parser/parser.go b/gazelle/kotlin/parser/parser.go index 99fed7850..74a537ff2 100644 --- a/gazelle/kotlin/parser/parser.go +++ b/gazelle/kotlin/parser/parser.go @@ -151,7 +151,7 @@ func readIdentifier(node *sitter.Node, sourceCode []byte, ignoreLast bool) strin } s.WriteString(nodeC.Content(sourceCode)) } else if nodeC.Type() != "comment" { - fmt.Printf("Unexpected node type: %v - %s", nodeC.Type(), nodeC.Content(sourceCode)) + fmt.Printf("Unexpected node type '%v' within: %s", nodeC.Type(), node.Content(sourceCode)) os.Exit(1) } } diff --git a/gazelle/kotlin/resolver.go b/gazelle/kotlin/resolver.go index da077f8c3..f484000b0 100644 --- a/gazelle/kotlin/resolver.go +++ b/gazelle/kotlin/resolver.go @@ -15,6 +15,8 @@ import ( "github.com/bazelbuild/bazel-gazelle/resolve" "github.com/bazelbuild/bazel-gazelle/rule" "github.com/emirpasic/gods/sets/treeset" + + jvm_types "github.com/bazel-contrib/rules_jvm/java/gazelle/private/types" ) type Resolver struct { @@ -146,7 +148,7 @@ func (kt *Resolver) resolveImport( ix *resolve.RuleIndex, impt ImportStatement, from label.Label, -) (ResolutionType, *label.Label, error) { +) (resType ResolutionType, resLabel *label.Label, err error) { imptSpec := impt.ImportSpec // Gazelle overrides @@ -188,9 +190,20 @@ func (kt *Resolver) resolveImport( return Resolution_NativeKotlin, nil, nil } - // TODO: maven imports + jvm_import := jvm_types.NewPackageName(impt.Imp) + + // Maven imports + if mavenResolver := kt.lang.mavenResolver; mavenResolver != nil { + if l, err := (*mavenResolver).Resolve(jvm_import); err == nil { + return Resolution_Label, &l, nil + } + } + + if err != nil { + BazelLog.Warn("Kotlin resolution error: ", err) + } - return Resolution_NotFound, nil, nil + return Resolution_NotFound, nil, err } // targetListFromResults returns a string with the human-readable list of diff --git a/gazelle/kotlin/tests/native_deps/lib.kt b/gazelle/kotlin/tests/native_deps/lib.kt index feefcece5..744598543 100644 --- a/gazelle/kotlin/tests/native_deps/lib.kt +++ b/gazelle/kotlin/tests/native_deps/lib.kt @@ -10,6 +10,18 @@ import kotlin.text.* // as import kotlinx.serialization.json.Json as Jason +// Java, see rules_jvm java/gazelle/private/java/java.go +import java.util.* +import java.lang.String +import javax.net.* +import javax.xml.* +import jdk.* +import netscape.javascript.* +import org.ietf.jgss.* +import org.jcp.xml.dsig.internal.* +import org.w3c.dom.* +import org.xml.sax.* + @Serializable data class Data(val a: Int, val b: String) diff --git a/gazelle/kotlin/tests/rules_jvm-maven/BUILD.in b/gazelle/kotlin/tests/rules_jvm-maven/BUILD.in new file mode 100644 index 000000000..dcaf62d10 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/BUILD.in @@ -0,0 +1 @@ +# TODO(gazelle:)java_maven_repository_name vendor_java diff --git a/gazelle/kotlin/tests/rules_jvm-maven/BUILD.out b/gazelle/kotlin/tests/rules_jvm-maven/BUILD.out new file mode 100644 index 000000000..dcaf62d10 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/BUILD.out @@ -0,0 +1 @@ +# TODO(gazelle:)java_maven_repository_name vendor_java diff --git a/gazelle/kotlin/tests/rules_jvm-maven/README.md b/gazelle/kotlin/tests/rules_jvm-maven/README.md new file mode 100644 index 000000000..a54dfb0a6 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/README.md @@ -0,0 +1,8 @@ +Copied from +[rules_jvm "maven" test](https://github.com/bazel-contrib/rules_jvm/tree/v0.17.0/java/gazelle/testdata/maven). + +Created by ~ following steps: + +1. Copy the rules_jvm "maven" test +2. Rename .java to .kt +3. Modify .kt files to Kotlin syntax with a minimal diff diff --git a/gazelle/kotlin/tests/rules_jvm-maven/WORKSPACE b/gazelle/kotlin/tests/rules_jvm-maven/WORKSPACE new file mode 100644 index 000000000..dbfdcb83f --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/WORKSPACE @@ -0,0 +1,27 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "rules_jvm_external", + sha256 = "23fe83890a77ac1a3ee143e2306ec12da4a845285b14ea13cb0df1b1e23658fe", + strip_prefix = "rules_jvm_external-4.3", + urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/refs/tags/4.3.tar.gz"], +) + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_install( + artifacts = [ + "junit:junit:4.13.1", + "com.google.guava:guava:30.0-jre", + ], + fetch_sources = True, + maven_install_json = "//:maven_install.json", + repositories = [ + "http://uk.maven.org/maven2", + "https://jcenter.bintray.com/", + ], +) + +load("@maven//:defs.bzl", "pinned_maven_install") + +pinned_maven_install() diff --git a/gazelle/kotlin/tests/rules_jvm-maven/maven_install.json b/gazelle/kotlin/tests/rules_jvm-maven/maven_install.json new file mode 100644 index 000000000..ccd38ae99 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/maven_install.json @@ -0,0 +1,363 @@ +{ + "dependency_tree": { + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": -98192304, + "__RESOLVED_ARTIFACTS_HASH": 1256918319, + "conflict_resolution": {}, + "dependencies": [ + { + "coord": "com.google.code.findbugs:jsr305:3.0.2", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" + ], + "packages": [ + "javax.annotation", + "javax.annotation.concurrent", + "javax.annotation.meta" + ], + "sha256": "766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7", + "url": "https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" + }, + { + "coord": "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar", + "https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar" + ], + "packages": [], + "sha256": "1c9e85e272d0708c6a591dc74828c71603053b48cc75ae83cce56912a2aa063b", + "url": "https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar" + }, + { + "coord": "com.google.errorprone:error_prone_annotations:2.3.4", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar", + "https://jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar" + ], + "packages": [ + "com.google.errorprone.annotations", + "com.google.errorprone.annotations.concurrent" + ], + "sha256": "baf7d6ea97ce606c53e11b6854ba5f2ce7ef5c24dddf0afa18d1260bd25b002c", + "url": "https://jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar" + }, + { + "coord": "com.google.errorprone:error_prone_annotations:jar:sources:2.3.4", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4-sources.jar", + "https://jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4-sources.jar" + ], + "packages": [], + "sha256": "0b1011d1e2ea2eab35a545cffd1cff3877f131134c8020885e8eaf60a7d72f91", + "url": "https://jcenter.bintray.com/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4-sources.jar" + }, + { + "coord": "com.google.guava:failureaccess:1.0.1", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "https://jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + ], + "packages": ["com.google.common.util.concurrent.internal"], + "sha256": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26", + "url": "https://jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + }, + { + "coord": "com.google.guava:failureaccess:jar:sources:1.0.1", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar", + "https://jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar" + ], + "packages": [], + "sha256": "092346eebbb1657b51aa7485a246bf602bb464cc0b0e2e1c7e7201fadce1e98f", + "url": "https://jcenter.bintray.com/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar" + }, + { + "coord": "com.google.guava:guava:30.0-jre", + "dependencies": [ + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.errorprone:error_prone_annotations:2.3.4", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:1.3", + "org.checkerframework:checker-qual:3.5.0" + ], + "directDependencies": [ + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.errorprone:error_prone_annotations:2.3.4", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:1.3", + "org.checkerframework:checker-qual:3.5.0" + ], + "file": "v1/https/jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar", + "https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar" + ], + "packages": [ + "com.google.common.annotations", + "com.google.common.base", + "com.google.common.base.internal", + "com.google.common.cache", + "com.google.common.collect", + "com.google.common.escape", + "com.google.common.eventbus", + "com.google.common.graph", + "com.google.common.hash", + "com.google.common.html", + "com.google.common.io", + "com.google.common.math", + "com.google.common.net", + "com.google.common.primitives", + "com.google.common.reflect", + "com.google.common.util.concurrent", + "com.google.common.xml", + "com.google.thirdparty.publicsuffix" + ], + "sha256": "56b292df9ec29d102820c1fd7dd581cd749d5c416c7b3aeac008dbda3b984cc2", + "url": "https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar" + }, + { + "coord": "com.google.guava:guava:jar:sources:30.0-jre", + "dependencies": [ + "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "com.google.errorprone:error_prone_annotations:jar:sources:2.3.4", + "com.google.guava:failureaccess:jar:sources:1.0.1", + "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "org.checkerframework:checker-qual:jar:sources:3.5.0" + ], + "directDependencies": [ + "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "com.google.errorprone:error_prone_annotations:jar:sources:2.3.4", + "com.google.guava:failureaccess:jar:sources:1.0.1", + "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "org.checkerframework:checker-qual:jar:sources:3.5.0" + ], + "file": "v1/https/jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar", + "https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar" + ], + "packages": [], + "sha256": "daa8a245663f9027ae4b84239147d3439221839155a4d93cbab280c3e657a73d", + "url": "https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar" + }, + { + "coord": "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "https://jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + ], + "packages": [], + "sha256": "b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99", + "url": "https://jcenter.bintray.com/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + }, + { + "coord": "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "dependencies": [], + "directDependencies": [], + "file": null + }, + { + "coord": "com.google.j2objc:j2objc-annotations:1.3", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", + "https://jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" + ], + "packages": ["com.google.j2objc.annotations"], + "sha256": "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b", + "url": "https://jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" + }, + { + "coord": "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar", + "https://jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar" + ], + "packages": [], + "sha256": "ba4df669fec153fa4cd0ef8d02c6d3ef0702b7ac4cabe080facf3b6e490bb972", + "url": "https://jcenter.bintray.com/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar" + }, + { + "coord": "junit:junit:4.13.1", + "dependencies": ["org.hamcrest:hamcrest-core:1.3"], + "directDependencies": ["org.hamcrest:hamcrest-core:1.3"], + "file": "v1/https/jcenter.bintray.com/junit/junit/4.13.1/junit-4.13.1.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/junit/junit/4.13.1/junit-4.13.1.jar", + "https://jcenter.bintray.com/junit/junit/4.13.1/junit-4.13.1.jar" + ], + "packages": [ + "junit.extensions", + "junit.framework", + "junit.runner", + "junit.textui", + "org.junit", + "org.junit.experimental", + "org.junit.experimental.categories", + "org.junit.experimental.max", + "org.junit.experimental.results", + "org.junit.experimental.runners", + "org.junit.experimental.theories", + "org.junit.experimental.theories.internal", + "org.junit.experimental.theories.suppliers", + "org.junit.function", + "org.junit.internal", + "org.junit.internal.builders", + "org.junit.internal.management", + "org.junit.internal.matchers", + "org.junit.internal.requests", + "org.junit.internal.runners", + "org.junit.internal.runners.model", + "org.junit.internal.runners.rules", + "org.junit.internal.runners.statements", + "org.junit.matchers", + "org.junit.rules", + "org.junit.runner", + "org.junit.runner.manipulation", + "org.junit.runner.notification", + "org.junit.runners", + "org.junit.runners.model", + "org.junit.runners.parameterized", + "org.junit.validator" + ], + "sha256": "c30719db974d6452793fe191b3638a5777005485bae145924044530ffa5f6122", + "url": "https://jcenter.bintray.com/junit/junit/4.13.1/junit-4.13.1.jar" + }, + { + "coord": "junit:junit:jar:sources:4.13.1", + "dependencies": ["org.hamcrest:hamcrest-core:jar:sources:1.3"], + "directDependencies": ["org.hamcrest:hamcrest-core:jar:sources:1.3"], + "file": "v1/https/jcenter.bintray.com/junit/junit/4.13.1/junit-4.13.1-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/junit/junit/4.13.1/junit-4.13.1-sources.jar", + "https://jcenter.bintray.com/junit/junit/4.13.1/junit-4.13.1-sources.jar" + ], + "packages": [], + "sha256": "624c08005c95c47287c9d921479cff0b71dd50a101b0810cd5e207242eb8fe0e", + "url": "https://jcenter.bintray.com/junit/junit/4.13.1/junit-4.13.1-sources.jar" + }, + { + "coord": "org.checkerframework:checker-qual:3.5.0", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar", + "https://jcenter.bintray.com/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar" + ], + "packages": [ + "org.checkerframework.checker.compilermsgs.qual", + "org.checkerframework.checker.fenum.qual", + "org.checkerframework.checker.formatter", + "org.checkerframework.checker.formatter.qual", + "org.checkerframework.checker.guieffect.qual", + "org.checkerframework.checker.i18n.qual", + "org.checkerframework.checker.i18nformatter", + "org.checkerframework.checker.i18nformatter.qual", + "org.checkerframework.checker.index.qual", + "org.checkerframework.checker.initialization.qual", + "org.checkerframework.checker.interning.qual", + "org.checkerframework.checker.lock.qual", + "org.checkerframework.checker.nullness", + "org.checkerframework.checker.nullness.qual", + "org.checkerframework.checker.optional.qual", + "org.checkerframework.checker.propkey.qual", + "org.checkerframework.checker.regex", + "org.checkerframework.checker.regex.qual", + "org.checkerframework.checker.signature.qual", + "org.checkerframework.checker.signedness", + "org.checkerframework.checker.signedness.qual", + "org.checkerframework.checker.tainting.qual", + "org.checkerframework.checker.units", + "org.checkerframework.checker.units.qual", + "org.checkerframework.common.aliasing.qual", + "org.checkerframework.common.reflection.qual", + "org.checkerframework.common.returnsreceiver.qual", + "org.checkerframework.common.subtyping.qual", + "org.checkerframework.common.util.report.qual", + "org.checkerframework.common.value.qual", + "org.checkerframework.dataflow.qual", + "org.checkerframework.framework.qual", + "org.checkerframework.framework.util" + ], + "sha256": "729990b3f18a95606fc2573836b6958bcdb44cb52bfbd1b7aa9c339cff35a5a4", + "url": "https://jcenter.bintray.com/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar" + }, + { + "coord": "org.checkerframework:checker-qual:jar:sources:3.5.0", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0-sources.jar", + "https://jcenter.bintray.com/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0-sources.jar" + ], + "packages": [], + "sha256": "0724b40995c1b05516caa2dd9a3b2f5378f948cf20f3404f4db316af25239368", + "url": "https://jcenter.bintray.com/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0-sources.jar" + }, + { + "coord": "org.hamcrest:hamcrest-core:1.3", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar", + "https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + ], + "packages": [ + "org.hamcrest", + "org.hamcrest.core", + "org.hamcrest.internal" + ], + "sha256": "66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9", + "url": "https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + }, + { + "coord": "org.hamcrest:hamcrest-core:jar:sources:1.3", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar", + "mirror_urls": [ + "http://uk.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar", + "https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar" + ], + "packages": [], + "sha256": "e223d2d8fbafd66057a8848cc94222d63c3cedd652cc48eddc0ab5c39c0f84df", + "url": "https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar" + } + ], + "version": "0.1.0" + } +} diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.in b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.out b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.out new file mode 100644 index 000000000..fb82e4805 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/BUILD.out @@ -0,0 +1,8 @@ +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary") + +kt_jvm_binary( + name = "compare_bin", + srcs = ["Compare.kt"], + main_class = "com.example.compare.Compare", + deps = ["@maven//:com_google_guava_guava"], +) diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/Compare.kt b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/Compare.kt new file mode 100644 index 000000000..7a3b3cf33 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/compare/Compare.kt @@ -0,0 +1,17 @@ +package com.example.compare + +import com.google.common.primitives.* + +/** This application compares two numbers, using the Ints.compare method from Guava. */ +class Compare() { + companion object { + fun compare(a : int, b: int) { + return Ints.compare(a, b) + } + } +} + +fun main(vararg args: string) { + var app = new Compare(); + System.out.println("Success: " + app.compare(2, 1)); +} \ No newline at end of file diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/App.kt b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/App.kt new file mode 100644 index 000000000..c359cea3e --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/App.kt @@ -0,0 +1,17 @@ +package com.example.myproject + +import com.google.common.primitives.Ints + +/** This application compares two numbers, using the Ints.compare method from Guava. */ +class App() { + companion object { + fun compare(a : int, b: int) { + return Ints.compare(a, b) + } + } +} + +fun main(vararg args: string) { + var app = new Compare(); + System.out.println("Success: " + app.compare(2, 1)); +} \ No newline at end of file diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.in b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.out b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.out new file mode 100644 index 000000000..88fe59995 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/src/main/java/com/example/myproject/BUILD.out @@ -0,0 +1,8 @@ +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary") + +kt_jvm_binary( + name = "app_bin", + srcs = ["App.kt"], + main_class = "com.example.myproject.App", + deps = ["@maven//:com_google_guava_guava"], +) diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/AppTest.kt b/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/AppTest.kt new file mode 100644 index 000000000..d0bfa7631 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/AppTest.kt @@ -0,0 +1,14 @@ +package com.example.myproject + +import org.junit.* + +import org.junit.Test + +/** Tests for correct dependency retrieval with maven rules. */ +class AppTest() { + + fun testCompare() { + var app = new App(); + Assert.assertEquals("should return 0 when both numbers are equal", 0, app.compare(1, 1)); + } +} diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.in b/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.in new file mode 100644 index 000000000..e69de29bb diff --git a/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.out b/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.out new file mode 100644 index 000000000..c49045424 --- /dev/null +++ b/gazelle/kotlin/tests/rules_jvm-maven/src/test/java/com/example/myproject/BUILD.out @@ -0,0 +1,7 @@ +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") + +kt_jvm_library( + name = "myproject", + srcs = ["AppTest.kt"], + deps = ["@maven//:junit_junit"], +) From 44e4e447fbb87aaefe19c45b724ae45802e5d149 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 14 Aug 2023 11:32:43 -0700 Subject: [PATCH 6/9] chore: update rules_jvm to latest (#3163) Picks up a visibility change so we can drop a patch That way we don't need to patch it in the aspect-cli repo too. --- ### Type of change - Chore (any other change that doesn't affect source or test files, such as configuration) ### Test plan - Covered by existing test cases --------- Co-authored-by: Jason Bedard GitOrigin-RevId: dc6e3f9df4b286b3417a45c73b9dfa7a0500911a --- gazelle/kotlin/configure.go | 1 - gazelle/kotlin/resolver.go | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gazelle/kotlin/configure.go b/gazelle/kotlin/configure.go index ca6879ddc..4c6ea5b77 100644 --- a/gazelle/kotlin/configure.go +++ b/gazelle/kotlin/configure.go @@ -77,7 +77,6 @@ func (kt *Configurer) Configure(c *config.Config, rel string, f *rule.File) { resolver, err := jvm_maven.NewResolver( cfg.MavenInstallFile(), - cfg.ExcludedArtifacts(), logger, ) if err != nil { diff --git a/gazelle/kotlin/resolver.go b/gazelle/kotlin/resolver.go index f484000b0..40f56360e 100644 --- a/gazelle/kotlin/resolver.go +++ b/gazelle/kotlin/resolver.go @@ -9,6 +9,7 @@ import ( common "aspect.build/cli/gazelle/common" . "aspect.build/cli/gazelle/common/log" + "aspect.build/cli/gazelle/kotlin/kotlinconfig" "github.com/bazelbuild/bazel-gazelle/config" "github.com/bazelbuild/bazel-gazelle/label" "github.com/bazelbuild/bazel-gazelle/repo" @@ -192,9 +193,12 @@ func (kt *Resolver) resolveImport( jvm_import := jvm_types.NewPackageName(impt.Imp) + cfgs := c.Exts[LanguageName].(kotlinconfig.Configs) + cfg, _ := cfgs[from.Pkg] + // Maven imports if mavenResolver := kt.lang.mavenResolver; mavenResolver != nil { - if l, err := (*mavenResolver).Resolve(jvm_import); err == nil { + if l, err := (*mavenResolver).Resolve(jvm_import, cfg.ExcludedArtifacts(), cfg.MavenRepositoryName()); err == nil { return Resolution_Label, &l, nil } } From ec269337a2ba01c7b5fe0bbda80a8a5ff7742890 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 14 Aug 2023 13:24:40 -0700 Subject: [PATCH 7/9] Update BUILD.bazel --- cmd/aspect/root/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/aspect/root/BUILD.bazel b/cmd/aspect/root/BUILD.bazel index e5e53747f..cd11b19bb 100644 --- a/cmd/aspect/root/BUILD.bazel +++ b/cmd/aspect/root/BUILD.bazel @@ -33,10 +33,10 @@ go_library( "//cmd/aspect/sync", "//cmd/aspect/test", "//cmd/aspect/version", + "//docs/help/topics", "//pkg/aspect/root/flags", "//pkg/ioutils", "//pkg/plugin/system", - "//docs/help/topics", "@com_github_fatih_color//:color", "@com_github_mattn_go_isatty//:go-isatty", "@com_github_spf13_cobra//:cobra", From 50d1c872533a0c73c0a3c07f590ac27dbfd0a4c9 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 14 Aug 2023 13:29:12 -0700 Subject: [PATCH 8/9] chore: go mod tidy --- cmd/aspect/root/root.go | 2 +- go.bzl | 28 ++++++++++++++++++++++------ go.mod | 5 ++++- go.sum | 13 +++++++++++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/cmd/aspect/root/root.go b/cmd/aspect/root/root.go index 6f11f7310..a965ae488 100644 --- a/cmd/aspect/root/root.go +++ b/cmd/aspect/root/root.go @@ -51,10 +51,10 @@ import ( "aspect.build/cli/cmd/aspect/sync" "aspect.build/cli/cmd/aspect/test" "aspect.build/cli/cmd/aspect/version" + help_docs "aspect.build/cli/docs/help/topics" "aspect.build/cli/pkg/aspect/root/flags" "aspect.build/cli/pkg/ioutils" "aspect.build/cli/pkg/plugin/system" - help_docs "github.com/aspect-build/silo/docs/help/topics" ) var ( diff --git a/go.bzl b/go.bzl index 7ed50ddee..4ba7c6152 100644 --- a/go.bzl +++ b/go.bzl @@ -30,8 +30,8 @@ def deps(): name = "com_github_bazel_contrib_rules_jvm", build_file_proto_mode = "disable_global", importpath = "github.com/bazel-contrib/rules_jvm", - sum = "h1:Sm5+nBadu14haQpSGejRXC3tMpAJI49RYbg93DfYVLo=", - version = "v0.13.0", + sum = "h1:oJxriPrBPGxugqkQiFceyzuBYgaFiUBTFM8xhrErPKs=", + version = "v0.17.1-0.20230814153054-0ce5d051291b", ) go_repository( @@ -161,8 +161,8 @@ def deps(): name = "com_github_coreos_go_systemd_v22", build_file_proto_mode = "disable_global", importpath = "github.com/coreos/go-systemd/v22", - sum = "h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=", - version = "v22.3.2", + sum = "h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=", + version = "v22.5.0", ) go_repository( name = "com_github_cpuguy83_go_md2man_v2", @@ -250,6 +250,14 @@ def deps(): sum = "h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=", version = "v0.0.0-20230315185526-52ccab3ef572", ) + go_repository( + name = "com_github_godbus_dbus_v5", + build_file_proto_mode = "disable_global", + importpath = "github.com/godbus/dbus/v5", + sum = "h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=", + version = "v5.0.4", + ) + go_repository( name = "com_github_gogo_protobuf", build_file_proto_mode = "disable_global", @@ -663,12 +671,20 @@ def deps(): sum = "h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=", version = "v1.9.0", ) + go_repository( + name = "com_github_rs_xid", + build_file_proto_mode = "disable_global", + importpath = "github.com/rs/xid", + sum = "h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY=", + version = "v1.4.0", + ) + go_repository( name = "com_github_rs_zerolog", build_file_proto_mode = "disable_global", importpath = "github.com/rs/zerolog", - sum = "h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=", - version = "v1.26.1", + sum = "h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=", + version = "v1.29.1", ) go_repository( diff --git a/go.mod b/go.mod index fdebff403..f1e408b6d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/Masterminds/semver/v3 v3.2.1 - github.com/bazel-contrib/rules_jvm v0.13.0 + github.com/bazel-contrib/rules_jvm v0.17.1-0.20230814153054-0ce5d051291b github.com/bazelbuild/bazel-gazelle v0.31.0 github.com/bazelbuild/bazelisk v1.17.0 github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d @@ -22,6 +22,7 @@ require ( github.com/onsi/gomega v1.27.7 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pmezard/go-difflib v1.0.0 + github.com/rs/zerolog v1.29.1 github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 github.com/sirupsen/logrus v1.9.3 github.com/smacker/go-tree-sitter v0.0.0-20230501083651-a7d92773b3aa @@ -39,10 +40,12 @@ require ( ) require ( + github.com/bazelbuild/rules_go v0.39.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect diff --git a/go.sum b/go.sum index eeab3907c..76ee575b2 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= -github.com/bazel-contrib/rules_jvm v0.13.0 h1:Sm5+nBadu14haQpSGejRXC3tMpAJI49RYbg93DfYVLo= -github.com/bazel-contrib/rules_jvm v0.13.0/go.mod h1:8WqhezdBMI9So2ASJrbwSbAvDEYlE28ssdQyDEm57GM= +github.com/bazel-contrib/rules_jvm v0.17.1-0.20230814153054-0ce5d051291b h1:oJxriPrBPGxugqkQiFceyzuBYgaFiUBTFM8xhrErPKs= +github.com/bazel-contrib/rules_jvm v0.17.1-0.20230814153054-0ce5d051291b/go.mod h1:tZ4zJRqWBNjRdaU+eE9ppdRZBrjWAYfaRYoe3bBwsCc= github.com/bazelbuild/bazel-gazelle v0.31.0 h1:D5oumrfJODIy/6jMxx8Aq4LtmXeyvqhsZ136NySl3fQ= github.com/bazelbuild/bazel-gazelle v0.31.0/go.mod h1:Ul0pqz50f5wxz0QNzsZ+mrEu4AVAVJZEB5xLnHgIG9c= github.com/bazelbuild/bazelisk v1.17.0 h1:TDt+a1PYrnBF9on3WRJUisXXFhCMrhcNo8OebyS5Q34= @@ -49,6 +49,7 @@ github.com/bazelbuild/bazelisk v1.17.0/go.mod h1:nWNmVF7yKsUt3EWCBCrqUeMNQpbB+DA github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d h1:Fl1FfItZp34QIQmmDTbZXHB5XA6JfbNNfH7tRRGWvQo= github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d/go.mod h1:689QdV3hBP7Vo9dJMmzhoYIyo/9iMhEmHkJcnaPRCbo= github.com/bazelbuild/rules_go v0.39.1 h1:wkJLUDx59dntWMghuL8++GteoU1To6sRoKJXuyFtmf8= +github.com/bazelbuild/rules_go v0.39.1/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bmatcuk/doublestar/v4 v4.6.0 h1:HTuxyug8GyFbRkrffIpzNCSK4luc0TY3wzXvzIZhEXc= @@ -67,6 +68,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -91,6 +93,7 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -123,6 +126,8 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -151,6 +156,7 @@ github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= @@ -218,6 +224,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= +github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= From 093c0a31c080cbb7420a1a251cbc467716c22ebe Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 14 Aug 2023 13:34:23 -0700 Subject: [PATCH 9/9] bazel run //docs:update --- docs/aspect_configure.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/aspect_configure.md b/docs/aspect_configure.md index 2c821220f..4e5724e49 100644 --- a/docs/aspect_configure.md +++ b/docs/aspect_configure.md @@ -26,6 +26,10 @@ The advantage of configure in Aspect CLI is that you don't need to compile the t [gazelle]: https://github.com/bazelbuild/bazel-gazelle +To change the behavior of configure, you add "directives" to your BUILD files, which are comments +in a special syntax. +Run 'aspect help directives' or see https://docs.aspect.build/v/cli/help/directives for more info. + ``` aspect configure [flags]