Skip to content

Commit

Permalink
Apply default dependencies when called from Pulumi CLI (#1501)
Browse files Browse the repository at this point in the history
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 #1500
  • Loading branch information
danielrbradley authored Dec 11, 2024
1 parent cfe8b2a commit 8f88a80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ CHANGELOG

- Reduce binary size by stripping debug information

- Apply default dependencies consistently.

## 0.18.0 (2024-11-26)

### Improvements
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/pulumi-java-gen/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions pkg/codegen/java/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ 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"

"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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 8f88a80

Please sign in to comment.