From 8f88a8082bbf3ec9e14f342b098654c88c0efd5a Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Wed, 11 Dec 2024 18:55:27 +0000 Subject: [PATCH] Apply default dependencies when called from Pulumi CLI (#1501) The `pulumi package gen-sdk` command calls `GeneratePackage` directly, so we need to apply the defaults at that layer rather than in the pulumi-java-gen specific code. Fixes https://github.com/pulumi/pulumi-java/issues/1500 --- CHANGELOG.md | 2 ++ pkg/cmd/pulumi-java-gen/command.go | 3 +-- pkg/codegen/java/gen.go | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d231d84151..b7b3753a99f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ CHANGELOG - Reduce binary size by stripping debug information +- Apply default dependencies consistently. + ## 0.18.0 (2024-11-26) ### Improvements diff --git a/pkg/cmd/pulumi-java-gen/command.go b/pkg/cmd/pulumi-java-gen/command.go index 1d79c3d3bf9..a156c3afc5d 100644 --- a/pkg/cmd/pulumi-java-gen/command.go +++ b/pkg/cmd/pulumi-java-gen/command.go @@ -147,8 +147,7 @@ See https://www.pulumi.com/docs/guides/pulumi-packages/schema/#language-specific return err } - opts.PackageInfo = opts.PackageInfo.With(buildArgOverrides). - WithDefaultDependencies() + opts.PackageInfo = opts.PackageInfo.With(buildArgOverrides) if javaSdkVersionArg != "" { parsedVersion, err := semver.ParseTolerant(javaSdkVersionArg) diff --git a/pkg/codegen/java/gen.go b/pkg/codegen/java/gen.go index b6d15146859..60ba45f59f9 100644 --- a/pkg/codegen/java/gen.go +++ b/pkg/codegen/java/gen.go @@ -13,6 +13,7 @@ import ( "strconv" "strings" + "github.com/blang/semver" "github.com/pulumi/pulumi/pkg/v3/codegen" "github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" @@ -20,6 +21,9 @@ import ( "github.com/pulumi/pulumi-java/pkg/codegen/java/names" ) +// This should be bumped as required at the point of release. +var DefaultSdkVersion = semver.Version{Major: 0, Minor: 18, Patch: 0} + func packageName(packages map[string]string, name string) string { if pkg, ok := packages[name]; ok { return pkg @@ -2039,6 +2043,9 @@ func generateModuleContextMap(tool string, pkg *schema.Package) (map[string]*mod panic(fmt.Sprintf("Failed to cast `pkg.Language[\"java\"]`=%v to `PackageInfo`", raw)) } } + javaInfo = javaInfo. + WithDefaultDependencies(). + WithJavaSdkDependencyDefault(DefaultSdkVersion) info = &javaInfo infos[def] = info }