hyperledger/web3j-gradle-plugin

Can't upgrade to Gradle 6.0 because of web3j plugin

chochos opened this issue · 5 comments

I have a project that includes the web3j plugin. When building I get this warning:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.6.4/userguide/command_line_interface.html#sec:command_line_warnings

Enabling that flag along with --stacktrace gives me this (abridged):

SourceDirectorySetFactory has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory service to create instances of SourceDirectorySet instead.
        at org.gradle.api.internal.file.DefaultSourceDirectorySetFactory.create(DefaultSourceDirectorySetFactory.java:37)
        at org.web3j.solidity.gradle.plugin.DefaultSoliditySourceSet.<init>(DefaultSoliditySourceSet.groovy:24)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.web3j.solidity.gradle.plugin.SolidityPlugin.configureSourceSet(SolidityPlugin.groovy:61)
...
...

The DefaultSourceDirectorySet constructor has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory service to create instances of SourceDirectorySet instead.
        at org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(DefaultSourceDirectorySet.java:65)
        at org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(DefaultSourceDirectorySet.java:79)
        at org.web3j.gradle.plugin.Web3jPlugin.buildSourceDirectorySet(Web3jPlugin.java:105)
        at org.web3j.gradle.plugin.Web3jPlugin.configure(Web3jPlugin.java:71)
        at org.web3j.gradle.plugin.Web3jPlugin.lambda$apply$0(Web3jPlugin.java:41)
...
...

If I try to build the sample-project with gradle 6.0 I get the following error message:
`* What went wrong:
A problem occurred configuring root project 'test'.

Failed to notify project evaluation listener.
org.gradle.api.internal.file.IdentityFileResolver: method ()V not found`

The issue does not appear, if gradle 5.6 is used or if I comment out the web3j plugin.

This is the relevant part of the stacktrace:
`Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:86)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:325)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:235)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy27.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:191)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate$1.execute(LifecycleProjectEvaluator.java:188)
at org.gradle.api.internal.project.DefaultProject.stepEvaluationListener(DefaultProject.java:1434)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:197)
... 114 more

Caused by: java.lang.NoSuchMethodError: org.gradle.api.internal.file.IdentityFileResolver: method ()V not found
at org.web3j.gradle.plugin.Web3jPlugin.buildSourceDirectorySet(Web3jPlugin.java:142)
at org.web3j.gradle.plugin.Web3jPlugin.configure(Web3jPlugin.java:105)
at org.web3j.gradle.plugin.Web3jPlugin.lambda$apply$0(Web3jPlugin.java:56)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1$1.run(DefaultCollectionCallbackActionDecorator.java:100)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.reapply(DefaultUserCodeApplicationContext.java:60)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:97)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)`

Hi, any update?

In Gradle 6 DefaultSourceDirectorySet constructor has been deprecated in favour of ObjectFactory. The way the default source directory set is made will have to be updated in the Web3jPlugin.java file.

I'd be keen to help fix this if someone is able to give me some guidance in contributing to this project.

For reference, this is how the protobuf gradle plugin fixed it.

Hi,

Thanks for keeping this issue alive, it's been a while since it was opened and I should have had a look before.

I'd be keen to help fix this if someone is able to give me some guidance in contributing to this project.

That'd be great if you could contribute, how could we help? If you open a PR on the repo we'll happily review before merge.

For reference, this is how the protobuf gradle plugin fixed it.

I had a look at the Protobuf fix and having version checks in the code is not ideal IMO, but we'll need more time to upgrade all web3j projects to Gradle 6.0 so for now I think is the best option.

Resolved in: #40