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
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
- Install Java using any of the methods available for your OS, e.g. download the binaries and place them in a local folder (recommended to use a simple path with no spaces)
- Must Configure the JAVA_HOME environment variable in your OS,
- Test that Java it's properly installed:
java -version
and also runjavac -version
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)
At the moment of writing this guide, the current maven version 3.9.0 it's not supported. (downgrade previous version)
- Download a previous version of maven 3.8.4 - 3.8.7 from here https://archive.apache.org/dist/maven/maven-3/
- Install Maven using any of the methods available OS, e.g. https://maven.apache.org/guides/getting-started/windows-prerequisites.html
- Configure the MAVEN_HOME environment variable, e.g.
MAVEN_HOME="/Users/andrespedesmorales/OSS/apache-maven-3.8.7/bin"
- Test that maven it's properly configured running
mvn -v
, compare that the java version used by maven it's the same previously configured.
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"
There are a handful of plugins that facilitate your dev experience. It's recommended to install them:
- Extension pack for Java : https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack
- Maven for Java : https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
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"
}
- Install the plugin, > Extensions > search Dataweave > Click install button. More info: https://marketplace.visualstudio.com/items?itemName=MuleSoftInc.dataweave
- Restart the Visual Studio Code
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>