-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default to using gradle-nexus in gen-sdk #1612
base: main
Are you sure you want to change the base?
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
@@ -1,15 +1,15 @@ | |||
// *** WARNING: this file was generated by test. *** | |||
// *** 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"
}
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff! And amazing PR description 💜
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@@ -126,7 +130,20 @@ func newGradleTemplateContext( | |||
ctx.Version = pkg.Parameterization.BaseProvider.Version.String() | |||
} | |||
|
|||
if packageInfo.GradleNexusPublishPluginVersion != "" { | |||
if legacyBuildFiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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—build
flag to set gradle related settings in the PackageInfo:none
gradle
buildFiles: gradle
gradle-nexus
buildFiles: gradle, gradleNexusPublishPluginVersion: 2.0.0
gradle-nexus:$VER
buildFiles: gradle, gradleNexusPublishPluginVersion: $VER
Pulumi providers use
--build gradle-nexus
.When using
gen-sdk
instead 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 thebuildFile
option when usinggen-sdk
. The behaviour when usingpulumi-java-gen
is unchanged.This allows providers to not set any options in their schema and still get the best default behaviour.
buildFiles: none
buildFiles: gradle-nexus
2.0.0
, the defaultbuildFiles: gradle-nexus, gradleNexusPublishPluginVersion: $VER
buildFiles: gradle
buildFiles: gradle, gradleNexusPublishPluginVersion: $VER
Fixes #1593