The JBang Gradle plugin allows JBang scripts to be executed during a Gradle build.
The plugin attempts to use an existing JBang installation. If no JBang installation is found, the plugin will install JBang by downloading and caching the latest version binaries (in your local Gradle cache directory) for subsequent runs.
This plugin adds a new task of type org.kordamp.gradle.plugin.jbang.tasks.JBangTask
named jbang
that accepts the
following properties
Property | Type | System | Environment | Default | Required |
---|---|---|---|---|---|
script |
String |
jbang.script |
JBANG_SCRIPT |
✅ |
|
args |
List<String> |
jbang.args |
JBANG_ARGS |
[ ] |
❌ |
trusts |
List<String> |
jbang.trusts |
JBANG_TRUSTS |
[ ] |
❌ |
version |
String |
jbang.version |
JBANG_VERSION |
0.48.0 |
❌ |
installDir |
Directory |
jbang.install.dir |
JBANG_INSTALL_DIR |
$gradleUserHomeDir/caches/jbang |
❌ |
script |
The script to be executed by JBang. |
args |
The arguments to be used in the JBang script (if any) |
trusts |
If the script resides in a remote location, this parameter specifies what URLs should be trusted. See URLs from Trusted Sources for more information |
version |
If your environment lacks the JBang binaries in the PATH, you can specify the JBang version to be installed. The default value will be the plugin’s version |
Task property values may be specified directly or using their respective environment variable, System property, or project property respectively, for example
$ gradle jbang -Djbang.script=hello.jsh -Djbang.args="Hello world"
If the org.kordamp.gradle.inline
plugin
were to be applied to your build (via settings.gradle
) then you may invoke this plugin without modifying your build file
$ gradle org.kordamp.gradle:jbang-gradle-plugin:0.1.0:jbang -Pjbang.script=hello.java
Option #1
buildscript {
repositories {
jcenter()
gradlePluginPortal()
}
dependencies {
classpath 'org.kordamp.gradle:jbang-gradle-plugin:0.1.0'
}
}
apply plugin: 'org.kordamp.gradle.jbang'
Option #2
plugins {
id 'org.kordamp.gradle.jbang' version '0.1.0'
}