diff --git a/buildengine/build_kotlin.go b/buildengine/build_kotlin.go index 66dc59459c..66235c60a9 100644 --- a/buildengine/build_kotlin.go +++ b/buildengine/build_kotlin.go @@ -28,16 +28,12 @@ type externalModuleContext struct { } func (e externalModuleContext) ExternalModules() []*schema.Module { - depsSet := make(map[string]struct{}) - for _, dep := range e.module.Dependencies { - depsSet[dep] = struct{}{} - } - - modules := make([]*schema.Module, 0) + modules := make([]*schema.Module, 0, len(e.Modules)) for _, module := range e.Modules { - if _, exists := depsSet[module.Name]; exists || module.Name == "builtin" { - modules = append(modules, module) + if module.Name == e.module.Module { + continue } + modules = append(modules, module) } return modules } @@ -149,7 +145,7 @@ func generateExternalModules(ctx context.Context, module Module, sch *schema.Sch return internal.ScaffoldZip(kotlinruntime.ExternalModuleTemplates(), config.Dir, externalModuleContext{ module: module, Schema: sch, - }, scaffolder.Functions(funcs)) + }, scaffolder.Exclude("^go.mod$"), scaffolder.Functions(funcs)) } var scaffoldFuncs = scaffolder.FuncMap{ diff --git a/buildengine/deps.go b/buildengine/deps.go index 64c758f98d..c86964ae41 100644 --- a/buildengine/deps.go +++ b/buildengine/deps.go @@ -43,6 +43,16 @@ func UpdateDependencies(ctx context.Context, config moduleconfig.ModuleConfig) ( if err != nil { return Module{}, err } + containsBuiltin := false + for _, dep := range dependencies { + if dep == "builtin" { + containsBuiltin = true + break + } + } + if !containsBuiltin { + dependencies = append(dependencies, "builtin") + } out := reflect.DeepCopy(config) return Module{ModuleConfig: out, Dependencies: dependencies}, nil } diff --git a/buildengine/engine_test.go b/buildengine/engine_test.go index 770bdea424..17a7251b07 100644 --- a/buildengine/engine_test.go +++ b/buildengine/engine_test.go @@ -44,9 +44,10 @@ func TestEngine(t *testing.T) { engine.Import(ctx, otherSchema) expected := map[string][]string{ - "alpha": {"another", "other"}, - "another": {}, + "alpha": {"another", "other", "builtin"}, + "another": {"builtin"}, "other": {}, + "builtin": {}, } graph, err := engine.Graph() assert.NoError(t, err) diff --git a/buildengine/testdata/modules/echokotlin/go.mod b/buildengine/testdata/modules/echokotlin/go.mod deleted file mode 100644 index 22cc3059db..0000000000 --- a/buildengine/testdata/modules/echokotlin/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module ignore - -go 1.22.0