Gradle - Could not find method wrapper() - dependant projects
Asked Answered
S

1

10

My project structure looks like bellow:

-Main dir
  - .gradle-wrapper
  |  - gradle-wrapper.jar
  |  - gradle-wrapper.properties
  |
  - projects
     - library
     - library-consumer

Inside library and library-consumer I have both build.gradle with:

wrapper {
    jarFile = "${project.projectDir}/../../.gradle-wrapper/gradle-wrapper.jar"
    gradleVersion = '4.8.1'
}

Also, in project library-consumer I have in build.gradle dependency to library project as

compile project(':library')

In library-consumer's settings.gradle I have included library like said here:

include ':library'
project(':library').projectDir = new File("../library")

Then I receive following error while trying gradle build:

Could not find method wrapper() for arguments [build_7cibagmqy9u5sctvqdtah2a8p$_run_closure1@134371ea] on project ':library' of type org.gradle.api.Project.

Any sugestion/solution? Both projects has included changed path to wrapper like bellow:

set CLASSPATH=%APP_HOME%\..\..\.gradle-wrapper\gradle-wrapper.jar

library builds without problem.

Stodgy answered 30/7, 2018 at 10:48 Comment(2)
Do you got any solution for this?Badinage
@Badinage No, unfortunately not, I made one "master build" which has wrapper definition and subprojects :/Stodgy
C
0

In gradle versions below version 5, you had to declare a wrapper task rather than attempting to configure an existing one.

See the upgrade guide here.

It looks like you have not upgrade to version 5, so you need to do:

task wrapper(type: Wrapper) {
    jarFile = "${project.projectDir}/../../.gradle-wrapper/gradle-wrapper.jar"
    gradleVersion = '4.8.1'
}
Coady answered 26/10, 2019 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.