### Install MigrationBench Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Clones the MigrationBench repository and installs its Python dependencies in editable mode. This is the setup step for both Docker and local evaluation modes. ```bash git clone https://github.com/amazon-science/MigrationBench.git cd MigrationBench pip install -r requirements.txt -e . ``` -------------------------------- ### Install Hugging Face Datasets Source: https://github.com/amazon-science/migrationbench/blob/main/docs/datasets.md Installs the Hugging Face Datasets library, required to load MigrationBench datasets. ```bash pip install datasets ``` -------------------------------- ### Verify Docker installation Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Verifies that Docker is installed and accessible from the command line. Run this after installing Docker to confirm the installation. ```bash docker --version ``` -------------------------------- ### Install Java 17 Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Installs OpenJDK 17 on Debian/Ubuntu systems using apt. Verifies the installation with java --version. ```bash # Install OpenJDK 17 sudo apt update sudo apt install -y openjdk-17-jdk # Verify installation java --version ``` -------------------------------- ### Build and run qct-ast-parser with Maven and java -jar Source: https://github.com/amazon-science/migrationbench/blob/main/src/migration_bench/lang/java/native/README.md Builds the Java 17 native module with Maven, then runs the packaged qct-ast-parser JAR against a Java source file to export an AST XML. Requires Maven installed; the build command is `mvn clean install` and the run command passes -input_files and -export_path arguments. ```bash cd .../java/native # Make sure maven is installed # mvn --verison # Should give you a valid version mvn clean install FILENAME=src/main/java/qct/AstParser.java FILENAME=src/main/java/qct/XmlBeautifier.java FILENAME=/home/sliuxl/xmpp-light/src/main/java/ua/tumakha/yuriy/xmpp/light/web/IndexController.java java -jar target/qct-ast-parser-1.0-jar-with-dependencies.jar -input_files $FILENAME -export_path /tmp/test.xml # cat /tmp/test.xml ### To update ../tesdata/ast_parser.xml ### ./cmd.sh ``` -------------------------------- ### Install Maven 3.9.6 Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Downloads and installs Maven 3.9.6 from the Apache archive. Creates symlinks for MAVEN_HOME and the mvn command, then verifies with mvn --version. ```bash # Download and install Maven curl -O https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.zip unzip apache-maven-3.9.6-bin.zip sudo mv apache-maven-3.9.6 /opt/ # Create symlinks sudo ln -s /opt/apache-maven-3.9.6 /opt/maven # for MAVEN_HOME sudo ln -s /opt/apache-maven-3.9.6/bin/mvn /usr/local/bin/mvn # so mvn works without PATH setup # Clean up rm apache-maven-3.9.6-bin.zip # Verify installation mvn --version ``` -------------------------------- ### Verify Java and Maven installations Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Verifies that Java 17 and Maven 3.9.6 are installed and accessible. The expected output is version 17 for Java and 3.9.6 for Maven. ```bash java -version # Should show version 17 mvn -version # Should show version 3.9.6 ``` -------------------------------- ### Run single repository evaluation locally Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Runs a single repository evaluation in local mode. Requires Java 17 and Maven 3.9.6 installed locally. Set GITHUB_URL and GIT_DIFF_FILE to the repository URL and diff file path. ```bash GITHUB_URL=https://github.com/0xShamil/java-xid GIT_DIFF_FILE=/path/to/java-xid.diff python run_eval.py --github_url $GITHUB_URL --git_diff_filename $GIT_DIFF_FILE ``` -------------------------------- ### Run batch evaluation locally Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Runs batch evaluations in local mode. The first command processes sequentially; the second uses 8 parallel workers. Requires Java 17 and Maven 3.9.6 installed locally. ```bash PREDICTIONS=predictions.json # Sequential processing python run_eval.py --predictions_filename $PREDICTIONS # Parallel processing (8 workers) python run_eval.py --predictions_filename $PREDICTIONS --max_workers 8 ``` -------------------------------- ### Predictions JSON with migrated_root_dir Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Example predictions.json entry using the migrated_root_dir field to specify the absolute path to the migrated repository directory. ```json [ { "github_url": "https://github.com/0xShamil/java-xid", "migrated_root_dir": "/absolute/path/to/migrated/java-xid" }, ] ``` -------------------------------- ### Predictions JSON with git_diff Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Example predictions.json entry using the git_diff field to provide the git diff content as a string, which can be empty for no changes. ```json [ { "github_url": "https://github.com/0xShamil/java-xid", "git_diff": "diff --git a/pom.xml b/pom.xml\n--- a/pom.xml\n+++ b/pom.xml\n..." }, ] ``` -------------------------------- ### Predictions JSON with git_diff_file Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Example predictions.json entry using the git_diff_file field to specify a path to a file containing the git diff for a repository. ```json [ { "github_url": "https://github.com/0xShamil/java-xid", "git_diff_file": "/absolute/path/to/java-xid.diff" }, ] ``` -------------------------------- ### Load and iterate MigrationBench dataset Source: https://github.com/amazon-science/migrationbench/blob/main/docs/datasets.md Loads the MigrationBench-Selected dataset and iterates through its test split, printing each repository name. ```python from datasets import load_dataset # Load java-selected dataset dataset = load_dataset("AmazonScience/migration-bench-java-selected") # Iterate through repositories for item in dataset['test']: print(f"Repository: {item['repo']}") ``` -------------------------------- ### Evaluate migrated repository directory in Docker Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Evaluates a migrated repository directory in Docker mode. Use --migrated_root_dir to point to the directory containing the migrated code. ```bash MIGRATED_DIR=/path/to/migrated/repo python run_eval.py --github_url $GITHUB_URL --migrated_root_dir $MIGRATED_DIR --use_docker ``` -------------------------------- ### Run single repository evaluation in Docker Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Runs a single repository evaluation in Docker mode. Set GITHUB_URL and GIT_DIFF_FILE to the repository URL and the diff file path, then invoke run_eval.py with the --use_docker flag. ```bash GITHUB_URL=https://github.com/0xShamil/java-xid GIT_DIFF_FILE=/path/to/java-xid.diff python run_eval.py --github_url $GITHUB_URL --git_diff_filename $GIT_DIFF_FILE --use_docker ``` -------------------------------- ### Run batch evaluation in Docker Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Runs batch evaluations in Docker mode. Set PREDICTIONS to the path of the predictions file. File paths in the predictions file should be absolute paths on the host system; the Docker container mounts them as read-only volumes. ```bash PREDICTIONS=predictions.json # Run batch evaluation in Docker python run_eval.py --predictions_filename $PREDICTIONS --use_docker ``` -------------------------------- ### BibTeX citation for MigrationBench paper Source: https://github.com/amazon-science/migrationbench/blob/main/README.md BibTeX citation for the MigrationBench paper, to be used when citing the benchmark in academic work. ```bibtex @inproceedings{liu2026migrationbench, title={Migrationbench: Repository-level code migration benchmark from java 8}, author={Liu, Linbo and Liu, Xinle and Zhou, Qiang and Chen, Lin and Liu, Yihan and Nguyen, Hoan and Tehrani, Behrooz Omidvar and Shen, Xi and Huan, Jun and Tripp, Omer and others}, booktitle={Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 2}, pages={9427--9438}, year={2026} } ``` -------------------------------- ### Force rebuild Docker image Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Forces a rebuild of the Docker image before running the evaluation. Use this when you need to update the Docker image. ```bash python run_eval.py --github_url $GITHUB_URL --git_diff_filename $GIT_DIFF_FILE --use_docker --build_docker_image ``` -------------------------------- ### Run batch evaluation in Docker with parallel workers Source: https://github.com/amazon-science/migrationbench/blob/main/README.md Runs batch evaluation in Docker with parallel processing. The --max_workers flag specifies the number of Docker containers to run in parallel; 8 is recommended for large batches. ```bash # Run 8 Docker containers in parallel (each evaluates one repo) python run_eval.py --predictions_filename $PREDICTIONS --use_docker --max_workers 8 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.