Home > Enterprise >  Cannot set the value of read-only property 'group' for DefaultExternalModuleDependency
Cannot set the value of read-only property 'group' for DefaultExternalModuleDependency

Time:09-30

I am solving duplicate issue due build process caused by a new library. There are some duplicate classes or a whole package of bouncycastle. The issue is the default way to exclude a class or a whole group brings this issue:

Caused by: groovy.lang.GroovyRuntimeException: Cannot set the value of read-only property 'group' for DefaultExternalModuleDependency{group='org.web3j', name='core', version='4.8.7-android', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency

Code itself:

implementation('org.web3j:core:4.8.7-android') {
    exclude(group = 'org.bouncycastle')
}

Is there some changes in exclude usage over the past few years?

CodePudding user response:

It's just a syntax issue, the exclude method expects a Map parameter. it looks like you are using the Groovy DSL, and in Groovy maps are created using : character ( in Kotlin DSL you would use = as you did)

So just replace = assignement by : as follows:

    implementation('org.web3j:core:4.8.7-android') {
        exclude(group : 'org.bouncycastle')
    }

See some examples here https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps

  • Related