[groovy-user] GrabResolver and authentication ?

487 views
Skip to first unread message

Grégory Joseph

unread,
Nov 5, 2010, 10:33:53 AM11/5/10
to us...@groovy.codehaus.org
Hi List,

I only just discovered @GrabResolver. Pretty neat, but... I have to
have the following in my grapeConfig.xml:
<ibiblio name="via-nexus"
root="http://gjoseph:<mypassword>@nexus.lalala.com/content/groups/all"
m2compatible="true"/>

.. and it worked nicely.
However, when I try to do the same via an annotation, it doesn't seem
to "work". I don't see anything in the code that would make it not
work, but then again ...

@GrabResolver(name='via-nexus',
root='http://gjoseph:<mypassword>@nexus.lalala.com/content/groups/all',
m2Compatible='true')
@Grab('com.lalala:foobar:1.0.0')
import com.lalala.foobar.Example
println new Example().hello()

... and I get the following exception (see below).

If I change the annotation to point to
'file:///Users/gjoseph/.m2/repository', it just works. So I'm vaguely
assuming this has to do with the auth, but can't explain why it would
work with the config file and not the annotation.

Two side-notes:
* I didn't manage (or don't know how) to debug
GrabAnnotationTransformation - if anyone could point me to how to do
this while executing my script (specifically with intellij), that
could be helpful and i might figure out what's wrong.
* Isn't there a way to *remove* the default resolvers ? If you're
familiar with Maven proxies, you might guess that I'm hoping to proxy
all requests to my Nexus instance. Any hint ?

Thanks,

-greg

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [unresolved
dependency: com.lalala#foobar;1.0.0: not found]

java.lang.RuntimeException: Error grabbing Grapes -- [unresolved
dependency: com.lalala#foobar;1.0.0: not found]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198)
at groovy.grape.GrapeIvy.getDependencies(GrapeIvy.groovy:287)

$

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Peter Niederwieser

unread,
Nov 5, 2010, 10:59:21 AM11/5/10
to us...@groovy.codehaus.org

Grégory Joseph wrote:
>
> I didn't manage (or don't know how) to debug
> GrabAnnotationTransformation - if anyone could point me to how to do
> this while executing my script (specifically with intellij), that
> could be helpful and i might figure out what's wrong.
>

Here is how I usually debug AST transforms in IDEA. Say you have the
following script:

<code>
@SomeTransform
def foo() { ... }

foo()
</code>

Change the script to:

<code>
Eval.me """
@SomeTransform
def foo() { ... }

foo()
"""
</code>

Now set a breakpoint in the AST transform and debug the modified script.

Cheers,
Peter
--
View this message in context: http://groovy.329449.n5.nabble.com/GrabResolver-and-authentication-tp3251904p3251929.html
Sent from the groovy - user mailing list archive at Nabble.com.

Grégory Joseph

unread,
Nov 5, 2010, 11:09:49 AM11/5/10
to us...@groovy.codehaus.org
Thanks Peter -
In the meantime, I realized I could also just print
groovy.grape.Grape.instance.ivyInstance.settings.defaultResolver.chain...
etc.
and as far as I can tell, the settings for my resolver are the same,
whether I use an annotation or the config file...

Grégory Joseph

unread,
Nov 5, 2010, 2:45:48 PM11/5/10
to us...@groovy.codehaus.org
Peter,

Thanks again for the great tip - I was able to dig much further.
As far as I can tell, it's got nothing to do with the AST
transformation per se, but perhaps with classloading, one way or the
other. I found this:
http://www.jaya.free.fr/ivy/doc/use/configure.html
... which seems to indicate that ivy needs commons-httpclient to
support the url i'm trying to load. Still can't figure out why it
works when used in the grapesConfig.xml - maybe a grape/groovy guru
can shed some light here.

In any case, the way I see it, there's no way to let my user
pass/setup his credentials before Grapes/ivy is executed. I might go
back to earlier attempts at packaging my scripts in one big archive
with all their dependencies...

... unless someone has ideas on how to go around all this ?

Essentially, I'd like to ship a small set of scripts - and have them
download their dependencies as needed, preferably *only* via our nexus
repository.

Thoughts ?

2010/11/5 Grégory Joseph <greg...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages