maven -nexus 导入已有的maven仓

参考:https://www.jianshu.com/p/6971fca953fc 

## nexus新建本地仓my_repo

## 新建一个文件夹 myrepo,将本地仓库的包批量放入我们需要的本地库文件夹,注意必须将package层级都拷贝

## 在 myrepo文件夹下执行如下命令创建一个 shell 脚本:mavenimport.sh

chmod +x 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 123 -r http://192.168.60.133:8081/repository/my_repo/

注意:1.导入到nexus 上要是空的仓库。

  2.导入后需要rebuild index 

 

posted @ 2023-02-10 14:07  higsan  阅读(18)  评论(0编辑  收藏  举报