Skip to content
This repository was archived by the owner on Nov 10, 2018. It is now read-only.

Defining a script

Tim Seckinger edited this page Dec 20, 2016 · 9 revisions

Inline script

You can pass an inline script to the script macro as follows:

script("language:source")
language can be either a language name or mime type, see Languages.

source is your script’s source code.

Examples:

script("groovy:Math.max(2, 4)")
script("application/javascript:21 * 2")

Script from a file

If you pass a valid file path to the script macro, the script’s source code will be read from the file.
You can use absolute file paths or file paths relative to your home directory.

Examples:

script("myscripts/abc.js")
script("/tmp/script.js")

File with extension

If the file name has a known extension (see Languages), the script language will be inferred from the extension.

File without extension

If the file name does not have a known extension (or you need to override the language for some reason), you can specify the language followed by a colon before the file path:

script("language:path")

Examples:

script("javascript:myscripts/abc")
script("application/x-groovy:/tmp/script.js")

Languages

All languages that have a ScriptEngine available within the IntelliJ IDEA instance can be used with the script macro.

The following table provides an overview of the available engines as of IntelliJ IDEA 2016.3.1:

Names Mime Types ScriptEngine

nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript

application/javascript, application/ecmascript, text/javascript, text/ecmascript

groovy, Groovy

application/x-groovy

Passing arguments

TODO

Clone this wiki locally