tree: 0c00f9033784255f1703c067e138119bdd332160 [path history] [tgz]
  1. gradle/
  2. src/
  3. .gitignore
  4. build.gradle
  5. gradlew
  6. gradlew.bat
  7. README.md
  8. settings.gradle
java-local/README.md

Testing Java functions locally

Building CLI

./gradlew jar

Usage

java -jar ./build/libs/java-local.jar ./path-to-function.jar parameter=value parameter2=value2 --main=myproject.Myfunction

Will invoke the main function of myproject.Myfunction class from path-to-function.jar with following params:

{
  "parameter":"value",
  "parameter2":"value"
}

Alternatively, you can test a single Java file by directly invoking it. In this case the Java file should not require any third party libraries.

java -jar ./build/libs/java-local.jar ./myproject/Myfunction.java parameter=value parameter2=value2

This will always return a JSON formatted result that can be post-processed

It is also possible to pass input on stdin, this allows the creation of more complex input objects that would be inconvenient to edit on the command line or passing non-string values.

echo '{"name": "value"}' | java -jar ./build/libs/java-local.jar ./path-to-function.jar --main=myproject.Myfunction
cat input.json | java -jar ./build/libs/java-local.jar ../myproject/Myfunction.java