Files
thpeetz-notes/Quellen/IT/Groovy Goodness_ Use GrabResolver for Custom Repos.md
T

1.0 KiB

title, tags
title tags
Groovy Goodness: Use GrabResolver for Custom Repositories - Messages from mrhaki
IT/Development/Groovy

Groovy Goodness: Use GrabResolver for Custom Repositories

In Groovy we can use the @Grab annotation to define dependencies and automatically download them from public repositories. But maybe we have created our own package and we want to use it in our Groovy script. Our own package is deployed to a customer Maven 2 compatible repository with the url http://customserver/repo, so it is not available to the general public. We can use @GrabResolver to add this repository as a source to look for dependencies in our script. In the following sample code we assume the module groovy-samples, version 1.0 is deployed in the repository accessible via http://customserver/repo:

@GrabResolver(name='custom', root='http://customserver/repo', m2Compatible='true')
@Grab('com.mrhaki:groovy-samples:1.0')
import com.mrhaki.groovy.Sample

def s = new Sample()
s.justToShowGrabResolver()  // Just a sample