Red Hat Training

A Red Hat training course is available for Red Hat Application Migration Toolkit

Chapter 5. Add Custom Rules

By default, the Eclipse plugin comes with a core set of system rules for identifying migration and modernization issues. You can browse the existing rules from the Eclipse plugin.

You can also create your own rules for identifying issues specific to your applications. You can either import an existing custom ruleset or create a custom ruleset directly in the Eclipse plugin.

5.1. Browse Rules

You can view both system and custom rules from the Eclipse plugin.

  1. From the RHAMT perspective, open the Rulesets tab.
  2. Expand the System item to view core system rules, or expand the Custom item to view custom rules.

    Note

    In order to view system rules, the RHAMT server must be started.

  3. Expand the ruleset containing the rule you want to review.
  4. Double-click the rule to open the rule in a viewer. You can select the Source tab to view the XML source of the rule.

5.2. Import a Custom Ruleset

You can import an existing custom ruleset into the Eclipse plugin to use during analysis of your projects.

  1. From the RHAMT perspective, open the Rulesets tab.
  2. Click the import ruleset icon ( Import ruleset icon ).
  3. Browse to and select the XML rule file to import.

    Note

    The XML rule file must use the .windup.xml or .rhamt.xml extension in order to be recognized as an RHAMT rule.

  4. The custom ruleset is now shown under the Custom item in the Rulesets tab.

This custom ruleset can now be selected in run configurations when analyzing projects.

See the Rules Development Guide to learn more about creating custom XML rules.

5.3. Create a Custom Ruleset

You can create a new custom ruleset in the Eclipse plugin to use during analysis of your projects.

  1. From the RHAMT perspective, open the Rulesets tab.
  2. Click the create ruleset icon ( Create ruleset icon ).
  3. Select the project and directory to save the new ruleset in.
  4. Enter the file name for the ruleset file.

    Note

    The XML rule file must use the .windup.xml or .rhamt.xml extension in order to be recognized as an RHAMT rule.

  5. Enter a ruleset ID, for example, my-ruleset-id.
  6. Optionally, check the Generate quickstart template checkbox to add basic rule templates to the ruleset file.
  7. Select Finish.
  8. The new ruleset file opens in an editor and you can add and edit rules in the file. You can also select the Source tab to edit the XML source for the ruleset file.

This new ruleset can now be selected in run configurations when analyzing projects.

See the Rules Development Guide to learn more about creating custom XML rules.

5.4. Submit a Custom Ruleset

Once a custom ruleset has been created it can be submitted for inclusion within the official RHAMT rule repository. This allows your custom rules to be reviewed and included in subsequent releases of RHAMT, enhancing the applications and server configurations that RHAMT analyzes.

  1. From the RHAMT perspective, open the Rulesets tab.
  2. Click the dropdown icon ( Dropdown ).
  3. Click Submit Ruleset from the options that appear. This will launch a new page in your browser.
  4. On the page that appears complete the following fields.

    1. In the Summary field, enter in the purpose of the rule. This becomes the title of the submission.
    2. In the Code Sample text field, enter an example of source code that the rule should run against.
    3. Click Choose Files and navigate to the saved rule to attach it.
    4. In the Description text field, enter in a brief description of the rule.
  5. Once all information has been entered, click Submit to complete the submission.