You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tasks/native-image-sample/README.md
+49-11Lines changed: 49 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -10,31 +10,69 @@ It will then submit a new task to this queue.
10
10
11
11
## Setup Instructions
12
12
13
-
1. Follow the [GCP Project and Native Image Setup Instructions](../../README.md).
13
+
You will need to follow these prerequisite steps in order to run these samples:
14
14
15
-
2.[Enable the Cloud Tasks APIs](https://console.cloud.google.com/apis/api/cloudtasks.googleapis.com).
15
+
1. If you have not already, [create a Google Cloud Platform Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project).
16
+
17
+
2. Install the [Google Cloud SDK](https://cloud.google.com/sdk/) which will allow you to run the sample with your project's credentials.
18
+
19
+
Once installed, log in with Application Default Credentials using the following command:
20
+
21
+
```
22
+
gcloud auth application-default login
23
+
```
24
+
25
+
**Note:** Authenticating with Application Default Credentials is convenient to use during development, but we recommend [alternate methods of authentication](https://cloud.google.com/docs/authentication/production) during production use.
26
+
27
+
3. Install the GraalVM compiler.
28
+
29
+
You can follow the [official installation instructions](https://www.graalvm.org/docs/getting-started/#install-graalvm) from the GraalVM website.
30
+
After following the instructions, ensure that you install the Native Image extension installed by running:
31
+
32
+
```
33
+
gu install native-image
34
+
```
35
+
36
+
Once you finish following the instructions, verify that the default version of Java is set to the GraalVM version by running `java -version` in a terminal.
37
+
38
+
You will see something similar to the below output:
39
+
40
+
```
41
+
$ java -version
42
+
43
+
openjdk 11.0.14 2022-01-18
44
+
OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05)
45
+
OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 11.0.14+9-jvmci-22.0-b05, mixed mode, sharing)
46
+
47
+
```
48
+
49
+
4. [Enable the Cloud Tasks APIs](https://console.cloud.google.com/apis/api/cloudtasks.googleapis.com).
16
50
17
51
### Run with Native Image Compilation
18
52
19
53
Navigate to this directory in a new terminal.
20
54
21
-
1. Compile the application using the Native Image Compiler. This step may take a few minutes.
55
+
1. The project uses an environment variable `LOCATION_ID` to run the test. Set the environment variable by calling:
56
+
57
+
```
58
+
export LOCATION_ID=us-east1
59
+
```
60
+
61
+
2. Compile the application using the Native Image Compiler. This step may take a few minutes.
22
62
23
63
```
24
64
$ mvn package -P native
25
65
```
26
66
27
-
The project uses an environment variable `LOCATION_ID` to run the test.
67
+
28
68
29
-
2. Run the application:
69
+
3. Run the application:
30
70
31
71
```
32
-
$ LOCATION_ID=us-east1 ./target/tasks-sample
72
+
$ ./target/native-image-sample
33
73
```
34
74
35
-
The sample application uses an environment variable `LOCATION_ID`.
36
-
37
-
3. The application runs through some basic Cloud Tasks operations (create queue, create task) and then prints some results of the operations.
75
+
4. The application runs through some basic Cloud Tasks operations (create queue, create task) and then prints some results of the operations.
38
76
39
77
```
40
78
Test queue ready: name: "projects/xxxxxxxxxx/locations/us-central1/queues/graal-test-queue-4009"
@@ -80,10 +118,10 @@ Navigate to this directory in a new terminal.
80
118
Queue deleted
81
119
```
82
120
83
-
4. Run the test in the project in the native-image mode
121
+
5. Run the test in the project in the native-image mode
84
122
85
123
```
86
-
$ LOCATION_ID=us-east1 mvn test -P native
124
+
$ export LOCATION_ID=us-east1 && mvn test -P native
0 commit comments