hyperledger / web3j-gradle-plugin

web3j Gradle plugin
https://web3j.io
Other
39 stars 26 forks source link

Task compileKotlin is coming before compileSolidity #24

Open conor10 opened 5 years ago

conor10 commented 5 years ago

When using the plugin in a Kotlin project, the compileKotlin task comes before compileSolidity and generateContractWrappers. This means that if you have Kotlin code trying to use the generated contracts in the same module as where they are created they will not be found.

There was a similar issue with the protobuf plugin https://github.com/google/protobuf-gradle-plugin/issues/100.

iikirilov commented 5 years ago

Is there a workaround for this?

iikirilov commented 5 years ago

https://github.com/bndtools/bnd/wiki/Using-Kotlin-with-the-Bnd-Gradle-Plugin-for-Workspace-Builds

xaviarias commented 5 years ago

This code snippet workarounds this issue:

    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
        dependsOn 'generateContractWrappers'
    }

    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
        dependsOn 'generateTestContractWrappers'
    }

    sourceSets {
        main.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/main/java"
        test.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/test/java"
    }