-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnexus_examples_test.go
62 lines (50 loc) · 1.37 KB
/
nexus_examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package nexus_test
import (
"sbrubbles.org/go/nexus"
"sbrubbles.org/go/nexus/credentials"
"sbrubbles.org/go/nexus/search"
"fmt"
"reflect"
)
func Example() {
n := nexus.New("https://maven.java.net", credentials.None)
// obtaining all repositories in Nexus
repositories, err := n.Repositories()
if err != nil {
fmt.Printf("%v: %v", reflect.TypeOf(err), err)
return
}
// printing out all artifacts which are in a hosted repository, and have
// both 'javax.enterprise' in their groupID and a 'sources' classifier.
for _, repo := range repositories {
if repo.Type != "hosted" {
continue
}
artifacts, err := n.Artifacts(
search.InRepository{
RepositoryID: repo.ID,
Criteria: search.ByCoordinates{
GroupID: "javax.enterprise*",
Classifier: "sources"}})
if err != nil {
fmt.Printf("%v: %v", reflect.TypeOf(err), err)
return
}
for _, a := range artifacts {
fmt.Println(a)
}
}
}
func ExampleNexus2x_Artifacts() {
n := nexus.New("http://maven.java.net", credentials.None)
// using a simple search
n.Artifacts(search.ByClassname("javax.servlet.Servlet"))
// using a composite search
n.Artifacts(
search.InRepository{
RepositoryID: "releases",
Criteria: search.ByKeyword("javax.enterprise")})
// searching for every artifact in Nexus (WARNING: this can take a LOOONG
// time - and memory!)
n.Artifacts(search.All)
}