3

I'm trying to use Grape for:

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )

However when I add that line in IntelliJ, I get the message:

Error:Groovyc: While compiling [project]: Cannot @Grab without Ivy, please add it to your module dependencies (NoClassDefFoundError: org/apache/ivy/plugins/resolver/DependencyResolver)

I tried to lookup how to do this but couldn't find a clear step-by-step guide (I'm very new to this)

Adding the IvyIDEA plugin didn't seem to resolve the issue.

enter image description here

I tried downloading the library but nothing I type in the search box seems gives any results (ivy, apacheivy, apache-ivy, ivy-2.5 etc.)

Then I tried downloading the jar itself from http://ant.apache.org/ivy/download.cgi - I chose the apache-ivy-2.5.0-src.zip option and unzipped it and then tried adding it as a dependency:

enter image description here

When I select the unzipped folder, I end up with an Empty Library - maybe it's looking for a .jar file instead of a folder? But when I unzipped the download there was no .jar in there so I'm not sure if I maybe did the download wrong..?

Then I thought to try adding ivy as a dependency in my project's build.gradle but couldn't find the syntax for how to add it - every google search took me to links about Ivy itself. The maven website's "gradle" tab also isn't working:

enter image description here

So I tried a few things in my root project's build.gradle like so:

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile 'ant.apache.org:ivy-2.5.0'
}

IntelliJ can't find the ivy dependency as I've typed it but I have no idea what it's supposed to look like and can't find the appropriate syntax.

I'm really struggling with this but also feel like it shouldn't be this difficult for me to get this working. Can someone give me a super explicit step by step for how to get my Grape line for http-builder working?

M. Justin
  • 14,487
  • 7
  • 91
  • 130
Sam Jones
  • 43
  • 5

2 Answers2

1

I chose the apache-ivy-2.5.0-src.zip option and unzipped it and then tried adding it as a dependency

This is an inaccurate step. You need to download "binary with dependencies", unzip it, and choose the "lib" folder as a dependency inside IntelliJ IDEA settings (as on the second screenshot).

Be careful, however. If your prooject is a Gradle project, you need to define all dependencies in the build.gradle file (as it is the source of truth for IntelliJ IDEA).

Konstantin Annikov
  • 11,655
  • 4
  • 27
  • 40
  • Ah okay thanks for that step! I've successfully added the "lib" folder as a dependency. To your second point, would you happen to know the exact line I need to add to my build.gradle? I tried adding a "compile 'apache-ivy-2.5.0'" under the dependencies{} block but I get a message saying my "notation is invalid" Then I tried "compile 'ant.apache.org:apache-ivy-2.5.0'" which resulted in a message saying "could not find" Any suggestions? – Sam Jones Jul 12 '21 at 10:40
  • Can you share a sample project where this could be reproduced? GitHub link, or any other – Konstantin Annikov Jul 13 '21 at 02:51
-1

Like @konstantin above said, I had to add the lib folder, but also had to add the ivy jar, as well. Then, it works.

unhuman
  • 19
  • 2