java

package
v3.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadPomFromRepo

func DownloadPomFromRepo(dep PomDependency, do func(r io.Reader), repos ...common.RepoConfig)

DownloadPomFromRepo 从maven仓库下载pom dep: pom的dependency内容 do: 对http.Response.Body的操作 repos: 额外使用的maven仓库

func MvnTree

func MvnTree(ctx context.Context, pom *Pom) *model.DepGraph

MvnTree 调用mvn dependency:tree解析依赖 pom: pom文件信息

func ParsePoms

func ParsePoms(ctx context.Context, poms []*Pom, exclusion []*Pom, call func(pom *Pom, root *model.DepGraph))

ParsePoms 解析一个项目中的pom文件 poms: 项目中全部的pom文件列表 exclusion: 不需要解析的pom文件 call: 每个pom文件会解析成一个依赖图 返回对应的依赖图

func RegisterMavenOrigin

func RegisterMavenOrigin(origin func(groupId, artifactId, version string) *Pom)

RegisterMavenOrigin 注册maven数据源 origin: 获取数据源 gav=>pom

func RegisterMavenRepo

func RegisterMavenRepo(repos ...common.RepoConfig)

Types

type Pom

type Pom struct {
	PomDependency
	Parent               PomDependency    `xml:"parent"`
	Properties           PomProperties    `xml:"properties"`
	DependencyManagement []*PomDependency `xml:"dependencyManagement>dependencies>dependency"`
	Dependencies         []*PomDependency `xml:"dependencies>dependency"`
	Modules              []string         `xml:"modules>module"`
	Repositories         []string         `xml:"repositories>repository>url"`
	Mirrors              []string         `xml:"mirrors>mirror>url"`
	Licenses             []string         `xml:"licenses>license>name"`
	Profiles             []Pom            `xml:"profiles>profile"`
	// 当前pom对应的文件信息
	File *model.File `xml:"-" json:"-"`
}

Pom pom信息

func ReadPom

func ReadPom(reader io.Reader) *Pom

ReadPom 读取pom信息

func (*Pom) Update

func (p *Pom) Update(dep *PomDependency)

Update 使用pom信息更新当前依赖中使用的属性

type PomDependency

type PomDependency struct {
	ArtifactId   string           `xml:"artifactId"`
	GroupId      string           `xml:"groupId"`
	Version      string           `xml:"version"`
	Type         string           `xml:"type"`
	Scope        string           `xml:"scope"`
	Classifier   string           `xml:"classifier"`
	RelativePath string           `xml:"relativePath"`
	Optional     bool             `xml:"optional"`
	Exclusions   []*PomDependency `xml:"exclusions>exclusion"`
	// 定义当前依赖的pom
	Define *Pom `xml:"-"`
	// 当前依赖引用的属性
	RefProperty *Property `xml:"-"`
	// 定义当前依赖标签位置起始行号
	Start int `xml:",start"`
	// 定义当前依赖标签位置结束行号
	End int `xml:",end"`
}

PomDependency pom依赖

func (PomDependency) Check

func (dep PomDependency) Check() bool

Check 检查是否是合法maven依赖

func (PomDependency) GAV

func (pd PomDependency) GAV() string

GAV is groupId:artifactId:version

func (PomDependency) ImportPath

func (dep PomDependency) ImportPath() []PomDependency

ImportPath 引入路径

func (PomDependency) ImportPathStack

func (dep PomDependency) ImportPathStack() string

ImportPathStack 引入路径栈

func (PomDependency) Index2

func (pd PomDependency) Index2() string

Index2 is groupId:artifactId:classifier:type

func (PomDependency) Index3

func (pd PomDependency) Index3() string

Index3 is groupId:artifactId:classifier:type:version

func (PomDependency) Index4

func (pd PomDependency) Index4() string

Index4 is groupId:artifactId:classifier:type:version:scope

func (PomDependency) NeedExclusion

func (pd PomDependency) NeedExclusion(dep PomDependency) bool

NeedExclusion 判断是否是当前依赖需要排除的子依赖

type PomProperties

type PomProperties map[string]*Property

PomProperties pom属性集合

func (*PomProperties) UnmarshalXML

func (pp *PomProperties) UnmarshalXML(d *xml.Decoder, s xml.StartElement) error

type Property

type Property struct {
	// 属性名
	Key string
	// 属性值
	Value string
	// 定义当前属性的pom
	Define *Pom
	// 定义当前属性标签位置起始行号
	Start int
	// 定义当前属性标签位置结束行号
	End int
}

Property pom属性

type Sca

type Sca struct {
	NotUseMvn    bool
	NotUseStatic bool
}

func (Sca) Filter

func (sca Sca) Filter(relpath string) bool

func (Sca) Language

func (sca Sca) Language() model.Language

func (Sca) Sca

func (sca Sca) Sca(ctx context.Context, parent *model.File, files []*model.File, call model.ResCallback)

Directories

Path Synopsis
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
Package xml implements a simple XML 1.0 parser that understands XML name spaces.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL