Skip to content

Commit f8c0c05

Browse files
authored
java: import packages from com.<namespace>... (#1719)
Currently all packages are namespaced in the `com.pulumi` namespace, unless explicitly overridden in the package info. Use the new namespace field to import packages from `com.<namespace>`. Depends on #1714
1 parent a788911 commit f8c0c05

File tree

56 files changed

+2277
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2277
-37
lines changed

pkg/cmd/pulumi-java-gen/command.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func newVersionCommand() *cobra.Command {
4848
Use: "version",
4949
Short: "Print pulumi-java-gen version number",
5050
Args: cmdutil.NoArgs,
51-
Run: cmdutil.RunFunc(func(_ *cobra.Command, _ []string) error {
51+
RunE: func(_ *cobra.Command, _ []string) error {
5252
fmt.Printf("%v\n", version.Version)
5353
return nil
54-
}),
54+
},
5555
}
5656
}
5757

@@ -110,7 +110,7 @@ See https://www.pulumi.com/docs/guides/pulumi-packages/schema/#language-specific
110110
cmd.Flags().BoolVar(&local, "local", false,
111111
"generate an SDK suitable for local consumption")
112112

113-
cmd.Run = cmdutil.RunFunc(func(_ *cobra.Command, _ []string) error {
113+
cmd.RunE = func(_ *cobra.Command, _ []string) error {
114114
rootDir, err := os.Getwd()
115115
if err != nil {
116116
return err
@@ -159,7 +159,7 @@ See https://www.pulumi.com/docs/guides/pulumi-packages/schema/#language-specific
159159
}
160160

161161
return generateJava(opts)
162-
})
162+
}
163163

164164
return cmd
165165
}

pkg/cmd/pulumi-language-java/language_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func TestLanguage(t *testing.T) {
160160
// expectedFailures maps the set of conformance tests we expect to fail to reasons they currently do so, so that we may
161161
// skip them with an informative message until they are fixed.
162162
var expectedFailures = map[string]string{
163+
"l1-builtin-project-root": "TODO: call rootDirectory",
163164
"l1-builtin-try": "#1683 Fix l1-builtin-try/can",
164165
"l1-builtin-can": "#1683 Fix l1-builtin-try/can",
165166
"l1-keyword-overlap": "#1681 Fix l1-keyword-overlap",
@@ -174,6 +175,9 @@ var expectedFailures = map[string]string{
174175
"l2-component-component-resource-ref": "components with resources as inputs/outputs not supported",
175176
"l2-component-program-resource-ref": "components with resources as inputs/outputs not supported",
176177
"l2-resource-secret": "#1564 Fix l2-resource-secret",
178+
"l2-resource-parent-inheritance": "Fix l2-resource-parent-inheritance",
179+
"l2-component-property-deps": "compilation error",
180+
"l2-parameterized-resource": "compilation error",
177181
}
178182

179183
// runTestingHost boots up a new instance of the language conformance test runner, `pulumi-test-language`, as well as a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: l1-builtin-project-root
2+
runtime: java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.pulumi</groupId>
8+
<artifactId>l1-builtin-project-root</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<encoding>UTF-8</encoding>
13+
<maven.compiler.source>11</maven.compiler.source>
14+
<maven.compiler.target>11</maven.compiler.target>
15+
<maven.compiler.release>11</maven.compiler.release>
16+
<mainClass>generated_program.App</mainClass>
17+
<mainArgs/>
18+
</properties>
19+
20+
<repositories>
21+
<repository>
22+
<id>repository-0</id>
23+
<url>REPOSITORY</url>
24+
</repository>
25+
</repositories>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>com.pulumi</groupId>
30+
<artifactId>pulumi</artifactId>
31+
<version>CORE.VERSION</version>
32+
</dependency>
33+
34+
</dependencies>
35+
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-jar-plugin</artifactId>
41+
<version>3.2.2</version>
42+
<configuration>
43+
<archive>
44+
<manifest>
45+
<addClasspath>true</addClasspath>
46+
<mainClass>${mainClass}</mainClass>
47+
</manifest>
48+
</archive>
49+
</configuration>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-assembly-plugin</artifactId>
54+
<version>3.4.2</version>
55+
<configuration>
56+
<archive>
57+
<manifest>
58+
<addClasspath>true</addClasspath>
59+
<mainClass>${mainClass}</mainClass>
60+
</manifest>
61+
</archive>
62+
<descriptorRefs>
63+
<descriptorRef>jar-with-dependencies</descriptorRef>
64+
</descriptorRefs>
65+
</configuration>
66+
<executions>
67+
<execution>
68+
<id>make-my-jar-with-dependencies</id>
69+
<phase>package</phase>
70+
<goals>
71+
<goal>single</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
76+
<plugin>
77+
<groupId>org.codehaus.mojo</groupId>
78+
<artifactId>exec-maven-plugin</artifactId>
79+
<version>3.1.0</version>
80+
<configuration>
81+
<mainClass>${mainClass}</mainClass>
82+
<commandlineArgs>${mainArgs}</commandlineArgs>
83+
</configuration>
84+
</plugin>
85+
<plugin>
86+
<groupId>org.apache.maven.plugins</groupId>
87+
<artifactId>maven-wrapper-plugin</artifactId>
88+
<version>3.1.1</version>
89+
<configuration>
90+
<mavenVersion>3.8.5</mavenVersion>
91+
</configuration>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package generated_program;
2+
3+
import com.pulumi.Context;
4+
import com.pulumi.Pulumi;
5+
import com.pulumi.core.Output;
6+
import java.util.List;
7+
import java.util.ArrayList;
8+
import java.util.Map;
9+
import java.io.File;
10+
import java.nio.file.Files;
11+
import java.nio.file.Paths;
12+
13+
public class App {
14+
public static void main(String[] args) {
15+
Pulumi.run(App::stack);
16+
}
17+
18+
public static void stack(Context ctx) {
19+
ctx.export("rootDirectoryOutput", "TODO: call rootDirectory");
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: l2-component-property-deps
2+
runtime: java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.pulumi</groupId>
8+
<artifactId>l2-component-property-deps</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<encoding>UTF-8</encoding>
13+
<maven.compiler.source>11</maven.compiler.source>
14+
<maven.compiler.target>11</maven.compiler.target>
15+
<maven.compiler.release>11</maven.compiler.release>
16+
<mainClass>generated_program.App</mainClass>
17+
<mainArgs/>
18+
</properties>
19+
20+
<repositories>
21+
<repository>
22+
<id>repository-0</id>
23+
<url>REPOSITORY</url>
24+
</repository>
25+
</repositories>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>com.pulumi</groupId>
30+
<artifactId>pulumi</artifactId>
31+
<version>CORE.VERSION</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.pulumi</groupId>
35+
<artifactId>component-property-deps</artifactId>
36+
<version>1.33.7</version>
37+
</dependency>
38+
</dependencies>
39+
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<artifactId>maven-jar-plugin</artifactId>
45+
<version>3.2.2</version>
46+
<configuration>
47+
<archive>
48+
<manifest>
49+
<addClasspath>true</addClasspath>
50+
<mainClass>${mainClass}</mainClass>
51+
</manifest>
52+
</archive>
53+
</configuration>
54+
</plugin>
55+
<plugin>
56+
<groupId>org.apache.maven.plugins</groupId>
57+
<artifactId>maven-assembly-plugin</artifactId>
58+
<version>3.4.2</version>
59+
<configuration>
60+
<archive>
61+
<manifest>
62+
<addClasspath>true</addClasspath>
63+
<mainClass>${mainClass}</mainClass>
64+
</manifest>
65+
</archive>
66+
<descriptorRefs>
67+
<descriptorRef>jar-with-dependencies</descriptorRef>
68+
</descriptorRefs>
69+
</configuration>
70+
<executions>
71+
<execution>
72+
<id>make-my-jar-with-dependencies</id>
73+
<phase>package</phase>
74+
<goals>
75+
<goal>single</goal>
76+
</goals>
77+
</execution>
78+
</executions>
79+
</plugin>
80+
<plugin>
81+
<groupId>org.codehaus.mojo</groupId>
82+
<artifactId>exec-maven-plugin</artifactId>
83+
<version>3.1.0</version>
84+
<configuration>
85+
<mainClass>${mainClass}</mainClass>
86+
<commandlineArgs>${mainArgs}</commandlineArgs>
87+
</configuration>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-wrapper-plugin</artifactId>
92+
<version>3.1.1</version>
93+
<configuration>
94+
<mavenVersion>3.8.5</mavenVersion>
95+
</configuration>
96+
</plugin>
97+
</plugins>
98+
</build>
99+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package generated_program;
2+
3+
import com.pulumi.Context;
4+
import com.pulumi.Pulumi;
5+
import com.pulumi.core.Output;
6+
import com.pulumi.componentpropertydeps.Custom;
7+
import com.pulumi.componentpropertydeps.CustomArgs;
8+
import com.pulumi.componentpropertydeps.Component;
9+
import com.pulumi.componentpropertydeps.ComponentArgs;
10+
import java.util.List;
11+
import java.util.ArrayList;
12+
import java.util.Map;
13+
import java.io.File;
14+
import java.nio.file.Files;
15+
import java.nio.file.Paths;
16+
17+
public class App {
18+
public static void main(String[] args) {
19+
Pulumi.run(App::stack);
20+
}
21+
22+
public static void stack(Context ctx) {
23+
var custom1 = new Custom("custom1", CustomArgs.builder()
24+
.value("hello")
25+
.build());
26+
27+
var custom2 = new Custom("custom2", CustomArgs.builder()
28+
.value("world")
29+
.build());
30+
31+
var component1 = new Component("component1", ComponentArgs.builder()
32+
.resource(custom1)
33+
.resourceList(
34+
custom1,
35+
custom2)
36+
.resourceMap(Map.ofEntries(
37+
Map.entry("one", custom1),
38+
Map.entry("two", custom2)
39+
))
40+
.build());
41+
42+
ctx.export("propertyDepsFromCall", "TODO: call call".applyValue(_call -> _call.result()));
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: l2-namespaced-provider
2+
runtime: java

0 commit comments

Comments
 (0)