0

I'm using the J2V8 library to run some javascript functions in the cordapp, but I'm having troubles to access the js files (or refer to them) during runtime, because when the project is built the js code is copied into the build/resources folder, not reachable from any running node (as far as I know).

I realized that I need to include the js source code into the corda.jar files, produced when I run gradle deployNodes.

I tried to add the following to the build.gradle file:

jar {
    baseName = 'something'
    from('src/main/resources/js_library') {
        include '*.js'
    }
}

but it doesn't solve my problem. Do I need to extend some tasks in the net.corda.plugins in some way? Or is there a way to access the build/resource folder once the cordapp is running?

Mauro
  • 61
  • 2
  • 9

1 Answers1

2

The corda.jar is the node JAR that your applications are intended to run on/against and it isn't intended to be modified for apps.

Your own CorDapp JAR should be generated automatically by the "jar" task if you're applying the correct gradle plugin (cordformation for V1, cordapp for later versions). This JAR will be on the classpath and contain all of the files in your resources directory. For example "src/main/resources/js_library" will be available in the root of the CorDapp JAR and can be accessed directly during runtime from the classloader of any of the classes in your CorDapp. See the answer here to learn how to access files within a JAR.

Clintonio
  • 434
  • 5
  • 11