-
Notifications
You must be signed in to change notification settings - Fork 0
Building Open Liberty
This assumes that you have already cloned an Open Liberty repository.
The directory containing your cloned repository (e.g. /home/gpicher/libertyGit/open-liberty as an example of a development repository, or /home/gpicher/libertyGit/open-liberty-service as an example of a service repository) will be referred to as <ol_clone_dir>.
Building Open Liberty in eclipse is optional (Steps 1 and 3). If you only want to build from the command line then only Step 2 is required.
- Step 1 : Optional - Import fork clone projects to Eclipse
- Step 2 : Run a Gradle build
- Step 3 : Optional - Run a project build all
The following steps can be completed to import the forked clone into 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 -> Team -> Git -> Projects and uncheck Automatically ignore derived resources by adding them to .gitignore).
-
Ensure you create an ant.home (all lower case) class path variable (click Window -> Preferences -> Java -> Build Path - > Classpath Variables). Click New, click Folder, and locate the org.apache.ant_ in your eclipse plugins directory (ex, D:\Eclipse\Eclipse4.6\eclipse\plugins\org.apache.ant_1.9.6.v201510161327).
Mac Users. Places to look:
/Applications/Eclipse.app/Contents/Eclipse/plugins/org.apache.ant_1.9.6.v201510161327
~/.p2/pool/plugins/org.apache.ant_1.9.6.v201510161327
Mac and Oxygen Users. You may need to use your locally installed Ant
For example: /Users//apache-ant-1.8.4
-
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
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 similar to what you have with the old RTC work space creation.
-
To run a gradle build do the following:
cd <ol_clone_dir>/dev
./gradlew cnf:initialize
You should only have to run this command on the initial setup of the repo./gradlew releaseNeeded
This task releases all projects to the local releaseRepo. The final openliberty zip can be found inopen-liberty\dev\cnf\release\dev\openliberty\<version>\openliberty-xxx.zip
Some common errors when running the command above:
Error JVMJ9VM015W Initialization error for library j9gc28(2): Failed to instantiate heap; 2G requested. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
Solution Open up the <ol_clone_dir>/dev/gradle.properties file and change the org.gradle.jvmargs=-Xmx2048M property to 1024MERROR Expiring Daemon because JVM Tenured space is exhausted
Solution did you edit the gradle.properties file to reduce -Xmx2048 to 1024M ? Why would you do that? Undo it.
To ensure all the Bnd Bundle paths resolve for bndtools inside of Eclipse for your open-liberty workspace, ensure you do a Project -> Build All.
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!