Skip to content

A gradle plugin to build your code against the deterministic version of Corda R3 and check you only use deterministic calls in contract calls

License

Notifications You must be signed in to change notification settings

lucacampanella/corda-deterministic-validator-plugin

Repository files navigation

corda-deterministic-validator-plugin

Build Status License

A gradle plugin to build your code against the deterministic version of Corda R3 and check you only use deterministic calls in contract calls

Installing

As a Gradle plugin

To apply the plugin, in the build.gradle (see gradle website):

Using legacy plugin application:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "com.github.lucacampanella:cordadeterministicvalidatorplugin:+"
  }
}

apply plugin: "com.github.lucacampanella.cordadeterministicvalidatorplugin.corda-deterministic-validator-plugin"

Be careful: in any case the plugin should be applied after the Java plugin.

Usage

Run ./gradlew compileDeterministicJava

The plugin creates a new JavaCompile task, called compileDeterministicJava which copies the default task, but compiles it with the deterministic Corda JDK and the deterministic Corda modules. (See Corda docs)

To do this it creates a new configuration, called deterministicImplementation, which extends from classpathCompile. By default the version of the deterministic Corda modules is 4.0, but this can be changed by explicitly writing the dependencies on this configuration. Example:

dependencies {
    deterministicImplementation "net.corda:corda-core-deterministic:$your_preferred_version"
    deterministicImplementation "net.corda:corda-serialization-deterministic:$your_preferred_version"
}

The compileDeterministicJava task copies the compiler args (options.compilerArgs), from compileJava task. It also adds -parameters and the arguments needed for deterministic compilation. If you want to add compiler arguments only to the compileDeterministicJava, just do so using the Gradle DSL. The tasks also copies the annotation processors configurations.

Be careful: The Corda Determinisc JDK doesn't currently support lambdas. If you have lambdas in your code, you'll probably have a problem similar to:

An exception has occurred in the compiler [...]
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.lang.invoke.MethodType not found

If this is the case you can either exchange lambdas with anonymous classes or ignore the failure of the validation, knowing the only problem are lambdas.

About

A gradle plugin to build your code against the deterministic version of Corda R3 and check you only use deterministic calls in contract calls

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages