Skip to content

Commit d25a954

Browse files
docs(sample): modify README instructions for Native Image sample (#666)
* docs(sample): modify README instructions for Native Image sample * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add setup instructions Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 07f5ad1 commit d25a954

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

tasks/native-image-sample/README.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,69 @@ It will then submit a new task to this queue.
1010

1111
## Setup Instructions
1212

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:
1414

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).
1650
1751
### Run with Native Image Compilation
1852
1953
Navigate to this directory in a new terminal.
2054
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.
2262
2363
```
2464
$ mvn package -P native
2565
```
2666
27-
The project uses an environment variable `LOCATION_ID` to run the test.
67+
2868
29-
2. Run the application:
69+
3. Run the application:
3070
3171
```
32-
$ LOCATION_ID=us-east1 ./target/tasks-sample
72+
$ ./target/native-image-sample
3373
```
3474
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.
3876
3977
```
4078
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.
80118
Queue deleted
81119
```
82120
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
84122
85123
```
86-
$ LOCATION_ID=us-east1 mvn test -P native
124+
$ export LOCATION_ID=us-east1 && mvn test -P native
87125
...
88126
[INFO] -------------------------------------------------------
89127
[INFO] T E S T S

0 commit comments

Comments
 (0)