Why won't Groovy/Grape resolve artifacts from

2019-07-07 04:02发布

问题:

With a fresh download of Groovy 2.1.9, I create:

// Test.Groovy
@Grab('commons-io:commons-io:1.2')
import org.apache.commons.io.CopyUtils
println "Resolved!"

Then I try running

$ ./groovy-2.1.9/bin/groovy Test.groovy

which fails with

General error during conversion: Error grabbing Grapes -- 
[download failed: commons-io#commons-io;1.2!commons-io.jar]

The artifact is listed in maven central, downloadable here

For what it's worth, various local files are created in:

~/.groovy/grapes/commons-io/commons-io

I'd very much appreciate ideas on how to debug or "resolve"!

Update

If I create a new user on my system (with no dotfiles in her homedir), this works. So I've got some user-specific config that's breaking things. I've tried deleting ~/.groovy, ~/.m2 and ~/.ivy to no avail. What else could it be?

回答1:

Works for me. Not clear what's wrong...

$ groovy -Dgroovy.grape.report.downloads=true test
Resolving dependency: commons-io#commons-io;1.2 {default=[default]}
Preparing to download artifact commons-io#commons-io;1.2!commons-io.jar
Downloaded 64 Kbytes in 323ms:
  [SUCCESSFUL ] commons-io#commons-io;1.2!commons-io.jar (306ms)
Resolved!

To dig some more you can enable debug as follows:

groovy -Divy.message.logger.level=4 test


回答2:

I am running Groovy 2.2.2 and have the same problem. I solved by deleting ~/.ivy2.