Skip to content
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

[GR-60094] Move java-hello-world-maven to clouds/native-oci-cloud-shell. #333

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
name: java-hello-world-maven
name: clouds/native-oci-cloud-shell
on:
push:
paths:
- 'java-hello-world-maven/**'
- '.github/workflows/java-hello-world-maven.yml'
# pull_request: (requires EE, which is unavailable in PRs)
- 'clouds/native-oci-cloud-shell/**'
- '.github/workflows/clouds-native-oci-cloud-shell.yml'
schedule:
- cron: "0 0 1 * *" # run every month
workflow_dispatch:
permissions:
contents: read
jobs:
run:
name: Run 'java-hello-world-maven'
name: Run 'clouds/native-oci-cloud-shell'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21.0.2'
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
native-image-job-reports: 'true'
- name: Run 'java-hello-world-maven'
- name: Run 'clouds/native-oci-cloud-shell'
run: |
cd java-hello-world-maven
cd clouds/native-oci-cloud-shell
mvn --no-transfer-progress clean package
java -jar target/my-app-1.0-SNAPSHOT.jar
mvn --no-transfer-progress clean -Pnative -DskipTests package
Expand Down
14 changes: 7 additions & 7 deletions _common/README-check-version-env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
The output should be similar to (versions may vary):

```shell
java version "17.0.9" 2023-10-17 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS-jvmci-23.0-b21)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS-jvmci-23.0-b21, mixed mode, sharing)
java version "17.0.13" 2024-10-15 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS-jvmci-23.0-b49)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS-jvmci-23.0-b49, mixed mode, sharing)
```

5. Confirm the `native-image` version:
Expand All @@ -61,9 +61,9 @@
The output should be similar to (versions may vary):

```shell
native-image 17.0.9 2023-10-17
GraalVM Runtime Environment Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS-jvmci-23.0-b21)
Substrate VM Oracle GraalVM 17.0.9+11.1 (build 17.0.9+11-LTS, serial gc, compressed references)
native-image 17.0.13 2024-10-15
GraalVM Runtime Environment Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS-jvmci-23.0-b49)
Substrate VM Oracle GraalVM 17.0.13+10.1 (build 17.0.13+10-LTS, serial gc, compressed references)
```

6. Confirm the `Java` used for Maven builds:
Expand All @@ -76,7 +76,7 @@

```shell
...
Java version: 17.0.9, vendor: Oracle Corporation, runtime: /usr/lib64/graalvm/graalvm-java17
Java version: 17.0.13, vendor: Oracle Corporation, runtime: /usr/lib64/graalvm/graalvm-java17
...
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Oracle GraalVM is available for use on Oracle Cloud Infrastructure (OCI) at no a

## What is Cloud Shell?

[Cloud Shell](https://www.oracle.com/devops/cloud-shell/) is a free-to-use browser-based terminal accessible from the Oracle Cloud Console. It provides access to a Linux shell with preinstalled developer tools and a preauthenticated OCI CLI. You can use the shell to interact with OCI resources, follow labs and tutorials, and quickly run utility commands.
[Cloud Shell](https://www.oracle.com/devops/cloud-shell/) is a free-to-use browser-based terminal accessible from the Oracle Cloud Console. It provides access to a Linux shell with preinstalled developer tools and a pre-authenticated OCI CLI. You can use the shell to interact with OCI resources, follow labs and tutorials, and quickly run utility commands.

Oracle GraalVM for JDK 17 (with Native Image) is preinstalled in Cloud Shell, so you don’t have to install and configure a development machine to get started.

Expand Down Expand Up @@ -46,39 +46,37 @@ Oracle GraalVM for JDK 17 (with Native Image) is preinstalled in Cloud Shell, so
The current managed java version is set to graalvmjdk-17.
```

## Step 3: [OPTIONAL] Confirm software version and environment variables

This step is optional - [Check software version and environment variables](../_common/README-check-version-env-vars.md)


## Step 4: Set up your project, build and run as a JAR
## Step 3: Set up your project, build and run as a JAR

1. Git clone this example.

```shell
git init graalvmee-java-hello-world-maven
git init graalvm-native-oci-cloud-shell

cd graalvmee-java-hello-world-maven
cd graalvm-native-oci-cloud-shell

git remote add origin https://github.com/graalvm/graalvm-demos.git

git config core.sparsecheckout true

echo "java-hello-world-maven/*">>.git/info/sparse-checkout
echo "clouds/native-oci-cloud-shell/*">>.git/info/sparse-checkout

git pull --depth=1 origin master

cd java-hello-world-maven

cd clouds/native-oci-cloud-shell
```

2. Build a JAR file for the example app.
2. [OPTIONAL] Confirm software version and environment variables.

[Check software version and environment variables](../../_common/README-check-version-env-vars.md)

3. Build a JAR file for the example app.

```shell
mvn clean package
./mvnw clean package
```

3. Run the JAR using:
4. Run the JAR:

```shell
java -jar target/my-app-1.0-SNAPSHOT.jar
Expand All @@ -90,7 +88,7 @@ This step is optional - [Check software version and environment variables](../_c
Hello World!
```

## Step 5: Build and run a native executable
## Step 4: Build and run a native executable

Use GraalVM Native Image to produce a native executable.

Expand All @@ -107,7 +105,7 @@ You will notice the `Quick Build` mode reduces the time required to generate a n
2. Use the Native Image maven plugin to create a native executable:

```shell
mvn clean -Pnative -DskipTests package
./mvnw clean -Pnative -DskipTests package
```

3. Run the native executable using:
Expand All @@ -134,7 +132,7 @@ You will notice the `Quick Build` mode reduces the time required to generate a n
2. Use the Native Image maven plugin to create a native executable:

```shell
mvn clean -Pnative -DskipTests package
./mvnw clean -Pnative -DskipTests package
```

3. Run the native executable using:
Expand All @@ -148,3 +146,5 @@ You will notice the `Quick Build` mode reduces the time required to generate a n
```text
Hello World!
```

Learn how to start using Oracle GraalVM with other OCI services at [docs.oracle.com](https://docs.oracle.com/en/graalvm/jdk/23/docs/getting-started/oci/).
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

In this example, you will build and run a "Hello World" Java application with:

- [Oracle GraalVM in OCI Code Editor](https://github.com/oracle-devrel/oci-code-editor-samples/tree/main/java-samples/graalvmee-java-hello-world)
- [Oracle GraalVM in OCI Cloud Shell](./README-Cloud-Shell.md)
- [Oracle GraalVM in OCI Code Editor](https://github.com/oracle-devrel/oci-code-editor-samples/tree/main/java-samples/graalvmee-java-hello-world)
Loading
Loading