We often hear that DataWeave scripts can become a critical part of Mule applications, covering complex logic that often needs to be replicated elsewhere. So being able to document and share that logic across applications has become a need for many.
With this in mind, MuleSoft is thrilled to announce that DataWeave is not only a first-class citizen in Exchange, but it also offers a full development lifecycle from designing, testing, and troubleshooting, to sharing your code.
Building DataWeave libraries
Let’s take a closer look at what DataWeave libraries allow and how you can share your own.
Designing, testing, and maintaining your library
The first step in creating a DataWeave library is to actually develop it. DataWeave’s Visual Studio Code plugin (Beta) allows you to quickly get started by guiding you through the creation of your library project and setting it up for you.
It also allows you to quickly create modules and mappings, where you’ll have editing features such as autocompletion, inline documentation, type checking, quick fixes, refactors, and navigation.
The plugin also guides you through documenting and safely developing your code by making it incredibly easy to test it – whether it’s a module or a mapping, using the testing framework available in the Visual Studio Code plugin (Beta). You’ll be one click away from describing the usage of your functions and creating unit tests for them, while being able to define scenarios for mappings, preview their results, and store them as tests.
Most importantly, the plugin supports debugging your code, so you can assure you’ll have the tools you need to support your library users as they report issues.
Publishing your library
When it comes time to share your library with the world, the Maven plugin available in the Visual Studio Code plugin (Beta) will make deployment as easy as 1, 2, 3. This plugin not only makes sure to run all your tests ahead of deployment, but it also provides coverage information.
Most importantly, it’s integrated with Exchange so that the documentation you write for your library is automatically uploaded into its portal. This means your coworkers won’t simply see a new asset, they’ll be able to review all the functionality it offers.
Reusing a library
What if you’re browsing through Exchange and find a library with some functionality you’ll like to reuse in your Mule application? Well, you can simply get the dependency snippet and copy it into your application’s pom.xml file. Then, you can work with this library as you would any internal modules or mappings, importing what you need into your scripts and using them to streamline your development.
Curious about how to get started with DataWeave libraries? We’ve got you covered! Check out MuleSoft’s DataWeave libraries in Anypoint Exchange; download our Visual Studio Code plugin to start developing your own; and review how to share and reuse custom DataWeave modules and mappings.