close
Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

script

This addon provides standalone functionality. Development tools for Java Programming Language.

Depends on

Addon Exported Optional

shell

no

no

resources

no

no

org.jboss.forge.furnace.container:simple

no

no

Setup

This Addon requires the following installation steps.

Add configuration to pom.xml

To use this addon, you must add it as a dependency in the pom.xml of your forge-addon classified artifact:

<dependency>
   <groupId>org.jboss.forge.addon</groupId>
   <artifactId>script</artifactId>
   <classifier>forge-addon</classifier>
   <version>${version}</version>
</dependency>

Features

JSR-223 (javax.script) compatible

Invoke script using the javax.script API:

 // Using ScriptEngineManager
ScriptEngineManager manager = new ScriptEngineManager(getClass().getClassLoader());
ScriptEngine engine = manager.getEngineByExtension("fsh");

// or fetching from the AddonRegistry
@Inject
ForgeScriptEngineFactory factory;
//and
ScriptEngine engine = factory.getScriptEngine();

// Ready to execute
ScriptContext scriptContext = ScriptContextBuilder.create().currentResource(currentResource).stdout(output.out()).stderr(output.err()).build();
Result result = (Result) engine.eval("touch foo.txt", scriptContext);
Support ScriptFileResource

You can use ResourceFactory to get a handle to a ScriptFileResource and evaluate it, be it a Forge script or any JSR-223 compatible implementation.

// it could be a JavaScript file or any other JSR-223 compatible engine.
ScriptFileResource scriptResource = resourceFactory.create(ScriptFileResource.class, new File("forge.fsh"));
ScriptContext context = ScriptContextBuilder.create().currentResource(tmpDir).build();
scriptResource.eval(context);