Chapter 5. Forge Tools basics in CodeReady Studio

CodeReady Studio offers Forge Tools for developing Java EE applications and to extend the IDE functionality in Eclipse.

The following section describes how to:

  • Launch the Forge Console.
  • Create a new Forge project.
  • Create a persistence.xml file.
  • Add a new field to the entity.
  • Generate a scaffold.
  • Manage addons.
  • Run Forge-based applications.
Important

Forge Tools are no longer fully supported by Red Hat.

5.1. Launching the Forge Console

The following section describes how to launch the Forge Console view.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Click Window:Show viewOther.

    The Show View window appears.

  4. Enter Forge Console in the search Field.
  5. Select Forge Console.
  6. Click the Open button.

The Forge Console view appears.

5.2. Creating a new Forge project

The following section describes how to create a new Forge project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Press Ctrl+4.

    The Current Selection window appears.

  4. Enter Project in the search field.
  5. Select Project: New.

    The Project: New window appears.

  6. Name your project. Note that the project name cannot include spaces or special characters. The only special characters allowed are periods (.), underscores (_), and dashes (-).
  7. Click the Browse button to select the project location.
  8. Click the down-arrow in the Stack field.
  9. Select Java EE 7.
  10. Click the Finish button.

Verification steps

  1. Click WindowShow ViewOther.

    The Show View window appears.

  2. Select Project Explorer.
  3. Click the Open button.

    The Project Explorer view appears.

Your newly created Forge project is now listed in the Project Explorer view.

5.3. Creating a persistence.xml file

The following section describes how to create a persistence.xml file for your Forge project in CodeReady Studio using JPA.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Press Ctrl+4.

    The Current Selection window appears.

  4. Enter JPA in the search field.
  5. Select JPA: New Entity.

    The JPA: Setup window appears.

    Not that the Forge Console automatically detects any prerequisites that must be set up and prompts you to create those at runtime.

  6. Click the Next button.

    The JPA: Connection Settings window appears.

    Ensure that the automatically generated values are correct.

  7. Click the Next button.

    The JPA: New Entity window appears.

  8. Name your entity.

    Note that the entity name cannot include spaces or special characters. The only special character allowed is underscore (_).

  9. Click the Finish button.

Your newly created Forge entity is now displayed in the CodeReady Studio editor.

Verification steps

  1. Click WindowShow ViewOther.

    The Show View window appears.

  2. Select Project Explorer.
  3. Click the Open button.

    The Project Explorer view appears.

  4. Expand your Forge project.

Your newly created .java Forge entity and the corresponding persistence.xml file are now listed in the Project Explorer.

5.4. Adding a new field to the entity

The following section describes how to add a new field to the entity for your Forge project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Press Ctrl+4.

    The Current Selection window appears.

  4. Enter Field in the search field.
  5. Select JPA: New Field.

    The JPA: New Field window appears.

  6. Click the down-arrow in the Target Entity field.
  7. Select the entity for your project.
  8. Name your new field.
  9. Click the Finish button.

Your newly created field is now added to the .java file of your Forge project. The .java file is displayed in the CodeReady Studio editor.

5.5. Generating a scaffold

Scaffolding is an automatic code generation technique. A program generates a basic CRUD (create, read, update, delete) admin interface by using available information (usually a database).

The following section describes how to generate a scaffold for your Forge project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Press Ctrl+4.

    The Current Selection window appears.

  4. Enter Scaffold in the search field.
  5. Select Scaffold: Generate.

    The Scaffold: Generate window appears.

  6. Click the down-arrow in the Scaffold Type field.
  7. Select Angular JS.
  8. Click the Next button.

    The Setup Facets window appears.

  9. Ensure that the automatically generated values are correct.
  10. Click the Next button.

    The Select JPA entities window appears.

  11. Select the JPA entities for scaffolding.
  12. Click the Finish button.

Your newly generated entries are now displayed in the CodeReady Studio editor.

5.6. Addon management

The following section describes how to:

  • Create a new addon.
  • Add a custom Forge command to the addon.
  • Installing a custom Forge command.
  • Executing a custom Forge command.

5.6.1. Creating addons

The following section describes how to create addons for your Forge project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Press Ctrl+4.

    The Current Selection window appears.

  4. Enter Project in the search field.
  5. Select Project: New.

    The Project: New window appears.

  6. Name your addon. Note that the name of the addon cannot include spaces or special characters. The only special characters allowed are periods (.), underscores (_), and dashes (-).
  7. Click the Browse button to select the project location.
  8. Click the down-arrow in the Project Type field.
  9. Select Forge Addon (JAR).
  10. Click the Next button.

    The Furnace Addon Setup window appears.

  11. Ensure that the automatically selected dependencies are correct.
  12. Click the Finish button.

    Note that the process of setting up the dependencies might take some time to complete.

Your newly created addon is now displayed in the CodeReady Studio editor.

Verification steps

  1. Click WindowShow ViewOther.

    The Show View window appears.

  2. Select Project Explorer.
  3. Click the Open button.

    The Project Explorer view appears.

  4. Expand your Forge project.

Your newly created addon is now listed in the Project Explorer.

5.6.2. Adding a custom Forge commands to the addon

The following section describes how to create a simple Java class and turn it into a Forge command in CodeReady Studio.

Prerequisites

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Press Ctrl+4.

    The Current Selection window appears.

  4. Enter New Class in the search field.
  5. Select Java: New Class.

    The Create a new Java Class window appears.

  6. Name your new class. Note that the class name cannot include spaces or special characters. The only special character allowed is underscore (_).
  7. Click the Finish button.
  8. Press Ctrl+4.

    The Current Selection window appears.

  9. Enter UI in the search field.
  10. Select Addon: New Annotated UI Command.

    The Addon: New Annotated UI Command window appears.

  11. Enter the Command name.
  12. Click the Finish button.

Your custom Forge command is now created.

5.6.3. Installing a custom Forge command

The following section describes how to install a custom Forge command into Eclipse IDE using CodeReady Studio.

Procedure

  1. Open the Project Explorer view.
  2. Press Ctrl+4.

    The Current Selection window appears.

  3. Enter Build in the search field.
  4. Select Build and Install an Addon.

    The Build and Install an Addon window appears.

  5. Ensure that the path to your addon is correct.
  6. Click the Finish button.

Your custom command is now installed into Eclipse IDE.

5.6.4. Executing a custom Forge command

The following section describes how to execute a custom Forge command in CodeReady Studio.

Procedure

  1. Press Ctrl+4.

    The Current Selection window appears.

  2. Enter the name of your command in the search field.
  3. Select your command.

5.7. Running Forge-based application

The following section describes how to run a Forge-based application in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Click WindowShow ViewOther.

    The Show View window appears.

  4. Select Project Explorer.
  5. Click the Open button.

    The Project Explorer view appears.

  6. Right-click your Forge projectRuns asRun on Server.

    The Run On Server window appears.

  7. Select the server to use.

    For example Red Hat JBoss Enterprise Application Platform 7.0.

  8. Click the Finish button.

    The Console view appears.

Your Forge-based application opens in the CodeReady Studio browser.