19 lines
1.0 KiB
Markdown
19 lines
1.0 KiB
Markdown
---
|
|
title: "Groovy Goodness: Use GrabResolver for Custom Repositories - Messages from mrhaki"
|
|
tags:
|
|
- 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:
|
|
|
|
```groovy
|
|
@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
|
|
```
|