我要评分
获取效率
正确性
完整性
易理解

Maven Project Source Code Porting Analysis Functions

Command Function

Analyzes the source code for migrating a Maven project using the terminal tool. You can run the mvn command to invoke the Maven plugin, which can parse the dependency compatibility in the POM file and generates an HTML report.

Only one command for Maven project analysis can be executed at a time on a server.

Syntax

  • Linux:
    1
    devkit sys-mig [-h | --help] [-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]
    
  • Windows:
    1
    sys-mig.exe [-h | --help] {-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]
    

Parameter Description

All parameters are optional.

Table 1 Parameter description

Parameter

Option

Description

-h/--help

-

Obtains help information.

-c/--command

stmt/sbom/mvn_analyse

Information collection mode.

  • stmt (default): collects the ledger information and generates a CSV report.
  • sbom: collects the component information and generates an HTML or JSON report.
  • mvn_analyse: analyzes the source code and generates an HTML report.

-cf/--config

-

Configuration file path. Parameters can be entered using a configuration file. The default configuration file template is ./sys-mig/resources/sysmig_default.conf. Configuration File Usage Example provides examples.

-d/--directory

-

File paths to be scanned. If you enter multiple paths, separate them with spaces.

Example: /home/test1 /home/test2

-o/--output

-

Report output directory, which defaults to the report directory where the sys-mig binary file is located.

Example: /home/report

-l/--log-level

0/1/2/3

Log level, which defaults to 1. This parameter is optional.
  • 0: DEBUG
  • 1: INFO
  • 2: WARNING
  • 3: ERROR

-v/--version

-

Displays the program version information. You do not need to set this parameter.

Environment Check

Before running commands, ensure that Maven 3.6.x or 3.8.x has been installed. If it is not installed or an incorrect version is installed, perform the following steps.

  1. Before installing Maven, ensure that the JDK has been installed.
    java -version

    If the JDK version information is displayed, the JDK has been installed. Otherwise, install the JDK first.

  2. Obtain the Maven installation package.
  3. Decompress the installation package. For example, download version 3.6.3 on Linux:
    1
    tar -zxvf apache-maven-3.6.3-bin.tar.gz
    
  4. Set the environment variables.
    1
    vi /etc/profile
    
    Add the following content. If Maven has been installed, change the environment variable to the latest path.
    1
    2
    export MAVEN_HOME=/path/to/apache-maven-3.6.3
    export PATH=$MAVEN_HOME/bin:$PATH
    

    MAVEN_HOME: directory generated after decompressing the Maven package. Replace the example directory with the actual one.

  5. Run the following command for the settings to take effect:
    1
    source /etc/profile
    
  6. Check whether the installation is successful.
    1
    mvn -v
    

    The installation is successful if the following information is displayed:

    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"
    

Example

  1. As an example, scan the project in the /home/maven_analyse/mvn_analyse_test_plugin/ directory and export the scan report to the /home/report directory.
    1
    devkit sys-mig -c mvn_analyse -d /home/maven_analyse/mvn_analyse_test_plugin -o /home/report
    

    Command output:

    [2025-07-21 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-07-21 09:52:21,104] [INFO] Creating file indexing...
    [2025-07-21 09:52:21,104] [INFO] Parsing...
    [2025-07-21 09:52:21,104] [INFO] Start scanning maven information.
    [2025-07-21 09:52:21,304] [INFO] The Maven version passes the check: 3.8.8
    [2025-07-21 09:52:22,481] [INFO] Using local repository at: /root/.m2/repository
    [2025-07-21 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-07-21 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-07-21 09:52:23,952] [INFO] Install mvn_analyse plugin success
    [2025-07-21 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-07-21 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-07-21 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
  2. View the assessment report. The report shows that there is one dependency that can be adapted for compatibility. Click Expand to view the complete handling suggestion.
    Figure 1 Assessment report (1)
    Table 2 Parameters for dependency file statistics

    Parameter

    Description

    Total Files

    Total number of compatible, adaptable for compatibility, and to-be-modified dependency files in the scan project. (If both direct and indirect dependencies are compatible, they are not displayed in the table.)

    Adaptable for Compatibility

    Download the file package from the Kunpeng image repository or Huawei Cloud and use it to replace the current files. For details, see the suggestions in the table.

    Unconfirmed

    Perform required operations to ensure compatibility with the target hardware platform. For details, see the suggestions in the table.

  3. Perform instructed operations based on the handling suggestion.
    1. Modify the settings.xml file. Replace the example path with the actual one.
      1
      vi /root/.m2/settings.xml
      

      Added the following content based on the handling suggestion:

    2. Delete the downloaded software.
      1
      mvn dependency:purge-local-repository -DreResolve=false -DmanualInclude=org.xerial.snappy:snappy-java:1.0.5 -f POM_file_path
      

      On Windows, run the mvn command in the CMD.

  4. Start a scan again.
    1
    devkit sys-mig -c mvn_analyse -d /home/maven_analyse/mvn_analyse_test_plugin/ -o /home/report
    

    Command output:

    [2025-07-21 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-07-21 09:57:42,437] [INFO] Creating file indexing...
    [2025-07-21 09:57:42,437] [INFO] Parsing...
    [2025-07-21 09:57:42,437] [INFO] Start scanning maven information.
    [2025-07-21 09:57:42,628] [INFO] The Maven version passes the check: 3.8.8
    [2025-07-21 09:57:43,759] [INFO] Using local repository at: /root/.m2/repository
    [2025-07-21 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-07-21 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-07-21 09:57:45,232] [INFO] Install mvn_analyse plugin success
    [2025-07-21 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-07-21 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-07-21 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
  5. View the assessment report. The result shows that no dependency needs to be modified or replaced.
    Figure 2 Assessment report (2)