Skip to content

Building Open Liberty with Eclipse

Mark Swatosh edited this page Aug 30, 2023 · 16 revisions

Prerequisite software

Eclipse IDE

Install Eclipse IDE using the eclipse installer.

  • Download the Eclipse IDE from the eclipse website. The main download is actually an installer.
  • Extract and run the installer Note: these instructions are for the default "simple mode"
    • Select "Eclipse IDE for Java Developers"
    • For the Product Version, select "Latest Release (xxxx-xx)"
    • Check that the installer has found a valid Java 17 VM
      • If it hasn't, click the button to the right of the drop down and add the Java install that you installed earlier.
    • Change the installation folder if you want to
    • Click Install
    • During the install you may be asked to accept unsigned content. Do accept it.
  • Launch Eclipse
    • When eclipse starts, it will ask for a "workspace directory". You can select any empty directory and it must be a different directory from where you cloned the Open Liberty code.

BND Tools

Install the BND Tools plugin into eclipse, (either go to Help -> Eclipse Marketplace... and search or drag and drop from the marketplace page)

This may ask you to accept untrusted or unsigned code. Do so.


Building Open Liberty in Eclipse

Step 1: Check Eclipse's memory allocation

The Open Liberty codebase is fairly large and Eclipse struggles with it a bit, but it works better if we allow it to use more RAM. Java 8+ by default will set -Xmx to 1/4 of physical memory, so for a system with 16GB or more memory this step is unnecessary.

  • Go to your eclipse install directory and open eclipse.ini in a text editor
  • Look for the line that starts -Xmx, (it'll be something like -Xmx2048m)
  • Make sure it's at least 2048m, if you have plenty of RAM, set it to -Xmx4096m
  • If you changed the file, restart Eclipse

Step 2 : Import cloned projects to Eclipse

  1. Ensure you turn off build automatically in Eclipse (click Project and ensure that Build Automatically is not checked).

  2. Ensure you turn off the auto ignore derived resources (click Window -> Preferences -> Version Control (Team) -> Git -> Projects and uncheck Automatically ignore derived resources by adding them to .gitignore).

  3. If you're on Windows, ensure you disable content assist proposals for user defined Ant tasks (click Window -> Preferences -> Ant -> Editor -> Content Assist and uncheck "Provide proposals for user defined tasks (may lock referenced JAR files)")

  4. Import the projects into Eclipse

    There are two options for importing the projects into Eclipse. Either use the built-in Eclipse function to import the existing projects, or use eGit to add the repository and add the projects via the repository.

    Importing using pure Eclipse has the benefit of typically being quicker since it doesn't have the overhead of using eGit. Doing so also means you have no reliance on eGit and can remove it from your Eclipse instance. However if you're unfamiliar with Git or simply prefer to use eGit capabilities, you'll need to import the projects via eGit.

    A. Import projects via Eclipse (recommended)

    1. Select File -> Import...

    2. In the window that pops up, search for or find Existing Projects into Workspace. Select it and click Next >.

    3. Under the Options section, ensure that Search for nested projects and Copy projects into workspace are not checked.

    4. In the Select root directory: input, input the path to the <ol_clone_dir>/dev directory.

      Eclipse will navigate through the directory to find all of the necessary projects. This might take a couple seconds, but no more than 30 or so.

    5. Click Finish

      This should not take more than a few minutes to complete.

    B. Import projects via eGit

    1. Next open the Git Repository viewer(Window -> Show View -> Other -> Git Repositories).

    2. Select Add an existing local Git Repository in the Git Repository window.

    3. In the Add Git Repositories dialog box, navigate to <ol_clone_dir> (via Browse/Search) and select it. It is where the <repository_name>.git file is located for the repository on your local file system.

    4. Check the box by your repository, and click Finish.

    5. Ensure that you modify the CRLF properties to use input. This can be done via the command line in Git bash:

      git config --global core.autocrlf input

      or via Eclipse by Windows -> Preferences -> Team -> Git -> Configuration. Under the Repository Settings tab highlight the core key, and click Add Entry. Enter core.autocrlf as the key, and for the value enter input.

      More information regarding CRLF can be found at the Dealing with line endings topic on GitHub Help (though note we make a different suggestion than to use true on Windows, since you may be working with a Windows Git repository but working on other systems like EZWAS).

    6. In the Git Repositories window, right click your repository, and select Import Projects.

    7. Ensure the Import existing Eclipse projects is selected (default), and ensure that you've select the correct working tree with your local repository. Click Next.

    8. After a few seconds you'll see a list of all the projects. Uncheck the 'Search for nested projects' option, then click the Finish button to import all the projects. NOTE: The import can take a ~5-10 minutes to complete depending on your system hardware.

  5. At this point, you should have all the projects into your Eclipse work space.


Step 3: Re-enable Build Automatically

To ensure all the Bnd Bundle paths resolve for bndtools inside of Eclipse for your Open Liberty workspace, you need to re-enable build automatically. Eclipse will then start building all of the projects that it can, which will then satisfy the dependencies of other projects and then it will build those.

This step can take 30-60 minutes for a new workspace. You should see Eclipse reporting progress in the bottom right corner, or in the Progress view.,

IMPORTANT The this step of building the code within Eclipse is just for development time purposes to get errors out of your workspace. You must run builds from the command line tools for things to get generated properly! In particular, the command line build will create the full liberty install which is used to run FAT tests. You must have run a full ./gradlew assemble on the workspace before running FATs.

In theory, your workspace should now have no errors in it. In practise you may find that some persist. If they're not in projects you need to work on, you can safely ignore them.


Clone this wiki locally