本文介紹如何將已有Maven私庫中的製品包批量遷移到雲效的Maven私庫中。
操作步驟
雲效支援兩種方式將Maven私庫中的製品包批量遷移到雲效的Maven私庫中,您可以根據實際需求進行選擇:
本地檔案批量上傳。
從Nexus3匯入製品。
步驟一:下載遷移工具
工具下載地址:https://agent-install-beijing.oss-cn-beijing.aliyuncs.com/maven-migration-jar-with-dependencies.jar
通過上面地址將jar包下載到本地,儲存為maven-migration-jar-with-dependencies.jar。
步驟二:運行下載工具
本地檔案批量上傳
請確保機器上安裝了java8及以上版本,在當前jar包的目錄下執行如下命令: 運行命令:java -jar maven-migration-jar-with-dependencies.jar migrate --help可以查看協助資訊。
java -jar ./target/maven-migration-jar-with-dependencies.jar migrate --help
Usage: migrate migrate [-hV] [--dryrun] [--exclude=<exclude>]
[--include=<include>] --source-dir=<sourceDir>
--target-repo-password=<repoPassword>
--target-repo-url=<repoUrl>
--target-repo-username=<repoUsername>
遷移製品
--dryrun 試運行,不會真正上傳包
--exclude=<exclude> 排除的groupId,多個groupId以逗號分割
-h, --help Show this help message and exit.
--include=<include> 包含的groupId,多個groupId以逗號分割
--source-dir=<sourceDir>
源檔案目錄,比如~/.m2/repository
--target-repo-password=<repoPassword>
訪問目標倉庫的密碼,可在packages.aliyun.com中倉庫指
南中查看
--target-repo-url=<repoUrl>
目標倉庫地址,可在packages.aliyun.com中倉庫指南中查
看
--target-repo-username=<repoUsername>
訪問目標倉庫的使用者名稱,可在packages.aliyun.com中倉庫
指南中查看
-V, --version Print version information and exit.
如果協助資訊中中文出現亂碼,可先在命令列中執行chcp 65001,然後再執行Java命令。
樣本命令:
java -jar maven-migration-jar-with-dependencies.jar migrate --source-dir="/root/.m2/repository" --target-repo-url="https://packages.aliyun.com/xxxxxx/maven/xxxxx-release-ogcezj" --target-repo-username="672aca1cbecc93xxxxx" --target-repo-password="xxxxxxx" --include="com.taobao.text" --exclude="junit"這條命令會將本地Maven倉庫中groupId為com.taobao.text下的所有包上傳到當前倉庫中。具體參數資訊,可在製品倉庫首頁面,選擇進入目標製品倉庫,在中擷取。

從Nexus3匯入製品
請確保機器上安裝了java8及以上版本,在當前jar包的目錄下執行如下命令: 運行命令:java -jar maven-migration-jar-with-dependencies.jar migrateNexus --help可以查看協助資訊。
java -jar maven-migration-jar-with-dependencies.jar migrateNexus --help
Usage: migrate migrateNexus [-hV] [--dryrun] [--exclude=<exclude>]
[--include=<include>] --nexus-host=<nexusHost>
--source-repo-id=<repoId>
--source-repo-password=<repoPassword>
--source-repo-username=<repoUsername>
--target-repo-password=<repoPassword>
--target-repo-url=<repoUrl>
--target-repo-username=<repoUsername>
遷移nexus3製品
--dryrun 試運行,不會真正上傳包
--exclude=<exclude> 排除的groupId,多個groupId以逗號分割
-h, --help Show this help message and exit.
--include=<include> 包含的groupId,多個groupId以逗號分割
--nexus-host=<nexusHost> nexus伺服器位址
--source-repo-id=<repoId> 源倉庫Id
--source-repo-password=<repoPassword> 訪問源倉庫的密碼
--source-repo-username=<repoUsername> 訪問源倉庫的使用者名稱
--target-repo-password=<repoPassword> 訪問目標倉庫的密碼,可在packages.aliyun.com中倉庫指南中查看
--target-repo-url=<repoUrl> 目標倉庫地址,可在packages.aliyun.com中倉庫指南中查看
--target-repo-username=<repoUsername> 訪問目標倉庫的使用者名稱,可在packages.aliyun.com中倉庫指南中查看
-V, --version Print version information and exit.如果協助資訊中中文出現亂碼,可先在命令列中執行chcp 65001,然後再執行Java命令。
樣本命令:
java -jar maven-migration-jar-with-dependencies.jar migrateNexus --source-repo-id="maven-releases" --source-repo-username="admin" --source-repo-password="admin123" --nexus-host="http://localhost:8081" --target-repo-url="https://packages.aliyun.com/xxxxxxxx/maven/xxxxx-release-ogcezj" --target-repo-username="672aca1cbecc93xxxxx" --target-repo-password="gKUf3xxxxx(" --include="com.taobao.text"這條命令會將指定的Nexus倉庫maven-releases中groupId為com.taobao.text下的所有包上傳到當前倉庫中。具體參數資訊,可在製品倉庫首頁面,選擇進入目標製品倉庫,在中擷取。

步驟三:查看運行結果
出現migration is finished字樣表示遷移已完成,即可在雲效目標製品倉庫中查看:

