Running a transformation on the command line with Amazon Q Developer
Complete these steps to transform your code on the command line with the Amazon Q Developer command line tool.
Prerequisites
Before you begin a transformation, see the prerequisites for upgrading Java versions with Amazon Q.
In addition, the following prerequisites must be met:
-
You are subscribed to Amazon Q Developer Pro and have a Start URL to access your subscription. You or your administrator can find the Start URL in the Amazon Q Developer console. For more information see, Managing account details.
-
You have Python installed on your command line environment. This is how you will install the command line tool. The minimum supported Python version is 3.12.
-
You are running the transformation on macOS or Linux.
-
The size of your application is 2 GB or smaller.
-
If you are performing custom transformations, you have installed the ast-grep tool. To install and set up ast-grep, see https://ast-grep.github.io/guide/quick-start.html#installation
Step 1: Install the tool
-
Download the Amazon Q command line tool for transformations
. -
We recommend that you set up a virtual environment in Python to install the tool. To create a virtual environment, open a terminal window and run:
python -m venv qct-cli
-
To activate the virtual environment, run:
source qct-cli/bin/activate
-
To install the tool on your command line, run:
pip install amzn_qct_cli-0.1.0-py3-none-any.whl
-
To verify that the tool was installed, run:
which qct
Step 2: Configure and authenticate
Before you can begin a transformation, you must provide configuration details and authenticate to your Amazon Q Developer Pro subscription with IAM Identity Center.
-
To start the configuration process, run the following command:
qct configure
-
First, your Maven version is verified. If you have at least the minimum supported version, you will see the following output:
Running command: mvn --version at: path/to/current/directory Your Maven version is supported for transformations.
If you don’t have a supported version of Maven, you must update it to continue. For more information, see the Prerequisites.
-
You are then be prompted to enter a JDK path for Java 8, 11, and 17. You only need to specify the path to the JDK of the Java version you are upgrading.
-
Next, you are prompted to provide the Start URL to authenticate to Amazon Q Developer Pro through OpenID Connect identity provider. For more information, see the Prerequisites.
-
Your configuration preferences are saved to a configuration.ini file.
Step 3: Run a transformation
To transform your code, you provide the source code file, and optionally a customization file. For information on customizations and creating custom transformation files, see Customizing transformations.
-
Run the following command to start a transformation. Replace
<path-to-folder>
with the path to the folder with the code you're transforming.qct transform --source_folder
<path-to-folder>
-
Amazon Q begins the transformation. It will output status updates throughout the transformation. When it’s complete, Amazon Q provides the path where the transformation results, logs, and configuration files are outputted.