Skip to content

Instantly share code, notes, and snippets.

@pedes
Last active July 20, 2023 11:17
Show Gist options
  • Save pedes/8001f87c8add4a3a2b41d6d40ebf5d31 to your computer and use it in GitHub Desktop.
Save pedes/8001f87c8add4a3a2b41d6d40ebf5d31 to your computer and use it in GitHub Desktop.

Absolute Install & Configuration Guide for Dataweave in VS Code

This gist will guide you to troubleshoot and configure properly the Dataweave plugin in Visual Studio Code.

Updated on 9th March 2023, plugin version v1.2.15

Pre-Requisites

This dataweave plugin/extension depends on Java & Maven.

It's recommended to use Java 11 & Maven 3.8.4 - 3.8.8

For this guide we'll do the setup using jdk-11.0.18+10, find it here: https://adoptium.net/en-GB/temurin/archive/?version=11

1. Install & Configure Java 11

java -version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment Temurin-11.0.18+10 (build 11.0.18+10)
OpenJDK 64-Bit Server VM Temurin-11.0.18+10 (build 11.0.18+10, mixed mode)

2. Install & Configure Maven

At the moment of writing this guide, the current maven version 3.9.0 it's not supported. (downgrade previous version)

sample output

mvn -v
Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
Maven home: /Users/andrespedesmorales/OSS/apache-maven-3.8.7
Java version: 11.0.18, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
Default locale: en_NL, platform encoding: UTF-8
OS name: "mac os x", version: "13.2.1", arch: "aarch64", family: "mac"

3. Install Java-related plugins

There are a handful of plugins that facilitate your dev experience. It's recommended to install them:

  1. Extension pack for Java : https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack
  2. Maven for Java : https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven

4. Configure User's settings.json

In the Visual Studio Code user's settings json config file set the default Java and Maven location. How to edit guide here: https://supunkavinda.blog/vscode-editing-settings-json

Note: maven.executable.path has to include the mvn binary file in its path, whereas the java.configuration.runtimes path only the root folder of installation.

{
    "workbench.colorTheme":"Default Dark+",
    "java.configuration.runtimes":[
       {
          "name":"JavaSE-1.8",
          "path":"/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
       },
       {
          "name":"JavaSE-11",
          "path":"/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home",
          "default":true
       },
       {
          "name":"JavaSE-17",
          "path":"/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home"
       }
    ],
   "maven.executable.path": "/Users/andrespedesmorales/OSS/apache-maven-3.8.7/bin/mvn"
 }

5. Install the Dataweave Code Plugin

At this point, now your VSCode should be ready for Dataweave development.

To create a new DataWeave project, follow these steps:

  • Launch the Command Palette by pressing Ctrl + Shift + P.
  • Select DataWeave: Create new Library Project.
  • Complete the details for your project in the provided text boxes.
  • When prompted, select whether to open a new window displaying the results.

Tip: Set the java level at the project pom.xml file

    <properties>
        <java.version>11</java.version>
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.source>11</maven.compiler.source>
    </properties>

Additional Helpful Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment