hyperledger-web3j / web3j-solidity-gradle-plugin

Gradle plugin providing tasks to compile Solidity contracts.
Apache License 2.0
21 stars 25 forks source link

Setting custom nodeProjectDir overwrites package.json instead of using it #34

Closed vanderheijden86 closed 3 years ago

vanderheijden86 commented 3 years ago

Hi there,

I have specified a custom nodeProjectDir like this:

node {
    nodeProjectDir = file("custom-node-dir")
}

I would expect the plugin to then to use the actual package.json file that lives inside that directory. Unfortunately, it simply overwrites the package.json with it's own generated package.json (with latest openzeppelin etc libraries). This prevents me from using a custom version of the openzeppelin contract. I believe I followed your README in this, but it works not as it is supposed to. But perhaps I am mistaken, would be grateful if you can help me out here.

Thanks

vanderheijden86 commented 3 years ago

From what I can see in the code it will actually always indeed create a new package.json file, instead of using the package.json file that lives in the directory (as one would expect from reading the docs):

private void configureSolidityResolve(Project target, DirectoryProperty nodeProjectDir) {
        def resolveSolidity = target.tasks.create(
                "resolveSolidity", SolidityResolve)
        resolveSolidity.sources = resolvedSolidity.solidity
        resolveSolidity.description = "Resolve external Solidity contract modules."
        resolveSolidity.allowPaths = target.solidity.allowPaths
        resolveSolidity.onlyIf {
            target.solidity.resolvePackages
        }
        def packageJson = new File(nodeProjectDir.asFile.get(), "package.json")
        resolveSolidity.packageJson = packageJson
    }
xaviarias commented 3 years ago

Hi, thanks for reporting! It will be fixed in the next release 0.3.1.

Cheers