Gradle equivalent required

Hi Gradle team,

I searched for gradle equivalent of below maven plugin , but whatever I found is not working. Please help


The gradle equivalent I found is as follow, but it’s throwing error which is as given below

dependencies {
    compile(group: 'org.apache.velocity', name: 'velocity-tools', version: '2.0') {
        exclude group: 'org.apache.struts', module: 'struts-core'
        exclude group: 'org.apache.struts', module: 'struts-taglib'
        exclude group: 'org.apache.struts', module: 'struts-tiles'

error I am getting as below:

Could not find method org.apache.velocity:velocity-tools:2.0() for arguments [build_9y.....] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.defaultDependencyHandler.

I have attached screenshot as after saving, the maven plugin is not visible properly

Have a look at your post source / edit history now. :wink:

error I am getting as below:

I strongly recommend using the Kotlin DSL, which also is the default by now. You immediately get type-safe build scripts, much better error messages in case you mess up the syntax like here, and amazingly better IDE support when using a decent IDE like IntelliJ IDEA or Android Studio.

Guessing that you are not on an ancient Gradle version, but on at least 7.0 (which is also older than 2 years already), the compile configuration on which you try to declare a dependency does not exist anymore and before was deprecated for many years. So that is most probably the cause of your issue, while it is very hard to say from the Groovy DSL error message.

What you tried though is most probably not equivalent to your Maven snippet.
It is more or less how you declare a dependency with excludes, yes.
But you try to add it to the compile classpath.
Which is not what that Maven snippet is doing.
It adds this dependencies (with the excludes) to the classpath of the maven-dependency-plugin classpath.
What this is for or what it should achieve, I can only guess.

1 Like