為了加速編譯代碼,想將本地maven緩存導入內網私庫使用。
腳本網上搜的
#!/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
# ./mavenimport.sh -u admin -p admin123 -r http://ip:8081/repository/maven-releases/while getopts ":r:u:p:" opt; docase $opt inr) REPO_URL="$OPTARG";;u) USERNAME="$OPTARG";;p) PASSWORD="$OPTARG";;esac
donefind . -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}/{} ;
執行方法注釋中有。
需要注意的是,要在庫的下級目錄執行。如:C:\Users\xxx\.m2\repository 的目錄下。
看到的應該是如下圖目錄:
這樣提交到nexus上才會是com.xxx.xxx或者org.xxx.xxx
開始在repository外執行的,結果目錄變成了repository.com.xxx.xxx導致識別一些問題。
以上