diff --git a/pkg/cmd/pulumi-language-java/language_test.go b/pkg/cmd/pulumi-language-java/language_test.go index a13a41383d7..f7baa21d0ae 100644 --- a/pkg/cmd/pulumi-language-java/language_test.go +++ b/pkg/cmd/pulumi-language-java/language_test.go @@ -178,8 +178,6 @@ var expectedFailures = map[string]string{ "l2-invoke-variants": "unimplemented for Java", "l2-large-string": "unimplemented for Java", "l2-map-keys": "unimplemented for Java", - "l2-plain": "unimplemented for Java", - "l2-primitive-ref": "unimplemented for Java", "l2-provider-grpc-config-schema-secret": "unimplemented for Java", "l2-provider-grpc-config-secret": "unimplemented for Java", "l2-provider-grpc-config": "unimplemented for Java", diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/Pulumi.yaml b/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/Pulumi.yaml new file mode 100644 index 00000000000..088b5c9728b --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/Pulumi.yaml @@ -0,0 +1,2 @@ +name: l2-plain +runtime: java diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/pom.xml b/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/pom.xml new file mode 100644 index 00000000000..fde23a1817d --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + com.pulumi + l2-plain + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + generated_program.App + + + + + + repository-0 + REPOSITORY + + + + + + com.pulumi + pulumi + CORE.VERSION + + + com.pulumi + plain + 13.0.0 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.1 + + 3.8.5 + + + + + \ No newline at end of file diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/src/main/java/generated_program/App.java b/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/src/main/java/generated_program/App.java new file mode 100644 index 00000000000..749df460a0b --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l2-plain/src/main/java/generated_program/App.java @@ -0,0 +1,53 @@ +package generated_program; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.plain.Resource; +import com.pulumi.plain.ResourceArgs; +import com.pulumi.plain.inputs.DataArgs; +import com.pulumi.plain.inputs.InnerDataArgs; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + var res = new Resource("res", ResourceArgs.builder() + .data(DataArgs.builder() + .innerData(InnerDataArgs.builder() + .boolean_(false) + .float_(2.17) + .integer(-12) + .string("Goodbye") + .boolArray( + false, + true) + .stringMap(Map.ofEntries( + Map.entry("two", "turtle doves"), + Map.entry("three", "french hens") + )) + .build()) + .boolean_(true) + .float_(4.5) + .integer(1024) + .string("Hello") + .boolArray( + true, + false) + .stringMap(Map.ofEntries( + Map.entry("x", "100"), + Map.entry("y", "200") + )) + .build()) + .build()); + + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/Pulumi.yaml b/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/Pulumi.yaml new file mode 100644 index 00000000000..e41010a1a86 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/Pulumi.yaml @@ -0,0 +1,2 @@ +name: l2-primitive-ref +runtime: java diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/pom.xml b/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/pom.xml new file mode 100644 index 00000000000..0fed0256f3c --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + com.pulumi + l2-primitive-ref + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + generated_program.App + + + + + + repository-0 + REPOSITORY + + + + + + com.pulumi + pulumi + CORE.VERSION + + + com.pulumi + primitive-ref + 11.0.0 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.1 + + 3.8.5 + + + + + \ No newline at end of file diff --git a/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/src/main/java/generated_program/App.java b/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/src/main/java/generated_program/App.java new file mode 100644 index 00000000000..b5a06423f53 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/projects/l2-primitive-ref/src/main/java/generated_program/App.java @@ -0,0 +1,39 @@ +package generated_program; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.primitiveref.Resource; +import com.pulumi.primitiveref.ResourceArgs; +import com.pulumi.primitiveref.inputs.DataArgs; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + var res = new Resource("res", ResourceArgs.builder() + .data(DataArgs.builder() + .boolean_(false) + .float_(2.17) + .integer(-12) + .string("Goodbye") + .boolArray( + false, + true) + .stringMap(Map.ofEntries( + Map.entry("two", "turtle doves"), + Map.entry("three", "french hens") + )) + .build()) + .build()); + + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/README.md b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/README.md new file mode 100644 index 00000000000..8d1c8b69c3f --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/README.md @@ -0,0 +1 @@ + diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/build.gradle b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/build.gradle new file mode 100644 index 00000000000..561ec5d93f6 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/build.gradle @@ -0,0 +1,157 @@ +// *** WARNING: this file was generated by pulumi-java-gen *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +plugins { + id("signing") + id("java-library") + id("maven-publish") +} + +group = "com.pulumi" + +def resolvedVersion = System.getenv("PACKAGE_VERSION") ?: + (project.version == "unspecified" + ? "13.0.0" + : project.version) + +def signingKey = System.getenv("SIGNING_KEY") +def signingPassword = System.getenv("SIGNING_PASSWORD") +def publishRepoURL = System.getenv("PUBLISH_REPO_URL") +def publishRepoUsername = System.getenv("PUBLISH_REPO_USERNAME") +def publishRepoPassword = System.getenv("PUBLISH_REPO_PASSWORD") + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + +compileJava { + options.fork = true + options.forkOptions.jvmArgs.addAll(["-Xmx16g"]) + options.encoding = "UTF-8" +} + +repositories { + maven { + url("REPOSITORY") + } + mavenLocal() + maven { // The google mirror is less flaky than mavenCentral() + url("https://maven-central.storage-download.googleapis.com/maven2/") + } + mavenCentral() +} + +dependencies { + implementation("com.google.code.findbugs:jsr305:3.0.2") + implementation("com.google.code.gson:gson:2.8.9") + implementation("com.pulumi:pulumi:CORE.VERSION") +} + +task sourcesJar(type: Jar) { + from sourceSets.main.allJava + archiveClassifier.set('sources') +} + +task javadocJar(type: Jar) { + from javadoc + archiveClassifier.set('javadoc') + zip64 = true +} + +def genPulumiResources = tasks.register('genPulumiResources') { + doLast { + def resourcesDir = sourceSets.main.output.resourcesDir + def subDir = project.name.replace(".", "/") + def outDir = file("$resourcesDir/$subDir") + outDir.mkdirs() + new File(outDir, "version.txt").text = resolvedVersion + def builder = new groovy.json.JsonBuilder() + builder { + resource true + name "plain" + version resolvedVersion + } + def infoJson = builder.toPrettyString() + new File(outDir, "plugin.json").text = infoJson + } +} + +jar.configure { + dependsOn genPulumiResources +} + +publishing { + publications { + mainPublication(MavenPublication) { + groupId = "com.pulumi" + artifactId = "plain" + version = resolvedVersion + from components.java + artifact sourcesJar + artifact javadocJar + + pom { + inceptionYear = "" + name = "" + packaging = "jar" + description = " " + + url = "https://example.com" + + scm { + connection = "https://example.com" + developerConnection = "https://example.com" + url = "https://example.com" + } + + licenses { + license { + name = "" + url = "" + } + } + + developers { + developer { + id = "" + name = "" + email = "" + } + } + } + } + } + + if (publishRepoURL) { + repositories { + maven { + name = "PublishRepo" + url = publishRepoURL + credentials { + username = publishRepoUsername + password = publishRepoPassword + } + } + } + } +} + +javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } + options.jFlags("-Xmx8g", "-Xms512m") +} + +jar { + zip64 = true +} + +if (signingKey) { + signing { + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications.mainPublication + } +} \ No newline at end of file diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/settings.gradle b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/settings.gradle new file mode 100644 index 00000000000..22486249500 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/settings.gradle @@ -0,0 +1,14 @@ +// *** WARNING: this file was generated by pulumi-java-gen. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +pluginManagement { + repositories { + maven { // The google mirror is less flaky than mavenCentral() + url("https://maven-central.storage-download.googleapis.com/maven2/") + } + gradlePluginPortal() + } +} + +rootProject.name = "com.pulumi.plain" +include("lib") diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Provider.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Provider.java new file mode 100644 index 00000000000..b3a1cd4bc69 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Provider.java @@ -0,0 +1,54 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.ResourceType; +import com.pulumi.core.internal.Codegen; +import com.pulumi.plain.ProviderArgs; +import com.pulumi.plain.Utilities; +import javax.annotation.Nullable; + +@ResourceType(type="pulumi:providers:plain") +public class Provider extends com.pulumi.resources.ProviderResource { + /** + * + * @param name The _unique_ name of the resulting resource. + */ + public Provider(java.lang.String name) { + this(name, ProviderArgs.Empty); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + */ + public Provider(java.lang.String name, @Nullable ProviderArgs args) { + this(name, args, null); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + * @param options A bag of options that control this resource's behavior. + */ + public Provider(java.lang.String name, @Nullable ProviderArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + super("plain", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); + } + + private static ProviderArgs makeArgs(@Nullable ProviderArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + if (options != null && options.getUrn().isPresent()) { + return null; + } + return args == null ? ProviderArgs.Empty : args; + } + + private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { + var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() + .version(Utilities.getVersion()) + .build(); + return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/ProviderArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/ProviderArgs.java new file mode 100644 index 00000000000..a5140bc3b7a --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/ProviderArgs.java @@ -0,0 +1,28 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain; + + + + +public final class ProviderArgs extends com.pulumi.resources.ResourceArgs { + + public static final ProviderArgs Empty = new ProviderArgs(); + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private ProviderArgs $; + + public Builder() { + $ = new ProviderArgs(); + } + public ProviderArgs build() { + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Resource.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Resource.java new file mode 100644 index 00000000000..96c7d42751e --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Resource.java @@ -0,0 +1,93 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Export; +import com.pulumi.core.annotations.ResourceType; +import com.pulumi.core.internal.Codegen; +import com.pulumi.plain.ResourceArgs; +import com.pulumi.plain.Utilities; +import com.pulumi.plain.outputs.Data; +import java.util.Optional; +import javax.annotation.Nullable; + +@ResourceType(type="plain:index:Resource") +public class Resource extends com.pulumi.resources.CustomResource { + @Export(name="data", refs={Data.class}, tree="[0]") + private Output data; + + public Output data() { + return this.data; + } + /** + * A non plain input to compare against the plain inputs, as well as testing plain/non-plain nesting. + * + */ + @Export(name="nonPlainData", refs={Data.class}, tree="[0]") + private Output nonPlainData; + + /** + * @return A non plain input to compare against the plain inputs, as well as testing plain/non-plain nesting. + * + */ + public Output> nonPlainData() { + return Codegen.optional(this.nonPlainData); + } + + /** + * + * @param name The _unique_ name of the resulting resource. + */ + public Resource(java.lang.String name) { + this(name, ResourceArgs.Empty); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + */ + public Resource(java.lang.String name, ResourceArgs args) { + this(name, args, null); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + * @param options A bag of options that control this resource's behavior. + */ + public Resource(java.lang.String name, ResourceArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + super("plain:index:Resource", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); + } + + private Resource(java.lang.String name, Output id, @Nullable com.pulumi.resources.CustomResourceOptions options) { + super("plain:index:Resource", name, null, makeResourceOptions(options, id), false); + } + + private static ResourceArgs makeArgs(ResourceArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + if (options != null && options.getUrn().isPresent()) { + return null; + } + return args == null ? ResourceArgs.Empty : args; + } + + private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { + var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() + .version(Utilities.getVersion()) + .build(); + return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); + } + + /** + * Get an existing Host resource's state with the given name, ID, and optional extra + * properties used to qualify the lookup. + * + * @param name The _unique_ name of the resulting resource. + * @param id The _unique_ provider ID of the resource to lookup. + * @param options Optional settings to control the behavior of the CustomResource. + */ + public static Resource get(java.lang.String name, Output id, @Nullable com.pulumi.resources.CustomResourceOptions options) { + return new Resource(name, id, options); + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/ResourceArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/ResourceArgs.java new file mode 100644 index 00000000000..590d7dee5b4 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/ResourceArgs.java @@ -0,0 +1,100 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Import; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import com.pulumi.plain.inputs.DataArgs; +import java.util.Objects; +import java.util.Optional; +import javax.annotation.Nullable; + + +public final class ResourceArgs extends com.pulumi.resources.ResourceArgs { + + public static final ResourceArgs Empty = new ResourceArgs(); + + @Import(name="data", required=true) + private DataArgs data; + + public DataArgs data() { + return this.data; + } + + /** + * A non plain input to compare against the plain inputs, as well as testing plain/non-plain nesting. + * + */ + @Import(name="nonPlainData") + private @Nullable Output nonPlainData; + + /** + * @return A non plain input to compare against the plain inputs, as well as testing plain/non-plain nesting. + * + */ + public Optional> nonPlainData() { + return Optional.ofNullable(this.nonPlainData); + } + + private ResourceArgs() {} + + private ResourceArgs(ResourceArgs $) { + this.data = $.data; + this.nonPlainData = $.nonPlainData; + } + + public static Builder builder() { + return new Builder(); + } + public static Builder builder(ResourceArgs defaults) { + return new Builder(defaults); + } + + public static final class Builder { + private ResourceArgs $; + + public Builder() { + $ = new ResourceArgs(); + } + + public Builder(ResourceArgs defaults) { + $ = new ResourceArgs(Objects.requireNonNull(defaults)); + } + + public Builder data(DataArgs data) { + $.data = data; + return this; + } + + /** + * @param nonPlainData A non plain input to compare against the plain inputs, as well as testing plain/non-plain nesting. + * + * @return builder + * + */ + public Builder nonPlainData(@Nullable Output nonPlainData) { + $.nonPlainData = nonPlainData; + return this; + } + + /** + * @param nonPlainData A non plain input to compare against the plain inputs, as well as testing plain/non-plain nesting. + * + * @return builder + * + */ + public Builder nonPlainData(DataArgs nonPlainData) { + return nonPlainData(Output.of(nonPlainData)); + } + + public ResourceArgs build() { + if ($.data == null) { + throw new MissingRequiredPropertyException("ResourceArgs", "data"); + } + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Utilities.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Utilities.java new file mode 100644 index 00000000000..731b9906003 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/Utilities.java @@ -0,0 +1,102 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain; + + + + + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.Nullable; +import com.pulumi.core.internal.Environment; +import com.pulumi.deployment.InvokeOptions; +import com.pulumi.deployment.InvokeOutputOptions; + +public class Utilities { + + public static Optional getEnv(java.lang.String... names) { + for (var n : names) { + var value = Environment.getEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static Optional getEnvBoolean(java.lang.String... names) { + for (var n : names) { + var value = Environment.getBooleanEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static Optional getEnvInteger(java.lang.String... names) { + for (var n : names) { + var value = Environment.getIntegerEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static Optional getEnvDouble(java.lang.String... names) { + for (var n : names) { + var value = Environment.getDoubleEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static InvokeOptions withVersion(@Nullable InvokeOptions options) { + if (options != null && options.getVersion().isPresent()) { + return options; + } + return new InvokeOptions( + options == null ? null : options.getParent().orElse(null), + options == null ? null : options.getProvider().orElse(null), + getVersion() + ); + } + + public static InvokeOutputOptions withVersion(@Nullable InvokeOutputOptions options) { + if (options != null && options.getVersion().isPresent()) { + return options; + } + return new InvokeOutputOptions( + options == null ? null : options.getParent().orElse(null), + options == null ? null : options.getProvider().orElse(null), + getVersion(), + options == null ? null : options.getDependsOn() + ); + } + + private static final java.lang.String version; + public static java.lang.String getVersion() { + return version; + } + + static { + var resourceName = "com/pulumi/plain/version.txt"; + var versionFile = Utilities.class.getClassLoader().getResourceAsStream(resourceName); + if (versionFile == null) { + throw new IllegalStateException( + java.lang.String.format("expected resource '%s' on Classpath, not found", resourceName) + ); + } + version = new BufferedReader(new InputStreamReader(versionFile)) + .lines() + .collect(Collectors.joining("\n")) + .trim(); + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/inputs/DataArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/inputs/DataArgs.java new file mode 100644 index 00000000000..d9ed3a4f9bd --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/inputs/DataArgs.java @@ -0,0 +1,166 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain.inputs; + +import com.pulumi.core.annotations.Import; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import com.pulumi.plain.inputs.InnerDataArgs; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Objects; + + +public final class DataArgs extends com.pulumi.resources.ResourceArgs { + + public static final DataArgs Empty = new DataArgs(); + + @Import(name="boolArray", required=true) + private List boolArray; + + public List boolArray() { + return this.boolArray; + } + + @Import(name="boolean", required=true) + private Boolean boolean_; + + public Boolean boolean_() { + return this.boolean_; + } + + @Import(name="float", required=true) + private Double float_; + + public Double float_() { + return this.float_; + } + + @Import(name="innerData", required=true) + private InnerDataArgs innerData; + + public InnerDataArgs innerData() { + return this.innerData; + } + + @Import(name="integer", required=true) + private Integer integer; + + public Integer integer() { + return this.integer; + } + + @Import(name="string", required=true) + private String string; + + public String string() { + return this.string; + } + + @Import(name="stringMap", required=true) + private Map stringMap; + + public Map stringMap() { + return this.stringMap; + } + + private DataArgs() {} + + private DataArgs(DataArgs $) { + this.boolArray = $.boolArray; + this.boolean_ = $.boolean_; + this.float_ = $.float_; + this.innerData = $.innerData; + this.integer = $.integer; + this.string = $.string; + this.stringMap = $.stringMap; + } + + public static Builder builder() { + return new Builder(); + } + public static Builder builder(DataArgs defaults) { + return new Builder(defaults); + } + + public static final class Builder { + private DataArgs $; + + public Builder() { + $ = new DataArgs(); + } + + public Builder(DataArgs defaults) { + $ = new DataArgs(Objects.requireNonNull(defaults)); + } + + public Builder boolArray(List boolArray) { + $.boolArray = boolArray; + return this; + } + + public Builder boolArray(Boolean... boolArray) { + return boolArray(List.of(boolArray)); + } + + public Builder boolean_(Boolean boolean_) { + $.boolean_ = boolean_; + return this; + } + + public Builder float_(Double float_) { + $.float_ = float_; + return this; + } + + public Builder innerData(InnerDataArgs innerData) { + $.innerData = innerData; + return this; + } + + public Builder integer(Integer integer) { + $.integer = integer; + return this; + } + + public Builder string(String string) { + $.string = string; + return this; + } + + public Builder stringMap(Map stringMap) { + $.stringMap = stringMap; + return this; + } + + public DataArgs build() { + if ($.boolArray == null) { + throw new MissingRequiredPropertyException("DataArgs", "boolArray"); + } + if ($.boolean_ == null) { + throw new MissingRequiredPropertyException("DataArgs", "boolean_"); + } + if ($.float_ == null) { + throw new MissingRequiredPropertyException("DataArgs", "float_"); + } + if ($.innerData == null) { + throw new MissingRequiredPropertyException("DataArgs", "innerData"); + } + if ($.integer == null) { + throw new MissingRequiredPropertyException("DataArgs", "integer"); + } + if ($.string == null) { + throw new MissingRequiredPropertyException("DataArgs", "string"); + } + if ($.stringMap == null) { + throw new MissingRequiredPropertyException("DataArgs", "stringMap"); + } + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/inputs/InnerDataArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/inputs/InnerDataArgs.java new file mode 100644 index 00000000000..249c7dcbd1f --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/inputs/InnerDataArgs.java @@ -0,0 +1,149 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain.inputs; + +import com.pulumi.core.annotations.Import; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Objects; + + +public final class InnerDataArgs extends com.pulumi.resources.ResourceArgs { + + public static final InnerDataArgs Empty = new InnerDataArgs(); + + @Import(name="boolArray", required=true) + private List boolArray; + + public List boolArray() { + return this.boolArray; + } + + @Import(name="boolean", required=true) + private Boolean boolean_; + + public Boolean boolean_() { + return this.boolean_; + } + + @Import(name="float", required=true) + private Double float_; + + public Double float_() { + return this.float_; + } + + @Import(name="integer", required=true) + private Integer integer; + + public Integer integer() { + return this.integer; + } + + @Import(name="string", required=true) + private String string; + + public String string() { + return this.string; + } + + @Import(name="stringMap", required=true) + private Map stringMap; + + public Map stringMap() { + return this.stringMap; + } + + private InnerDataArgs() {} + + private InnerDataArgs(InnerDataArgs $) { + this.boolArray = $.boolArray; + this.boolean_ = $.boolean_; + this.float_ = $.float_; + this.integer = $.integer; + this.string = $.string; + this.stringMap = $.stringMap; + } + + public static Builder builder() { + return new Builder(); + } + public static Builder builder(InnerDataArgs defaults) { + return new Builder(defaults); + } + + public static final class Builder { + private InnerDataArgs $; + + public Builder() { + $ = new InnerDataArgs(); + } + + public Builder(InnerDataArgs defaults) { + $ = new InnerDataArgs(Objects.requireNonNull(defaults)); + } + + public Builder boolArray(List boolArray) { + $.boolArray = boolArray; + return this; + } + + public Builder boolArray(Boolean... boolArray) { + return boolArray(List.of(boolArray)); + } + + public Builder boolean_(Boolean boolean_) { + $.boolean_ = boolean_; + return this; + } + + public Builder float_(Double float_) { + $.float_ = float_; + return this; + } + + public Builder integer(Integer integer) { + $.integer = integer; + return this; + } + + public Builder string(String string) { + $.string = string; + return this; + } + + public Builder stringMap(Map stringMap) { + $.stringMap = stringMap; + return this; + } + + public InnerDataArgs build() { + if ($.boolArray == null) { + throw new MissingRequiredPropertyException("InnerDataArgs", "boolArray"); + } + if ($.boolean_ == null) { + throw new MissingRequiredPropertyException("InnerDataArgs", "boolean_"); + } + if ($.float_ == null) { + throw new MissingRequiredPropertyException("InnerDataArgs", "float_"); + } + if ($.integer == null) { + throw new MissingRequiredPropertyException("InnerDataArgs", "integer"); + } + if ($.string == null) { + throw new MissingRequiredPropertyException("InnerDataArgs", "string"); + } + if ($.stringMap == null) { + throw new MissingRequiredPropertyException("InnerDataArgs", "stringMap"); + } + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/outputs/Data.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/outputs/Data.java new file mode 100644 index 00000000000..16c2ecf1562 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/outputs/Data.java @@ -0,0 +1,149 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain.outputs; + +import com.pulumi.core.annotations.CustomType; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import com.pulumi.plain.outputs.InnerData; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@CustomType +public final class Data { + private List boolArray; + private Boolean boolean_; + private Double float_; + private InnerData innerData; + private Integer integer; + private String string; + private Map stringMap; + + private Data() {} + public List boolArray() { + return this.boolArray; + } + public Boolean boolean_() { + return this.boolean_; + } + public Double float_() { + return this.float_; + } + public InnerData innerData() { + return this.innerData; + } + public Integer integer() { + return this.integer; + } + public String string() { + return this.string; + } + public Map stringMap() { + return this.stringMap; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(Data defaults) { + return new Builder(defaults); + } + @CustomType.Builder + public static final class Builder { + private List boolArray; + private Boolean boolean_; + private Double float_; + private InnerData innerData; + private Integer integer; + private String string; + private Map stringMap; + public Builder() {} + public Builder(Data defaults) { + Objects.requireNonNull(defaults); + this.boolArray = defaults.boolArray; + this.boolean_ = defaults.boolean_; + this.float_ = defaults.float_; + this.innerData = defaults.innerData; + this.integer = defaults.integer; + this.string = defaults.string; + this.stringMap = defaults.stringMap; + } + + @CustomType.Setter + public Builder boolArray(List boolArray) { + if (boolArray == null) { + throw new MissingRequiredPropertyException("Data", "boolArray"); + } + this.boolArray = boolArray; + return this; + } + public Builder boolArray(Boolean... boolArray) { + return boolArray(List.of(boolArray)); + } + @CustomType.Setter("boolean") + public Builder boolean_(Boolean boolean_) { + if (boolean_ == null) { + throw new MissingRequiredPropertyException("Data", "boolean_"); + } + this.boolean_ = boolean_; + return this; + } + @CustomType.Setter("float") + public Builder float_(Double float_) { + if (float_ == null) { + throw new MissingRequiredPropertyException("Data", "float_"); + } + this.float_ = float_; + return this; + } + @CustomType.Setter + public Builder innerData(InnerData innerData) { + if (innerData == null) { + throw new MissingRequiredPropertyException("Data", "innerData"); + } + this.innerData = innerData; + return this; + } + @CustomType.Setter + public Builder integer(Integer integer) { + if (integer == null) { + throw new MissingRequiredPropertyException("Data", "integer"); + } + this.integer = integer; + return this; + } + @CustomType.Setter + public Builder string(String string) { + if (string == null) { + throw new MissingRequiredPropertyException("Data", "string"); + } + this.string = string; + return this; + } + @CustomType.Setter + public Builder stringMap(Map stringMap) { + if (stringMap == null) { + throw new MissingRequiredPropertyException("Data", "stringMap"); + } + this.stringMap = stringMap; + return this; + } + public Data build() { + final var _resultValue = new Data(); + _resultValue.boolArray = boolArray; + _resultValue.boolean_ = boolean_; + _resultValue.float_ = float_; + _resultValue.innerData = innerData; + _resultValue.integer = integer; + _resultValue.string = string; + _resultValue.stringMap = stringMap; + return _resultValue; + } + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/outputs/InnerData.java b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/outputs/InnerData.java new file mode 100644 index 00000000000..b5245d32fb8 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/plain-13.0.0/src/main/java/com/pulumi/plain/outputs/InnerData.java @@ -0,0 +1,133 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.plain.outputs; + +import com.pulumi.core.annotations.CustomType; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@CustomType +public final class InnerData { + private List boolArray; + private Boolean boolean_; + private Double float_; + private Integer integer; + private String string; + private Map stringMap; + + private InnerData() {} + public List boolArray() { + return this.boolArray; + } + public Boolean boolean_() { + return this.boolean_; + } + public Double float_() { + return this.float_; + } + public Integer integer() { + return this.integer; + } + public String string() { + return this.string; + } + public Map stringMap() { + return this.stringMap; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(InnerData defaults) { + return new Builder(defaults); + } + @CustomType.Builder + public static final class Builder { + private List boolArray; + private Boolean boolean_; + private Double float_; + private Integer integer; + private String string; + private Map stringMap; + public Builder() {} + public Builder(InnerData defaults) { + Objects.requireNonNull(defaults); + this.boolArray = defaults.boolArray; + this.boolean_ = defaults.boolean_; + this.float_ = defaults.float_; + this.integer = defaults.integer; + this.string = defaults.string; + this.stringMap = defaults.stringMap; + } + + @CustomType.Setter + public Builder boolArray(List boolArray) { + if (boolArray == null) { + throw new MissingRequiredPropertyException("InnerData", "boolArray"); + } + this.boolArray = boolArray; + return this; + } + public Builder boolArray(Boolean... boolArray) { + return boolArray(List.of(boolArray)); + } + @CustomType.Setter("boolean") + public Builder boolean_(Boolean boolean_) { + if (boolean_ == null) { + throw new MissingRequiredPropertyException("InnerData", "boolean_"); + } + this.boolean_ = boolean_; + return this; + } + @CustomType.Setter("float") + public Builder float_(Double float_) { + if (float_ == null) { + throw new MissingRequiredPropertyException("InnerData", "float_"); + } + this.float_ = float_; + return this; + } + @CustomType.Setter + public Builder integer(Integer integer) { + if (integer == null) { + throw new MissingRequiredPropertyException("InnerData", "integer"); + } + this.integer = integer; + return this; + } + @CustomType.Setter + public Builder string(String string) { + if (string == null) { + throw new MissingRequiredPropertyException("InnerData", "string"); + } + this.string = string; + return this; + } + @CustomType.Setter + public Builder stringMap(Map stringMap) { + if (stringMap == null) { + throw new MissingRequiredPropertyException("InnerData", "stringMap"); + } + this.stringMap = stringMap; + return this; + } + public InnerData build() { + final var _resultValue = new InnerData(); + _resultValue.boolArray = boolArray; + _resultValue.boolean_ = boolean_; + _resultValue.float_ = float_; + _resultValue.integer = integer; + _resultValue.string = string; + _resultValue.stringMap = stringMap; + return _resultValue; + } + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/README.md b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/README.md new file mode 100644 index 00000000000..8d1c8b69c3f --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/README.md @@ -0,0 +1 @@ + diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/build.gradle b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/build.gradle new file mode 100644 index 00000000000..27715ed5ac2 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/build.gradle @@ -0,0 +1,157 @@ +// *** WARNING: this file was generated by pulumi-java-gen *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +plugins { + id("signing") + id("java-library") + id("maven-publish") +} + +group = "com.pulumi" + +def resolvedVersion = System.getenv("PACKAGE_VERSION") ?: + (project.version == "unspecified" + ? "11.0.0" + : project.version) + +def signingKey = System.getenv("SIGNING_KEY") +def signingPassword = System.getenv("SIGNING_PASSWORD") +def publishRepoURL = System.getenv("PUBLISH_REPO_URL") +def publishRepoUsername = System.getenv("PUBLISH_REPO_USERNAME") +def publishRepoPassword = System.getenv("PUBLISH_REPO_PASSWORD") + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } +} + +compileJava { + options.fork = true + options.forkOptions.jvmArgs.addAll(["-Xmx16g"]) + options.encoding = "UTF-8" +} + +repositories { + maven { + url("REPOSITORY") + } + mavenLocal() + maven { // The google mirror is less flaky than mavenCentral() + url("https://maven-central.storage-download.googleapis.com/maven2/") + } + mavenCentral() +} + +dependencies { + implementation("com.google.code.findbugs:jsr305:3.0.2") + implementation("com.google.code.gson:gson:2.8.9") + implementation("com.pulumi:pulumi:CORE.VERSION") +} + +task sourcesJar(type: Jar) { + from sourceSets.main.allJava + archiveClassifier.set('sources') +} + +task javadocJar(type: Jar) { + from javadoc + archiveClassifier.set('javadoc') + zip64 = true +} + +def genPulumiResources = tasks.register('genPulumiResources') { + doLast { + def resourcesDir = sourceSets.main.output.resourcesDir + def subDir = project.name.replace(".", "/") + def outDir = file("$resourcesDir/$subDir") + outDir.mkdirs() + new File(outDir, "version.txt").text = resolvedVersion + def builder = new groovy.json.JsonBuilder() + builder { + resource true + name "primitive-ref" + version resolvedVersion + } + def infoJson = builder.toPrettyString() + new File(outDir, "plugin.json").text = infoJson + } +} + +jar.configure { + dependsOn genPulumiResources +} + +publishing { + publications { + mainPublication(MavenPublication) { + groupId = "com.pulumi" + artifactId = "primitive-ref" + version = resolvedVersion + from components.java + artifact sourcesJar + artifact javadocJar + + pom { + inceptionYear = "" + name = "" + packaging = "jar" + description = " " + + url = "https://example.com" + + scm { + connection = "https://example.com" + developerConnection = "https://example.com" + url = "https://example.com" + } + + licenses { + license { + name = "" + url = "" + } + } + + developers { + developer { + id = "" + name = "" + email = "" + } + } + } + } + } + + if (publishRepoURL) { + repositories { + maven { + name = "PublishRepo" + url = publishRepoURL + credentials { + username = publishRepoUsername + password = publishRepoPassword + } + } + } + } +} + +javadoc { + if (JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } + options.jFlags("-Xmx8g", "-Xms512m") +} + +jar { + zip64 = true +} + +if (signingKey) { + signing { + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications.mainPublication + } +} \ No newline at end of file diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/settings.gradle b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/settings.gradle new file mode 100644 index 00000000000..1cfa0d1c16f --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/settings.gradle @@ -0,0 +1,14 @@ +// *** WARNING: this file was generated by pulumi-java-gen. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +pluginManagement { + repositories { + maven { // The google mirror is less flaky than mavenCentral() + url("https://maven-central.storage-download.googleapis.com/maven2/") + } + gradlePluginPortal() + } +} + +rootProject.name = "com.pulumi.primitive-ref" +include("lib") diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Provider.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Provider.java new file mode 100644 index 00000000000..351bc345203 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Provider.java @@ -0,0 +1,54 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.ResourceType; +import com.pulumi.core.internal.Codegen; +import com.pulumi.primitiveref.ProviderArgs; +import com.pulumi.primitiveref.Utilities; +import javax.annotation.Nullable; + +@ResourceType(type="pulumi:providers:primitive-ref") +public class Provider extends com.pulumi.resources.ProviderResource { + /** + * + * @param name The _unique_ name of the resulting resource. + */ + public Provider(java.lang.String name) { + this(name, ProviderArgs.Empty); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + */ + public Provider(java.lang.String name, @Nullable ProviderArgs args) { + this(name, args, null); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + * @param options A bag of options that control this resource's behavior. + */ + public Provider(java.lang.String name, @Nullable ProviderArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + super("primitive-ref", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); + } + + private static ProviderArgs makeArgs(@Nullable ProviderArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + if (options != null && options.getUrn().isPresent()) { + return null; + } + return args == null ? ProviderArgs.Empty : args; + } + + private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { + var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() + .version(Utilities.getVersion()) + .build(); + return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/ProviderArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/ProviderArgs.java new file mode 100644 index 00000000000..b4015dccb7b --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/ProviderArgs.java @@ -0,0 +1,28 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref; + + + + +public final class ProviderArgs extends com.pulumi.resources.ResourceArgs { + + public static final ProviderArgs Empty = new ProviderArgs(); + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private ProviderArgs $; + + public Builder() { + $ = new ProviderArgs(); + } + public ProviderArgs build() { + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Resource.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Resource.java new file mode 100644 index 00000000000..aba8910411e --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Resource.java @@ -0,0 +1,78 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Export; +import com.pulumi.core.annotations.ResourceType; +import com.pulumi.core.internal.Codegen; +import com.pulumi.primitiveref.ResourceArgs; +import com.pulumi.primitiveref.Utilities; +import com.pulumi.primitiveref.outputs.Data; +import javax.annotation.Nullable; + +@ResourceType(type="primitive-ref:index:Resource") +public class Resource extends com.pulumi.resources.CustomResource { + @Export(name="data", refs={Data.class}, tree="[0]") + private Output data; + + public Output data() { + return this.data; + } + + /** + * + * @param name The _unique_ name of the resulting resource. + */ + public Resource(java.lang.String name) { + this(name, ResourceArgs.Empty); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + */ + public Resource(java.lang.String name, ResourceArgs args) { + this(name, args, null); + } + /** + * + * @param name The _unique_ name of the resulting resource. + * @param args The arguments to use to populate this resource's properties. + * @param options A bag of options that control this resource's behavior. + */ + public Resource(java.lang.String name, ResourceArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + super("primitive-ref:index:Resource", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); + } + + private Resource(java.lang.String name, Output id, @Nullable com.pulumi.resources.CustomResourceOptions options) { + super("primitive-ref:index:Resource", name, null, makeResourceOptions(options, id), false); + } + + private static ResourceArgs makeArgs(ResourceArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { + if (options != null && options.getUrn().isPresent()) { + return null; + } + return args == null ? ResourceArgs.Empty : args; + } + + private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { + var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() + .version(Utilities.getVersion()) + .build(); + return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); + } + + /** + * Get an existing Host resource's state with the given name, ID, and optional extra + * properties used to qualify the lookup. + * + * @param name The _unique_ name of the resulting resource. + * @param id The _unique_ provider ID of the resource to lookup. + * @param options Optional settings to control the behavior of the CustomResource. + */ + public static Resource get(java.lang.String name, Output id, @Nullable com.pulumi.resources.CustomResourceOptions options) { + return new Resource(name, id, options); + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/ResourceArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/ResourceArgs.java new file mode 100644 index 00000000000..a893a45b429 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/ResourceArgs.java @@ -0,0 +1,65 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Import; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import com.pulumi.primitiveref.inputs.DataArgs; +import java.util.Objects; + + +public final class ResourceArgs extends com.pulumi.resources.ResourceArgs { + + public static final ResourceArgs Empty = new ResourceArgs(); + + @Import(name="data", required=true) + private Output data; + + public Output data() { + return this.data; + } + + private ResourceArgs() {} + + private ResourceArgs(ResourceArgs $) { + this.data = $.data; + } + + public static Builder builder() { + return new Builder(); + } + public static Builder builder(ResourceArgs defaults) { + return new Builder(defaults); + } + + public static final class Builder { + private ResourceArgs $; + + public Builder() { + $ = new ResourceArgs(); + } + + public Builder(ResourceArgs defaults) { + $ = new ResourceArgs(Objects.requireNonNull(defaults)); + } + + public Builder data(Output data) { + $.data = data; + return this; + } + + public Builder data(DataArgs data) { + return data(Output.of(data)); + } + + public ResourceArgs build() { + if ($.data == null) { + throw new MissingRequiredPropertyException("ResourceArgs", "data"); + } + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Utilities.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Utilities.java new file mode 100644 index 00000000000..cd07b47762f --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/Utilities.java @@ -0,0 +1,102 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref; + + + + + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.Nullable; +import com.pulumi.core.internal.Environment; +import com.pulumi.deployment.InvokeOptions; +import com.pulumi.deployment.InvokeOutputOptions; + +public class Utilities { + + public static Optional getEnv(java.lang.String... names) { + for (var n : names) { + var value = Environment.getEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static Optional getEnvBoolean(java.lang.String... names) { + for (var n : names) { + var value = Environment.getBooleanEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static Optional getEnvInteger(java.lang.String... names) { + for (var n : names) { + var value = Environment.getIntegerEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static Optional getEnvDouble(java.lang.String... names) { + for (var n : names) { + var value = Environment.getDoubleEnvironmentVariable(n); + if (value.isValue()) { + return Optional.of(value.value()); + } + } + return Optional.empty(); + } + + public static InvokeOptions withVersion(@Nullable InvokeOptions options) { + if (options != null && options.getVersion().isPresent()) { + return options; + } + return new InvokeOptions( + options == null ? null : options.getParent().orElse(null), + options == null ? null : options.getProvider().orElse(null), + getVersion() + ); + } + + public static InvokeOutputOptions withVersion(@Nullable InvokeOutputOptions options) { + if (options != null && options.getVersion().isPresent()) { + return options; + } + return new InvokeOutputOptions( + options == null ? null : options.getParent().orElse(null), + options == null ? null : options.getProvider().orElse(null), + getVersion(), + options == null ? null : options.getDependsOn() + ); + } + + private static final java.lang.String version; + public static java.lang.String getVersion() { + return version; + } + + static { + var resourceName = "com/pulumi/primitive-ref/version.txt"; + var versionFile = Utilities.class.getClassLoader().getResourceAsStream(resourceName); + if (versionFile == null) { + throw new IllegalStateException( + java.lang.String.format("expected resource '%s' on Classpath, not found", resourceName) + ); + } + version = new BufferedReader(new InputStreamReader(versionFile)) + .lines() + .collect(Collectors.joining("\n")) + .trim(); + } +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/inputs/DataArgs.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/inputs/DataArgs.java new file mode 100644 index 00000000000..af4849399b4 --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/inputs/DataArgs.java @@ -0,0 +1,174 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref.inputs; + +import com.pulumi.core.Output; +import com.pulumi.core.annotations.Import; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Objects; + + +public final class DataArgs extends com.pulumi.resources.ResourceArgs { + + public static final DataArgs Empty = new DataArgs(); + + @Import(name="boolArray", required=true) + private Output> boolArray; + + public Output> boolArray() { + return this.boolArray; + } + + @Import(name="boolean", required=true) + private Output boolean_; + + public Output boolean_() { + return this.boolean_; + } + + @Import(name="float", required=true) + private Output float_; + + public Output float_() { + return this.float_; + } + + @Import(name="integer", required=true) + private Output integer; + + public Output integer() { + return this.integer; + } + + @Import(name="string", required=true) + private Output string; + + public Output string() { + return this.string; + } + + @Import(name="stringMap", required=true) + private Output> stringMap; + + public Output> stringMap() { + return this.stringMap; + } + + private DataArgs() {} + + private DataArgs(DataArgs $) { + this.boolArray = $.boolArray; + this.boolean_ = $.boolean_; + this.float_ = $.float_; + this.integer = $.integer; + this.string = $.string; + this.stringMap = $.stringMap; + } + + public static Builder builder() { + return new Builder(); + } + public static Builder builder(DataArgs defaults) { + return new Builder(defaults); + } + + public static final class Builder { + private DataArgs $; + + public Builder() { + $ = new DataArgs(); + } + + public Builder(DataArgs defaults) { + $ = new DataArgs(Objects.requireNonNull(defaults)); + } + + public Builder boolArray(Output> boolArray) { + $.boolArray = boolArray; + return this; + } + + public Builder boolArray(List boolArray) { + return boolArray(Output.of(boolArray)); + } + + public Builder boolArray(Boolean... boolArray) { + return boolArray(List.of(boolArray)); + } + + public Builder boolean_(Output boolean_) { + $.boolean_ = boolean_; + return this; + } + + public Builder boolean_(Boolean boolean_) { + return boolean_(Output.of(boolean_)); + } + + public Builder float_(Output float_) { + $.float_ = float_; + return this; + } + + public Builder float_(Double float_) { + return float_(Output.of(float_)); + } + + public Builder integer(Output integer) { + $.integer = integer; + return this; + } + + public Builder integer(Integer integer) { + return integer(Output.of(integer)); + } + + public Builder string(Output string) { + $.string = string; + return this; + } + + public Builder string(String string) { + return string(Output.of(string)); + } + + public Builder stringMap(Output> stringMap) { + $.stringMap = stringMap; + return this; + } + + public Builder stringMap(Map stringMap) { + return stringMap(Output.of(stringMap)); + } + + public DataArgs build() { + if ($.boolArray == null) { + throw new MissingRequiredPropertyException("DataArgs", "boolArray"); + } + if ($.boolean_ == null) { + throw new MissingRequiredPropertyException("DataArgs", "boolean_"); + } + if ($.float_ == null) { + throw new MissingRequiredPropertyException("DataArgs", "float_"); + } + if ($.integer == null) { + throw new MissingRequiredPropertyException("DataArgs", "integer"); + } + if ($.string == null) { + throw new MissingRequiredPropertyException("DataArgs", "string"); + } + if ($.stringMap == null) { + throw new MissingRequiredPropertyException("DataArgs", "stringMap"); + } + return $; + } + } + +} diff --git a/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/outputs/Data.java b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/outputs/Data.java new file mode 100644 index 00000000000..d2a496bbe5a --- /dev/null +++ b/pkg/cmd/pulumi-language-java/testdata/sdks/primitive-ref-11.0.0/src/main/java/com/pulumi/primitiveref/outputs/Data.java @@ -0,0 +1,133 @@ +// *** WARNING: this file was generated by pulumi-language-java. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package com.pulumi.primitiveref.outputs; + +import com.pulumi.core.annotations.CustomType; +import com.pulumi.exceptions.MissingRequiredPropertyException; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@CustomType +public final class Data { + private List boolArray; + private Boolean boolean_; + private Double float_; + private Integer integer; + private String string; + private Map stringMap; + + private Data() {} + public List boolArray() { + return this.boolArray; + } + public Boolean boolean_() { + return this.boolean_; + } + public Double float_() { + return this.float_; + } + public Integer integer() { + return this.integer; + } + public String string() { + return this.string; + } + public Map stringMap() { + return this.stringMap; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(Data defaults) { + return new Builder(defaults); + } + @CustomType.Builder + public static final class Builder { + private List boolArray; + private Boolean boolean_; + private Double float_; + private Integer integer; + private String string; + private Map stringMap; + public Builder() {} + public Builder(Data defaults) { + Objects.requireNonNull(defaults); + this.boolArray = defaults.boolArray; + this.boolean_ = defaults.boolean_; + this.float_ = defaults.float_; + this.integer = defaults.integer; + this.string = defaults.string; + this.stringMap = defaults.stringMap; + } + + @CustomType.Setter + public Builder boolArray(List boolArray) { + if (boolArray == null) { + throw new MissingRequiredPropertyException("Data", "boolArray"); + } + this.boolArray = boolArray; + return this; + } + public Builder boolArray(Boolean... boolArray) { + return boolArray(List.of(boolArray)); + } + @CustomType.Setter("boolean") + public Builder boolean_(Boolean boolean_) { + if (boolean_ == null) { + throw new MissingRequiredPropertyException("Data", "boolean_"); + } + this.boolean_ = boolean_; + return this; + } + @CustomType.Setter("float") + public Builder float_(Double float_) { + if (float_ == null) { + throw new MissingRequiredPropertyException("Data", "float_"); + } + this.float_ = float_; + return this; + } + @CustomType.Setter + public Builder integer(Integer integer) { + if (integer == null) { + throw new MissingRequiredPropertyException("Data", "integer"); + } + this.integer = integer; + return this; + } + @CustomType.Setter + public Builder string(String string) { + if (string == null) { + throw new MissingRequiredPropertyException("Data", "string"); + } + this.string = string; + return this; + } + @CustomType.Setter + public Builder stringMap(Map stringMap) { + if (stringMap == null) { + throw new MissingRequiredPropertyException("Data", "stringMap"); + } + this.stringMap = stringMap; + return this; + } + public Data build() { + final var _resultValue = new Data(); + _resultValue.boolArray = boolArray; + _resultValue.boolean_ = boolean_; + _resultValue.float_ = float_; + _resultValue.integer = integer; + _resultValue.string = string; + _resultValue.stringMap = stringMap; + return _resultValue; + } + } +}