Maven工程源码迁移分析功能说明
命令功能
使用命令通过终端工具进行Maven工程源码迁移分析,通过mvn指令调取Maven插件,解析POM文件中依赖的兼容性,并生成HTML报告。

同一台服务器上,不支持启动多个命令进行Maven工程分析。
命令格式
- Linux环境
1
devkit sys-mig {-c mvn_analyse | --command mvn_analyse} [-cf configure_file_path | --config configure_file_path] [-d scan_path | --directory scan_path] [-o report_dir | --output report_dir] [-l {0/1/2/3 | --log-level {0/1/2/3}] [-v | --version] [-h | --help]
- Windows环境
1
sys-mig.exe {-c mvn_analyse | --command mvn_analyse} [-cf configure_file_path | --config configure_file_path] [-d scan_path | --directory scan_path] [-o report_dir | --output report_dir] [-l {0/1/2/3 | --log-level {0/1/2/3}] [-v | --version] [-h | --help]
参数说明
参数 |
参数选项 |
说明 |
---|---|---|
-h/--help |
- |
获取帮助信息。 |
-c/--command |
stmt/sbom/mvn_analyse |
收集信息的模式。
|
-cf/--config |
- |
输入参数配置文件路径。支持通过配置文件方式输入参数,默认模板位置为sys-mig/resources/sysmig_default.conf,具体使用示例请参见扫描规则文件使用示例。 |
-d/--directory |
- |
输入扫描文件目录,支持输入多个目录,多个目录间以空格分隔。 例如:/home/test1 /home/test2。 |
-o/--output |
- |
报告输出目录,默认为sys-mig二进制所在report目录。 例如:/home/report。 |
-l/--log-level |
0/1/2/3 |
设置日志级别,默认为1。
|
-v/--version |
- |
展示程序版本信息,无需输入参数。 |
环境检查
在执行命令前,需要确保已安装Maven 3.6*或者3.8.*。若未安装或已安装但版本不符合要求,请按照如下步骤进行操作。
- 获取Maven安装包(https://archive.apache.org/dist/maven/maven-3)。
- 解压安装包。以Linux环境下3.6.3为例。
1
tar -zxvf apache-maven-3.6.3-bin.tar.gz
- 配置环境变量。
1
vi /etc/profile
添加如下内容,若已安装请修改环境变量为最新路径:1 2
export MAVEN_HOME=/path/to/apache-maven-3.6.3 export PATH=$MAVEN_HOME/bin:$PATH
MAVEN_HOME:Maven解压后目录,请根据实际情况进行替换。
- 运行以下命令使配置生效。
1
source /etc/profile
- 验证安装是否成功。
1
mvn -v
返回如下信息表示安装成功:
1 2 3 4 5
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /opt/tools/installed/apache-maven-3.6.3 Java version: 1.8.0_272, vendor: Bisheng, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.272.b10-7.oe1.aarch64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.19.90-2012.4.0.0053.oe1.aarch64", arch: "aarch64", family: "unix"
使用示例
- 此处以扫描“/home/maven_analyse/mvn_analyse_test_plugin/”目录下工程且扫描报告输出至“/home/report”为例,请根据实际情况修改。
1
devkit sys-mig -c mvn_analyse -d /home/maven_analyse/mvn_analyse_test_plugin -o /home/report
返回信息如下:
[2025-02-25 09:52:21,104] [INFO] Start to execute the command: ./devkit sys-mig -cf /root/DevKit-Sys-Mig-CLI-x.x.x-Linux-Kunpeng/sys-mig/resources/sysmig_default.conf -d /home/maven_analyse/mvn_analyse_test_plugin -o /home/report -l 1 [2025-02-25 09:52:21,104] [INFO] Creating file indexing... [2025-02-25 09:52:21,104] [INFO] Parsing... [2025-02-25 09:52:21,104] [INFO] Start Scanning maven information. [2025-02-25 09:52:21,304] [INFO] The Maven version passes the check: 3.8.8 [2025-02-25 09:52:22,481] [INFO] Using local repository at: /root/.m2/repository [2025-02-25 09:52:22,482] [INFO] Start to install mvn_analyse plugin, please ensure that the mirror and proxy settings in the settings.xml file are correct, and verify that remote repositories (such as Central Repository and Private Repositories) are accessible. Installing... [2025-02-25 09:52:22,482] [INFO] Some steps may require downloads and can be time-consuming. You can open a new terminal and use `tail -f /home/report/sys-mig_xx.xx.xx.xx_20250225095221/analyse_result_dir/stdout.txt` to view the temporary logs of the mvn_analyse plugin execution. [2025-02-25 09:52:23,952] [INFO] Install mvn_analyse plugin success [2025-02-25 09:52:23,952] [INFO] Start to analyse maven dependencies in /home/maven_analyse/mvn_analyse_test_plugin, please ensure that the mirror and proxy settings in the settings.xml file are correct, and verify that remote repositories (such as Central Repository and Private Repositories) are accessible. Analysing... [2025-02-25 09:52:23,953] [INFO] Some steps may require downloads and can be time-consuming. You can open a new terminal and use `tail -f /home/report/sys-mig_xx.xx.xx.xx_20250225095221/analyse_result_dir/plugin_stdout.txt` to view the temporary logs of the mvn_analyse plugin execution. [2025-02-25 09:52:29,133] [INFO] Execute plugin success in project directory /home/maven_analyse/mvn_analyse_test_plugin Html report is created successfully. The file is located in /home/report/sys-mig_xx.xx.xx.xx_20250225095221/mvn_analyse.html
- 查看评估报告,报告显示有1个可兼容依赖,单击“展开”,可查看完整处理建议。图1 评估报告1
表2 依赖文件统计参数说明 参数
说明
文件总数
扫描工程中已兼容、可兼容和待修改的依赖文件总数(若直接依赖与间接依赖均已兼容,则不在表格中展示)。
可兼容
通过使用鲲鹏镜像仓或华为云提供的文件包替换后,可兼容目标硬件平台,具体操作请参见表格中处理建议。
待修改
需要用户自行处理以达到兼容目标硬件平台,具体操作请参见表格中处理建议。
- 根据处理建议修改。
- 修改setting.xml文件,文件路径请根据实际情况进行修改。
1
vi /root/.m2/settings.xml
根据处理建议,新增如下内容:
- 删除本地已下载的软件。
1
mvn dependency:purge-local-repository -DreResolve=false -DmanualInclude=org.xerial.snappy:snappy-java:1.0.5 -f POM文件路径
在Windows环境下,请在CMD命令行中运行mvn命令。
- 修改setting.xml文件,文件路径请根据实际情况进行修改。
- 重新扫描。
1
devkit sys-mig -c mvn_analyse -d /home/maven_analyse/mvn_analyse_test_plugin/ -o /home/report
返回信息如下:
[2025-02-25 09:57:42,436] [INFO] Start to execute the command: ./devkit sys-mig -cf /root/DevKit-Sys-Mig-CLI-x.x.x-Linux-Kunpeng/sys-mig/resources/sysmig_default.conf -d /home/maven_analyse/mvn_analyse_test_plugin -o /home/report -l 1 [2025-02-25 09:57:42,437] [INFO] Creating file indexing... [2025-02-25 09:57:42,437] [INFO] Parsing... [2025-02-25 09:57:42,437] [INFO] Start Scanning maven information. [2025-02-25 09:57:42,628] [INFO] The Maven version passes the check: 3.8.8 [2025-02-25 09:57:43,759] [INFO] Using local repository at: /root/.m2/repository [2025-02-25 09:57:43,760] [INFO] Start to install mvn_analyse plugin, please ensure that the mirror and proxy settings in the settings.xml file are correct, and verify that remote repositories (such as Central Repository and Private Repositories) are accessible. Installing... [2025-02-25 09:57:43,760] [INFO] Some steps may require downloads and can be time-consuming. You can open a new terminal and use `tail -f /home/report/sys-mig_xx.xx.xx.xx_20250225095742/analyse_result_dir/stdout.txt` to view the temporary logs of the mvn_analyse plugin execution. [2025-02-25 09:57:45,232] [INFO] Install mvn_analyse plugin success [2025-02-25 09:57:45,233] [INFO] Start to analyse maven dependencies in /home/maven_analyse/mvn_analyse_test_plugin, please ensure that the mirror and proxy settings in the settings.xml file are correct, and verify that remote repositories (such as Central Repository and Private Repositories) are accessible. Analysing... [2025-02-25 09:57:45,233] [INFO] Some steps may require downloads and can be time-consuming. You can open a new terminal and use `tail -f /home/report/sys-mig_xx.xx.xx.xx_20250225095742/analyse_result_dir/plugin_stdout.txt` to view the temporary logs of the mvn_analyse plugin execution. [2025-02-25 09:57:50,343] [INFO] Execute plugin success in project directory /home/maven_analyse/mvn_analyse_test_plugin Html report is created successfully. The file is located in /home/report/sys-mig_xx.xx.xx.xx_20250225095742/mvn_analyse.html
- 查看评估报告,结果显示已无需要修改或替换的依赖。图2 评估报告2