[groovy-user] Jenkins and Grapes and CLASSPATH, oh my!

402 views
Skip to first unread message

Brian Brown

unread,
Mar 6, 2014, 4:53:23 PM3/6/14
to us...@groovy.codehaus.org

Hello All,

I'm using Groovy 2.2.2 on Windows 7 64-bit. My Java version is 1.7.0_45

I'm using the @Grab annotation to grab things I need to run my scripts, and it dutifully downloads everything I put in my annotations, which I can verify in ~/.groovy/grapes (really %UserProfile%.groovy\grapes).

I'm programmatically using TestNG and ReportNG, and I'm using the latest versions (testng-6.8.8.jar and reportng-1.1.4.jar - I removed testng-6.8.5 from GROOVY_HOME/lib).

When I try to run my testRunner.groovy file, it downloads the jars and complained about not finding com.google.inject.Module, so I added guice-2.0, and it also in fact is properly installed in by grapes folder.

If I run this code in groovy, the output shows nothing related to grapes (not sure if it should)

def printClassPath(classLoader) {
println "$classLoader"
classLoader.getURLs().each {url->
println "- ${url.toString()}"
}
if (classLoader.parent) {
printClassPath(classLoader.parent)
}
}
printClassPath this.class.classLoader

so, even though it downloaded and installed the jar in the grapes folder properly, it doesn't find it. IF, however, I simply copy guice-2.0.jar to GROOVY_HOME/lib, everything works.

The goal is to run this from jenkins, and after I copied the file above, it works fine from jenkins, but I want the Grapes functionality so rolling out new slaves is simpler affair.

And thoughts on what it is I'm missing about how this should work?

Thanks!

  • Brian

Brian Brown

unread,
Mar 6, 2014, 4:56:52 PM3/6/14
to us...@groovy.codehaus.org

A couple of things to note:

testng-6.8.8.jar and reportng-1.1.4.jar are not in my GROOVY_HOME/lib folder, they are only in the ~/.groovy/grapes folder, and they resolve just fine! Also, I have no ~/.groovy/lib, so I've verified that there not extra jar files floating around.

  • Brian

Paul King

unread,
Mar 7, 2014, 7:05:49 AM3/7/14
to us...@groovy.codehaus.org

What happens if you use the following script as your test (in a file TestNG.groovy):

==============>8===============
@Grab('org.codehaus.groovy:groovy-testng:2.2.2')
//@Grab('org.testng:testng:6.8.8')
@Grab('com.google.inject:guice:2.0')
@GrabConfig(systemClassLoader=true)
import org.testng.annotations.Test

class TestNG {
@Test
void "check string size"() {
assert 'foo'.size() == 3
}
}
==============>8===============

I was just using the TestNG versions which came with Groovy 2.2.2 as a starting point, then try uncommenting the commented out Grab and see if it still works.

Cheers, Paul.

On 7/03/2014 7:56 AM, Brian Brown wrote:
> A couple of things to note:
>
> testng-6.8.8.jar and reportng-1.1.4.jar are not in my GROOVY_HOME/lib folder, they are only in the ~/.groovy/grapes folder, and they resolve just fine! Also, I have no ~/.groovy/lib, so I've verified that there not extra jar files floating around.
>
> * Brian
>
> On 6 Mar 2014, at 14:53, Brian Brown wrote:
>
> Hello All,
>
> I'm using Groovy 2.2.2 on Windows 7 64-bit. My Java version is 1.7.0_45
>
> I'm using the @Grab annotation to grab things I need to run my scripts, and it dutifully downloads everything I put in my annotations, which I can verify in ~/.groovy/grapes (really %UserProfile%.groovy\grapes).
>
> I'm programmatically using TestNG and ReportNG, and I'm using the latest versions (testng-6.8.8.jar and reportng-1.1.4.jar - I removed testng-6.8.5 from GROOVY_HOME/lib).
>
> When I try to run my testRunner.groovy file, it downloads the jars and complained about not finding com.google.inject.Module, so I added guice-2.0, and it also in fact is properly installed in by grapes folder.
>
> If I run this code in groovy, the output shows nothing related to grapes (not sure if it should)
>
> def printClassPath(classLoader) {
> println "$classLoader"
> classLoader.getURLs().each {url->
> println "- ${url.toString()}"
> }
> if (classLoader.parent) {
> printClassPath(classLoader.parent)
> }
> }
> printClassPath this.class.classLoader
>
> so, even though it downloaded and installed the jar in the grapes folder properly, it doesn't find it. IF, however, I simply copy guice-2.0.jar to GROOVY_HOME/lib, everything works.
>
> The goal is to run this from jenkins, and after I copied the file above, it works fine from jenkins, but I want the Grapes functionality so rolling out new slaves is simpler affair.
>
> And thoughts on what it is I'm missing about how this should work?
>
> Thanks!
>
> * Brian
>


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com


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

http://xircles.codehaus.org/manage_email


Brian Brown

unread,
Mar 7, 2014, 5:10:55 PM3/7/14
to us...@groovy.codehaus.org

Paul King

unread,
Mar 7, 2014, 7:23:35 PM3/7/14
to us...@groovy.codehaus.org

You basically need the groovy-testng classes and the other testng related classes to be loaded from the same classloader. There are a couple of ways to do this. You might find that if your groovy isn't configured to use the groovy-all jar that you could just delete the groovy-testng jar from your distro and then you might not need the @GrabConfig annotation at all but it's usually best to leave the CI server distro in a default state and then using the @GrabConfig is the best way to go. Basically there is a classloader hierarchy in place - normally you can see things up the hierarchy but you can't go back down the hierarchy.

Cheers, Paul.
http://www.avast.com
Reply all
Reply to author
Forward
0 new messages