Skip to content

Instantly share code, notes, and snippets.

@Noisyfox
Last active February 10, 2020 11:36
Show Gist options
  • Save Noisyfox/24f7c335a351a6d40171d698f43aec41 to your computer and use it in GitHub Desktop.
Save Noisyfox/24f7c335a351a6d40171d698f43aec41 to your computer and use it in GitHub Desktop.
Gradle generate web3j truffle wrapper
buildscript {
ext.WEB3J_VERSION = "4.5.14"
repositories {
mavenCentral()
}
dependencies {
// Pull the web3j codegen lib
classpath group: 'org.web3j', name: 'codegen', version: WEB3J_VERSION
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.web3j:core:$WEB3J_VERSION"
}
sourceSets {
main {
java {
// the contract wrapper files will be located in this directory
srcDir 'build/java'
}
}
}
import org.web3j.codegen.TruffleJsonFunctionWrapperGenerator
task("generateWrapper") {
doLast {
// Call the truffle generator from web3j codegen
TruffleJsonFunctionWrapperGenerator.run(
"generate", "--javaTypes",
"<path-to-your-truffle-json-file>",
"--package", "<package-name>",
"--outputDir", "<output-dir>"
)
}
}
// Generate contract wrapper before compile
compileJava.dependsOn "generateWrapper"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment