目录
目录README.md

maven-dependencies

Maven 依赖 脚手架

License-Anti Link-996 QQ群

基于 go 语言的 Maven 依赖 脚手架

为简化开发工作、提高生产率、解决常见问题而生

支持的系统

  1. Linux amd64、arm64
  2. Windows amd64、arm64
  3. Mac amd64、arm64
  4. LoongArch 64-bit

构建

本项目发布在 GitHub 进行构建,并使用构建后的程序将自己发布到各大代码托管平台,发布过程参见: GitHub Actions

下载

  1. gitee
  2. gitlab
  3. github
  4. gitlink

支持的功能

  1. 一键发布到 github,可包含产物上传
  2. 一键发布到 gitlab,可包含产物上传,可自定义域名(支持自建 gitlab),支持将产物文件名、链接导出为 map,可供 gitee 使用
  3. 一键发布到 gitee,由于 gitee 暂不支持提供上传产物的 API 接口, 本工具支持提供 json 文件(map 形式,键:代表文件名,值:代表下载链接)作为产物, 本项目使用 GitLink 作为 gitee 产物链接
  4. 一键发布到 gitlink,可包含产物上传(需要等到官方开放 token 功能,或者联系官方人员申请 token 才能使用), 本工具支持提供 json 文件(map 形式,键:代表文件名,值:代表下载链接)作为产物

开发命令

get

go env -w GOPROXY=https://goproxy.cn,direct
# go env -w GOPROXY=https://proxy.golang.org,direct
# go env -w GOPROXY=https://goproxy.io,direct
# go env -w GOPROXY=https://mirrors.aliyun.com/goproxy,direct
# go env -w GOPROXY=https://mirrors.cloud.tencent.com/go,direct
go get -u github.com/urfave/cli/v2
go get -u github.com/xuxiaowei-com-cn/git-go@main
go get -u github.com/stretchr/testify/assert

mod

go mod tidy
go mod download

run

go run main.go

run help

  • Windows 环境为 %xxx%
  • Linux 环境为 $xxx
go run main.go --help
$ go run main.go --help
NAME:
   maven-dependencies - 基于 Go 语言开发的 Maven 依赖 命令行工具

USAGE:
   maven-dependencies [global options] command [command options]

VERSION:
   dev

AUTHOR:
   徐晓伟 <xuxiaowei@xuxiaowei.com.cn>

COMMANDS:
   dependency  Maven 依赖坐标
   current     Maven 当前坐标
   help, h     Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

COPYRIGHT:
   徐晓伟工作室 <xuxiaowei@xuxiaowei.com.cn>
$ go run main.go dependency --help
NAME:
   maven-dependencies dependency - Maven 依赖坐标

USAGE:
   maven-dependencies dependency command [command options]

COMMANDS:
   edit     修改 Maven 依赖坐标
   help, h  Shows a list of commands or help for one command

OPTIONS:
   --file-path value    File Path
   --group-id value     Maven groupId
   --artifact-id value  Maven artifactId
   --help, -h           show help
$ go run main.go dependency edit --help
NAME:
   maven-dependencies dependency edit - 修改 Maven 依赖坐标

USAGE:
   maven-dependencies dependency edit [command options] [arguments...]

OPTIONS:
   --file-path value          File Path
   --group-id value           Maven groupId
   --artifact-id value        Maven artifactId
   --after-group-id value     After Maven groupId
   --after-artifact-id value  After Maven artifactId
   --after-version value      After Maven version
   --help, -h                 show help
$ go run main.go current --help
NAME:
   maven-dependencies current - Maven 当前坐标

USAGE:
   maven-dependencies current command [command options]

COMMANDS:
   edit     修改 Maven 当前坐标
   help, h  Shows a list of commands or help for one command

OPTIONS:
   --file-path value          File Path
   --after-group-id value     After Maven groupId
   --after-artifact-id value  After Maven artifactId
   --after-version value      After Maven version
   --help, -h                 show help
$ go run main.go current edit --help
NAME:
   maven-dependencies current edit - 修改 Maven 当前坐标

USAGE:
   maven-dependencies current edit [command options] [arguments...]

OPTIONS:
   --file-path value          File Path
   --after-group-id value     After Maven groupId
   --after-artifact-id value  After Maven artifactId
   --after-version value      After Maven version
   --help, -h                 show help

test

go test ./... -v

build

go build
# GOOS=:设置构建的目标操作系统(darwin | freebsd | linux | windows)
# GOARCH=:设置构建的目标操作系统(386 | amd64 | arm | arm64)
# -v:打印编译过程中的详细信息
# -ldflags:设置在编译时传递给链接器的参数
# -ldflags "-s -w -buildid="
#                           -s: 删除符号表信息,减小可执行文件的大小。
#                           -w: 删除调试信息,使可执行文件在运行时不会打印调试信息。
#                           -buildid=: 删除构建ID,使可执行文件在运行时不会打印构建ID。
# -trimpath:去掉所有包含 go path 的路径
# -o:指定构建后输出的文件名
  • Windows

    • amd64
      go build -o buildinfo/buildinfo.exe buildinfo/buildinfo.go
      GOOS=windows GOARCH=amd64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo.exe now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo.exe commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo.exe commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo.exe commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo.exe commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo.exe commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo.exe git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo.exe commitTag) -X main.GoVersion=$(buildinfo/buildinfo.exe goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=windows/amd64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-windows-amd64.exe .
    • arm64
      go build -o buildinfo/buildinfo.exe buildinfo/buildinfo.go
      GOOS=windows GOARCH=arm64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo.exe now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo.exe commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo.exe commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo.exe commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo.exe commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo.exe commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo.exe git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo.exe commitTag) -X main.GoVersion=$(buildinfo/buildinfo.exe goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=windows/arm64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-windows-arm64.exe .
  • Linux

    • amd64
      go build -o buildinfo/buildinfo buildinfo/buildinfo.go
      GOOS=linux GOARCH=amd64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo commitTag) -X main.GoVersion=$(buildinfo/buildinfo goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=linux/amd64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-linux-amd64 .
    • arm64
      go build -o buildinfo/buildinfo buildinfo/buildinfo.go
      GOOS=linux GOARCH=arm64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo commitTag) -X main.GoVersion=$(buildinfo/buildinfo goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=linux/arm64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-linux-arm64 .
  • LoongArch

    • 64-bit
      go build -o buildinfo/buildinfo buildinfo/buildinfo.go
      GOOS=linux GOARCH=loong64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo commitTag) -X main.GoVersion=$(buildinfo/buildinfo goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=darwin/amd64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-loong64 .
  • Darwin

    • amd64
      go build -o buildinfo/buildinfo buildinfo/buildinfo.go
      GOOS=darwin GOARCH=amd64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo commitTag) -X main.GoVersion=$(buildinfo/buildinfo goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=darwin/amd64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-darwin-amd64 .
    • arm64
      go build -o buildinfo/buildinfo buildinfo/buildinfo.go
      GOOS=darwin GOARCH=arm64 go build -v -ldflags "-s -w -buildid= -X main.BuildDate=$(buildinfo/buildinfo now) -X main.Compiler= -X main.GitCommitBranch=$(buildinfo/buildinfo commitBranch) -X main.GitCommitSha=$(buildinfo/buildinfo commitSha) -X main.GitCommitShortSha=$(buildinfo/buildinfo commitShortSha) -X main.GitCommitTag=$(buildinfo/buildinfo commitTag) -X main.GitCommitTimestamp=$(buildinfo/buildinfo commitTimestamp) -X main.GitTreeState=$(buildinfo/buildinfo git-tree-state) -X main.GitVersion=$(buildinfo/buildinfo commitTag) -X main.GoVersion=$(buildinfo/buildinfo goShortVersion) -X main.Major= -X main.Minor= -X main.Revision= -X main.Platform=darwin/arm64 -X main.CiPipelineId= -X main.CiJobId=" -trimpath -o maven-dependencies-darwin-arm64 .
关于
215.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号