diff --git a/.github/workflows/polyglot-debug.yml b/.github/workflows/polyglot-debug.yml index c51fdd870..23786d0ab 100644 --- a/.github/workflows/polyglot-debug.yml +++ b/.github/workflows/polyglot-debug.yml @@ -20,7 +20,7 @@ jobs: timeout-minutes: 15 strategy: matrix: - java-version: ['17', 'dev'] + java-version: ['21', 'dev'] steps: - uses: actions/checkout@v3 - uses: graalvm/setup-graalvm@v1 @@ -34,4 +34,4 @@ jobs: run: | cd polyglot-debug mvn --no-transfer-progress clean package - java -cp ./target/PolyglotDebug-1.0-SNAPSHOT.jar org.graalvm.demos.PolyglotDebug + mvn exec:exec diff --git a/polyglot-debug/README.MD b/polyglot-debug/README.MD index 5aea4e2bc..b6d02ca9b 100644 --- a/polyglot-debug/README.MD +++ b/polyglot-debug/README.MD @@ -1,23 +1,44 @@ -# GraalVM Java to JavaScript Polyglot Debugging +# Debugging a Java with JavaScript Embedding Application -This sample code helps to demonstrate simplicity of debugging and developing GraalVM Polyglot applications using __VS Code extensions__. +This sample code helps to demonstrate simplicity of debugging and developing GraalVM polyglot applications using Visual Studio (VS) Code extensions. ## Prerequisites -1. VS Code has to be installed. +1. Install VS Code and launch it. 2. Then go to VS Code Extensions activity panel and search for _GraalVM Extension Pack_, install it. The GraalVM Extension Pack will install all required extensions. -3. [Install GraalVM in VS Code](https://www.graalvm.org/latest/tools/vscode/graalvm-extension/#graalvm-installation-wizard): Navigate to Gr activity panel in VS Code and install some of the latest GraalVM __Enterprise Edition__ versions available from the list. +2. Open Visual Studio Code, navigate to Extensions activity panel in the left-hand side Activity Bar. Search for “GraalVM” in the search field. Find [GraalVM Tools for Java](https://marketplace.visualstudio.com/items?itemName=oracle-labs-graalvm.graalvm), press Install. Reload will be required. +3. [Install GraalVM in VS Code](https://www.graalvm.org/latest/tools/vscode/graalvm-extension/#graalvm-installation-wizard): Navigate to Gr activity panel in VS Code and install the latest Oracle GraalVM version available from the list. 4. Confirm to set this as _Active GraalVM_ for VS Code. -5. Install the `js` component. -## Debugging the project - -Working with Polyglot project in VSCode is simple just open this sample. +## Build and Run the Application + +1. Open VS Code Terminal. +2. Clone the repository and navigate into the `polyglot-debug` directory: + ```bash + git clone https://github.com/graalvm/graalvm-demos + ``` + ```bash + cd graalvm-demos/polyglot-debug + ``` + +3. Build the application using Maven: + ```bash + mvn clean package + ``` +4. Run this application with the following command: + ```bash + mvn exec:exec + ``` + +## Debug the Application + +Working with a polyglot project in VS Code is simple just open this sample. It will be working out of the box with VS Code GraalVM extensions. -Place breakpoints either in Java or JavaScript code. +1. Place breakpoints either in Java or JavaScript code. + +2. To debug the project, go to __Run and Debug__ activity or simply press F5. -To debug the project go to __Run and Debug__ activity or simply press F5. -Choose **Launch Java 8+** as this is the Polyglot debugger provided by GraalVM extensions. +3. Choose **Launch Java 8+** as this is the Polyglot debugger provided by the GraalVM extension. That is, the sample is running under debugger on GraalVM. diff --git a/polyglot-debug/pom.xml b/polyglot-debug/pom.xml index 2826a0efe..d45f12f4c 100755 --- a/polyglot-debug/pom.xml +++ b/polyglot-debug/pom.xml @@ -3,12 +3,107 @@ 4.0.0 org.graalvm.demos PolyglotDebug - 1.0-SNAPSHOT + 1.0 jar UTF-8 - 1.8 - 1.8 + 23.1.1 - PolyglotDebug - \ No newline at end of file + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + org.graalvm.demos.PolyglotDebug + + + + + + assemble-all + package + + single + + + + + + maven-jar-plugin + 3.2.0 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 21 + 21 + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + default-cli + + exec + + + + --module-path + + + -m + demo/org.graalvm.demos.PolyglotDebug + + + + + + ${JAVA_HOME}/bin/java + + + + + + + + org.graalvm.sdk + collections + ${graalvm.version} + + + org.graalvm.sdk + nativeimage + ${graalvm.version} + + + org.graalvm.sdk + word + ${graalvm.version} + + + org.graalvm.polyglot + polyglot + ${graalvm.version} + + + org.graalvm.polyglot + js + ${graalvm.version} + pom + + + + diff --git a/polyglot-debug/src/main/java/module-info.java b/polyglot-debug/src/main/java/module-info.java new file mode 100644 index 000000000..b2905e9ee --- /dev/null +++ b/polyglot-debug/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module demo { + exports org.graalvm.demos; + requires org.graalvm.polyglot; +} \ No newline at end of file diff --git a/polyglot-debug/src/main/java/org/graalvm/demos/PolyglotDebug.java b/polyglot-debug/src/main/java/org/graalvm/demos/PolyglotDebug.java index bce77b340..c63021035 100644 --- a/polyglot-debug/src/main/java/org/graalvm/demos/PolyglotDebug.java +++ b/polyglot-debug/src/main/java/org/graalvm/demos/PolyglotDebug.java @@ -44,6 +44,7 @@ import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; + import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value;