Skip to main content
Version: 4.14.8

Migration guide for Groovy and JavaScript scripts used in the ScriptComponent.

Groovy

Versions

DovetailGroovyRelease notes
< 4.14.42.5
4.15.03.0https://groovy-lang.org/releasenotes/groovy-3.0.html
> 4.16.04.0https://groovy-lang.org/releasenotes/groovy-4.0.html

Migration

For most Groovy Script nothing needs to change. If a script is not working it's best to check the release notes if your script contains one of the changes listed in the release notes.

JavaScript

Versions

DovetailJavaScriptEngine
< 4.14.4ECMAScript 5.1Nashorn
> 4.15.0ECMAScript 2023GraalVM

About the new engine

Until Dovetail 4.14.x, Dovetail was running on Java 8. This Java version came with a JavaScript engine bundled called Nashorn:

https://en.wikipedia.org/wiki/Nashorn_(JavaScript_engine)

For some time Oracle, owner of Java, supported JavaScript by using the Nashorn Engine. Since Java 11 this engine was deprecated citing maintenance challenges by Oracle.

From Dovetail 4.15.x a new engine provided by Oracle is used in the Script component. This engine is called (GraalVM). Oracle says:

“Both Nashorn and GraalVM JavaScript support a similar set of syntax and semantics for Java interoperability. One notable difference is that GraalVM JavaScript takes a secure by default approach, meaning some features need to be explicitly enabled that were available by default on Nashorn. The most important differences relevant for migration are listed here.”

https://www.graalvm.org/latest/reference-manual/js/NashornMigrationGuide/

Scripts need thus be tested if they still work with the new engine.

Predefined variables

Some JavaScript variables were predefined like "request" and "result". Using GraalVM the predefined variables are changed:

Dovetail 4.14.xDovetail 4.15.x
contextcontext
exchangeexchange
requestmessage
responsebody
propertiesproperties
headers
body
exchangeId
result

Migration

To upgrade it's best to follow following steps:

  1. Change the predefined variables.
  2. Remove the "result" variable, the last variable is return by default (result is not need anymore).
  3. Update script from ECMAScript 5.1 to ECMAScript 2023.

Tip 1: Use a linter

You can test syntax of script online:

https://jshint.com/

Note that it doesn't recognize the predefined variables.

Tip 2: Use ChatGPT

We created a custom GPT that converts a script automatically:

https://chat.openai.com/g/g-geEsZe9iG-javascript-converter-for-dovetail

This (like all ChatGPT's) is not perfect, but can save a bit of time.