Default to using gradle-nexus in gen-sdk#1612
Conversation
When using `pulumi-java-gen`, the user can bass a `—build` flag which the following options: * `none`: no gradle file is generated (the default) * `gradle`: a gradle file is generated -> BuildFiles: gradle * `gradle-nexus`: a gradle file using the nexus publishing plugin is generated, using a default version of the plugin -> BuildFiles: gradle, GradleNexusPublishPluginVersion: 2.0.0 * `gradle-nexus:$VER`: a gradle file using the nexus publishing plugin is generated, using the version $VER for the plugin -> BuildFiles: gradle, GradleNexusPublishPluginVersion: $VER Using `gen-sdk`, the options are managed via the schema, `buildFiles` can take the following options: * `gradle-nexus`: the default if the buildFiles is not set, a gradle file using the nexus publishing plugin is generated, implies `gradleNexusPublishPluginVersion: 2.0.0` if `gradleNexusPublishPluginVersionA` is not set. * `gradle`: a gradle file is generated, but without the nexus publishing plugin * `none`: no gradle file is generated Fixes #1593
386cdc0 to
6f67b55
Compare
| // *** Do not edit by hand unless you're certain you know what you are doing! *** | ||
|
|
||
| package com.pulumi.kubernetes.core_v1; | ||
| package com.pulumi.kubernetes.core.v1; |
There was a problem hiding this comment.
Previously the tests ignored any language specific settings. They now no longer do, and this change comes from the config
"java": {
"packages": {
"core/v1": "core.v1",
"helm.sh/v3": "helm.v3",
"meta/v1": "meta.v1"
}
},
lunaris
left a comment
There was a problem hiding this comment.
Awesome stuff! And amazing PR description 💜
pkg/codegen/java/gen.go
Outdated
| // legacy behavior requires explicit gradle setting | ||
| (legacyBuildFiles && info.BuildFiles == "gradle") || | ||
| // new behavior uses gradle by default, unless explicitly disabled | ||
| (!legacyBuildFiles && info.BuildFiles != "none") |
There was a problem hiding this comment.
I feel like I'd make this an if, which although a bit more verbose might be clearer and obviate some of the comment. E.g.:
var useGradle bool
if local {
// ...
useGradle = false
} else {
if legacyBuildFiles {
// The default for legacy invocations is "none", so we need to see an explicit "gradle" setting
useGradle = info.BuildFiles == "gradle"
} else {
// The default for new invocations is gradle, unless "none" is specified explicitly
useGradle = info.BuildFiles != "none"
}
}| info := pkg.Language["java"].(PackageInfo) | ||
| pkg.Language["java"] = info.With(testCase.packageInfo) | ||
| } | ||
| return GeneratePackage(tool, pkg, extraFiles, nil, false /*local*/, false /*legacyBuildFiles*/) |
There was a problem hiding this comment.
I do wonder if it's possible to find a way to test this set to true, since that's the behaviour we want to preserve, but equally it's probably fine?
There was a problem hiding this comment.
Good call, I updated TestGenGradleProject to check the generated file for both legacy false and true variants.
| } | ||
|
|
||
| if packageInfo.GradleNexusPublishPluginVersion != "" { | ||
| if legacyBuildFiles { |
There was a problem hiding this comment.
I wonder if it's worth adding some version of the amazing table in the PR description here; happy either way though.
| PackageInfo | Behaviour |
|---|---|
buildFiles: none |
no gradle file |
buildFiles: gradle-nexus |
gradle file with nexus plugin, using default version of the plugin, 2.0.0, the default |
buildFiles: gradle-nexus, gradleNexusPublishPluginVersion: $VER |
gradle file with nexus plugin, using version $VER of the plugin |
buildFiles: gradle |
gradle file without nexus plugin |
buildFiles: gradle, gradleNexusPublishPluginVersion: $VER |
gradle file with nexus plugin, using version $VER of the plugin |
When using
pulumi-java-gen, the user can bass a—buildflag to set gradle related settings in the PackageInfo:nonegradlebuildFiles: gradlegradle-nexusbuildFiles: gradle, gradleNexusPublishPluginVersion: 2.0.0gradle-nexus:$VERbuildFiles: gradle, gradleNexusPublishPluginVersion: $VERPulumi providers use
--build gradle-nexus.When using
gen-sdkinstead ofpulumi-java-gen, you control the gradle generation with thePackageInfo. To streamline the usage of the most desired behaviour (gradle-nexus), this PR changes the behaviour of thebuildFileoption when usinggen-sdk. The behaviour when usingpulumi-java-genis unchanged.This allows providers to not set any options in their schema and still get the best default behaviour.
buildFiles: nonebuildFiles: gradle-nexus2.0.0, the defaultbuildFiles: gradle-nexus, gradleNexusPublishPluginVersion: $VERbuildFiles: gradlebuildFiles: gradle, gradleNexusPublishPluginVersion: $VERFixes #1593