Migrating an existing Maven private repository to Alibaba Cloud DevOps

更新时间:
复制 MD 格式

This topic shows how to bulk-migrate artifacts from an existing maven private repository to one in Alibaba Cloud DevOps.

Procedure

Alibaba Cloud DevOps provides two methods to migrate artifacts in bulk from an existing maven private repository to Packages:

  • local files batch upload

  • import 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 URL above and save it to your local machine as maven-migration-jar-with-dependencies.jar.

Step 2: Run the migration tool

Local file upload

Ensure that Java 8 or a later version is installed on your machine. To view the help information, run the following command in the directory where the JAR file is located: 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              Performs a dry run without actually uploading artifacts.
      --exclude=<exclude>   The groupIDs to exclude. Separate multiple groupIDs with commas.
  -h, --help                Show this help message and exit.
      --include=<include>   The groupIDs to include. Separate multiple groupIDs with commas.
      --source-dir=<sourceDir>
                            The source directory, for example, ~/.m2/repository.
      --target-repo-password=<repoPassword>
                            The password to access the target repository. You can obtain this from the User Guide in Packages.
      --target-repo-url=<repoUrl>
                            The URL of the target repository. You can obtain this from the User Guide in Packages.
      --target-repo-username=<repoUsername>
                            The username to access the target repository. You can obtain this from the User Guide in Packages.
  -V, --version             Print version information and exit.                      
     
Important

If the help information displays garbled characters, run chcp 65001 in the command line before you run the Java command.

Example command:

  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"

This command uploads all artifacts with the groupID com.taobao.text from your local Maven repository to the target repository. Obtain the required parameters from your target repository in Packages. Navigate to .

高的 - 2024-12-09T160121

Nexus3 import

Ensure that Java 8 or a later version is installed on your machine. To view the help information, run the following command in the directory where the JAR file is located: 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              Performs a dry run without actually uploading artifacts.
      --exclude=<exclude>   The groupIDs to exclude. Separate multiple groupIDs with commas.
  -h, --help                Show this help message and exit.
      --include=<include>   The groupIDs to include. Separate multiple groupIDs with commas.
      --nexus-host=<nexusHost> The URL of the Nexus server.
      --source-repo-id=<repoId> The ID of the source repository.
      --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 target repository. You can obtain this from the User Guide in Packages.
      --target-repo-url=<repoUrl> The URL of the target repository. You can obtain this from the User Guide in Packages.
      --target-repo-username=<repoUsername> The username to access the target repository. You can obtain this from the User Guide in Packages.
  -V, --version             Print version information and exit.
Important

If the help information displays garbled characters, run chcp 65001 in the command line before you run the Java command.

Example command:

  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"

This command uploads all artifacts with the groupID com.taobao.text from the maven-releases repository on the specified Nexus server to the target repository. Obtain the required parameters from your target repository in Packages. Navigate to .

高的 - 2024-12-09T160320

Step 3: Verify the results

When the migration is finished message is displayed, the migration is complete. You can then find the artifacts in your target repository in Packages:

高的 - 2024-12-05T103359

高的 - 2024-12-09T154055