예제 #1
0
func ExampleByCoordinates() {
	n := nexus.New("https://maven.java.net", credentials.None)

	// Returns all artifacts with a groupID starting with com.sun. Due to Go's
	// struct syntax, we don't need to specify all the coordinates; they
	// default to string's zero value (""), which Nexus ignores.
	n.Artifacts(search.ByCoordinates{GroupID: "com.sun*"})

	// A coordinate search requires specifying at least either a groupID, an
	// artifactID or a version. This search will (after some time), return
	// nothing. This doesn't mean there are no projects with packaging "pom";
	// this is a limitation of Nexus' search.
	n.Artifacts(search.ByCoordinates{Packaging: "pom"})

	// This search may or may not return an error, depending on the version of
	// the Nexus being accessed. On newer Nexuses (sp?) "*" searches are
	// invalid.
	n.Artifacts(search.ByCoordinates{GroupID: "*", Packaging: "pom"})

	// ByCoordinates searches in Maven *projects*, not artifacts. So this
	// search will return all com.sun* artifacts in projects with packaging
	// "pom", not all POM artifacts with groupID com.sun*! Packaging is not
	// the same as extension.
	n.Artifacts(search.ByCoordinates{GroupID: "com*", Packaging: "pom"})
}
예제 #2
0
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)
		}
	}
}
예제 #3
0
파일: nexus.go 프로젝트: thomasf/alkasir
func getNexusClient() (nexus.Client, error) {
	if nexusURL == "" {
		return nil, fmt.Errorf("nexus-url argument not set")
	}
	if nexusClient == nil {
		nexusClient = nexus.New(nexusURL, credentials.None)
	}
	return nexusClient, nil
}
예제 #4
0
func ExampleByKeyword() {
	n := nexus.New("https://maven.java.net", credentials.None)

	// Return all artifacts with javax.enterprise somewhere.
	n.Artifacts(search.ByKeyword("javax.enterprise*"))

	// This search may or may not return an error, depending on the version of
	// the Nexus being accessed. On newer Nexuses (sp?) "*" searches are
	// invalid.
	n.Artifacts(search.ByKeyword("*"))
}
예제 #5
0
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)
}
예제 #6
0
func ExampleInRepository() {
	n := nexus.New("https://maven.java.net", credentials.None)

	// Returns all artifacts in the repository releases with groupID starting
	// with com.sun and whose project has packaging "pom".
	n.Artifacts(
		search.InRepository{
			"releases",
			search.ByCoordinates{GroupID: "com.sun*", Packaging: "pom"},
		})

	// Nexus doesn't support * in the repository ID parameter, so this search
	// will return an error.
	n.Artifacts(
		search.InRepository{
			"releases*",
			search.ByCoordinates{GroupID: "com.sun*", Packaging: "pom"},
		})
}
예제 #7
0
package nexus

import (
	"runtime"

	"github.com/thomasf/lg"

	"github.com/hanjos/nexus"
	"github.com/hanjos/nexus/credentials"
)

var baseDir = "as-downloads"
var nexusClient = nexus.New("https://nexus.some.domain", credentials.None)
var repoID = "alkasir-releases"

// Quickrunner for the latest archived release
func GetMasterSnapshot(cmd string) error {
	q := BuildQuery{
		OS:   runtime.GOOS,
		Arch: runtime.GOARCH,
		Cmd:  cmd,
	}

	latest, err := q.getMasterSnapshot("alkasir-snapshots")
	if err != nil {
		return err
	}

	_, err = q.GetBinary(latest)
	if err != nil {
		return err