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

1.1 KiB

title, updated, created, tags
title updated created tags
Groovy Goodness: Use GrabResolver for Custom Repositories - Messages from mrhaki 2019-02-26 11:54:37Z 2019-02-26 11:53:45Z
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