0

enter image description herecan anybody help me solve this problem

Could not find method compile() for arguments [project ':moqui-util'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.enter image description here

m.mahdi_rasouli
  • 82
  • 1
  • 1
  • 7
  • 4
    [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/q/285551/3111149) – Matteo NNZ May 26 '21 at 11:45
  • 5
    some people do not like to read code from black background; most cannot copy code from an image –  May 26 '21 at 11:47
  • Does this answer your question? [What's the difference between implementation, api and compile in Gradle?](https://stackoverflow.com/questions/44493378/whats-the-difference-between-implementation-api-and-compile-in-gradle) – Elikill58 Mar 08 '22 at 21:31

2 Answers2

7

If you are using Gradle version 7.0+, then compile dependency configuration is removed from that. You might need to look for implementation dependency configuration in place of compile.

PS: Do not forget to rebuild your gradle file.

More info can be found here at my another answer for this deprecation.

https://stackoverflow.com/a/67695126/8148637

KnockingHeads
  • 1,569
  • 1
  • 22
  • 42
  • I dont exactly understand your answer could you please tell me what should I do in code ? – m.mahdi_rasouli May 26 '21 at 12:11
  • 1
    In dependencies {} closure in your build file, you have some compile dependencies like 'javax.cache','javax.servlet' . Replace them from being compile dependencies to be implementation dependencies. In other words, replace the word compile at the starting of all such dependencies with the word 'implementation' – KnockingHeads May 26 '21 at 12:13
  • You need to reload your gradle build file after the change. It will appear at the right top of your editor when you make the change. – KnockingHeads May 26 '21 at 12:37
  • @KnockingHeads How to resolve this issue in case of plugins {} closure dependency and not the dependencies {} closure? – Nobita Dec 16 '21 at 07:37
  • TL;DR compile is deprecated, use implementation instead. – Tigerrrrr Aug 04 '23 at 19:16
6

It looks pretty straightforward, but i didn't see many examples of what needs to be changed. This is what I had to do:

Anything like this, change from

compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'

to

implementation 'org.slf4j:slf4j-log4j12:1.7.25'

I also had to change the way mainClass is declared

mainClassName = 'package.MainClass'

to

application {
mainClass = 'package.MainClass'

}

To get to this, I had to delete the gradle files and folder, and do a gradle init to recreate the build configs and dependencies. Use implementation, runtimeOnly, compileOnly etc. as the new equivalents

Dharman
  • 30,962
  • 25
  • 85
  • 135
kriver
  • 1,588
  • 3
  • 20
  • 33