All Products
Search
Document Center

Alibaba Cloud DevOps:Migrate an existing Maven private repository to Alibaba Cloud DevOps Packages

Last Updated:Apr 29, 2025

This topic describes how to migrate artifacts in batches from an existing Maven private repository to an Alibaba Cloud DevOps Maven private repository.

Procedure

Packages supports two methods to migrate artifacts in batches from a Maven private repository to a Packages Maven private repository. You can make a selection based on your requirements.

  • Upload local files in batches

  • Import artifacts from Nexus3

Step 1: Download the migration tool

Download URL: https://agent-install-beijing.oss-cn-beijing.aliyuncs.com/maven-migration-jar-with-dependencies.jar

Download the JAR file from the preceding URL to your local machine and save the file as maven-migration-jar-with-dependencies.jar.

Step 2: Run the migration tool

Upload local files in batches

Make sure that Java 8 or later is installed on your machine. To view the help information, run the following command in the directory of the current JAR file: 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>
Migrate artifacts
      --dryrun              Dry run, artifacts are not uploaded.
      --exclude=<exclude>   Exclude groupIds and multiple groupIds separated by commas.
  -h, --help                Show this help message and exit.
      --include=<include>   Include groupIds and multiple groupIds separated by commas.
      --source-dir=<sourceDir>
                            The source directory, such as ~/.m2/repository.
      --target-repo-password=<repoPassword>
                            The password to access the destination repository can be found in the guide of the repository on packages.aliyun.com.
      --target-repo-url=<repoUrl>
                            The destination repository address can be found in the repository guide on packages.aliyun.com.
      --target-repo-username=<repoUsername>
                            The username to access the destination repository can be found in the repository guide on packages.aliyun.com.
  -V, --version             Print version information and exit.                      
     
Important

If you find garbled Chinese characters in the help information, run the chcp 65001 command in the command line and run the Java command.

Example:

  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"

You can upload all artifacts with the com.taobao.text groupId to the maven-releases Nexus repository by running the preceding command. To view the information about the specific parameters, perform the following steps. Go to the repository details page. In the left-side navigation pane, click User Guide. On the page that appears, click Local files batch upload.

高的 - 2024-12-09T160121

Import artifacts from Nexus3

Make sure that Java 8 or later is installed on your machine. To view the help information, run the following command in the directory of the current JAR package: 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>
Migrate Nexus3 artifacts
      --dryrun              Dry run, artifacts are not actually uploaded.
      --exclude=<exclude>   Exclude groupIds and multiple groupIds separated by commas.
  -h, --help                Show this help message and exit.
      --include=<include>   Include groupIds and multiple groupIds separated by commas.
      --nexus-host=<nexusHost> The Nexus server address
      --source-repo-id=<repoId> The source repository ID
      --source-repo-password=<repoPassword> The password to access the source repository
      --source-repo-username=<repoUsername> The username to access the source repository 
      --target-repo-password=<repoPassword> The password to access the destination repository can be found in the repository guide on packages.aliyun.com
      --target-repo-url=<repoUrl> The destination repository URL can be found in the repository guide on packages.aliyun.com
      --target-repo-username=<repoUsername> The username to access the destination repository can be found in the repository guide on packages.aliyun.com
  -V, --version             Print version information and exit.
Important

If you find garbled Chinese characters in the help information, run the chcp 65001 command in the command line and run the Java command.

Example:

  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"

You can upload all artifacts with the com.taobao.text groupId to the maven-releases Nexus repository by running the preceding command. To view specific parameter information, perform the following steps. Go to the repository details page. In the left-side navigation pane, click User Guide. On the page that appears, click Import from Nexus3.

高的 - 2024-12-09T160320

Step 3: View the execution results

If migration is finished is displayed, it indicates that the migration is complete. You can then view the results in the Packages destination repository.

高的 - 2024-12-05T103359

高的 - 2024-12-09T154055