-
Notifications
You must be signed in to change notification settings - Fork 599
Building Open Liberty with Eclipse
- Overview Open Liberty Development
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.
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.
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
-
Ensure you turn off build automatically in Eclipse (click Project and ensure that Build Automatically is not checked).
-
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).
-
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)")
-
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)
-
Select File -> Import...
-
In the window that pops up, search for or find Existing Projects into Workspace. Select it and click Next >.
-
Under the Options section, ensure that Search for nested projects and Copy projects into workspace are not checked.
-
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.
-
Click Finish
This should not take more than a few minutes to complete.
B. Import projects via eGit
-
Next open the Git Repository viewer(Window -> Show View -> Other -> Git Repositories).
-
Select Add an existing local Git Repository in the Git Repository window.
-
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.
-
Check the box by your repository, and click Finish.
-
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).
-
In the Git Repositories window, right click your repository, and select Import Projects.
-
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.
-
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.
-
-
At this point, you should have all the projects into your Eclipse work space.
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.
- Overview Open Liberty Development