导入本地maven库导入nexus3(脚本)

文件结构如下示例:

[root@localhost shanhy]# tree -C
.
└── myrepo
    ├── mavenimport.sh
    ├── com
    │   └── oracle
    │       └── ojdbc6
    │           └── 11.2.0.4.0
    │               ├── m2e-lastUpdated.properties
    │               ├── ojdbc6-11.2.0.4.0.jar
    │               ├── ojdbc6-11.2.0.4.0.jar.sha1
    │               ├── ojdbc6-11.2.0.4.0-javadoc.jar.lastUpdated
    │               ├── ojdbc6-11.2.0.4.0.pom
    │               ├── ojdbc6-11.2.0.4.0.pom.sha1
    │               ├── ojdbc6-11.2.0.4.0-sources.jar.lastUpdated
    │               └── _remote.repositories
    └── xpp3
        └── xpp3
            └── 1.1.4c
                ├── m2e-lastUpdated.properties
                ├── _maven.repositories
                ├── xpp3-1.1.4c.jar
                ├── xpp3-1.1.4c.jar.sha1
                ├── xpp3-1.1.4c.pom
                ├── xpp3-1.1.4c.pom.sha1
                ├── xpp3-1.1.4c-sources.jar
                └── xpp3-1.1.4c-sources.jar.sha1

8 directories, 17 files
[root@localhost shanhy]# 

其中 mavenimport.sh 内容如下(脚本内容来自互联网):

#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
	case $opt in
		r) REPO_URL="$OPTARG"
		;;
		u) USERNAME="$OPTARG"
		;;
		p) PASSWORD="$OPTARG"
		;;
	esac
done
 
find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

执行脚本的命令示例为:

./mavenimport.sh -u admin -p admin123456 -r http://192.168.1.88:8081/repository/maven-releases/

(END)

发布了378 篇原创文章 · 获赞 1419 · 访问量 632万+

猜你喜欢

转载自blog.csdn.net/catoop/article/details/104304512