...
Eclipse is a popular IDE that is used by many committers to develop Java code. Eclipse project files and Buildship files (.project
, .classpath
, and files in the .classpathsettings
folder) and have been created and checked into the repository. You should use the latest Eclipse version, or at least a version that supports JDK N-1 (for OpenJFX N) after patching (see below on patching).
...
You can either use Gradle from the command line or through through Buildship, which integrates Gradle into Eclipse (see below for more info on Buildship).
Import the Eclipse Projects
You can either import the projects as Java projects and then run Gradle manually from a command line, or import them directly as Gradle projects with Buildship and use Gradle from within Eclipse. If you import as Java projects, you can later also import them as Gradle projects to add Buildship's functionality to them.
Importing as Java-only projects
...
- Go to
File -> → Import -> → General -> → Existing Projects into Workspace.
- Set the root directory to the base repository path (named "jfx" be default).
- Check
Search for nested projects.
- It's recommended to import all the projects, however, you can select only the ones you know that you will need.
- Click
Finish
Importing as Gradle+Java projects
Organizing the Workspace
OpenJFX contains a large number of projects, which can make it difficult to work with as most of them will not be used regularly. Eclipse's Project Explorer
view will show the projects' hierarchy:
You can use this view to collapse the non-relevant projects. If you prefer to use the Package Explorer
view, you can use Working set
s to only show those you are interested in. For example, you can create a working set for the projects under "apps", another for those under "modules", and another for those under "tests".
You can also close projects, which can reduce some visual clutter and will save time when building, but you will have to make sure that there are no errors on any project before integrating a PR. If you know that some projects can't be affected by the area you work on, you can close them.
Using Buildship
Buildship is an optional plugin that integrates Gradle into Eclipse, allowing you to forgo the command line. If you choose to use Buildship, use the latest Use the latest Buildship version, as the Gradle version used in OpenJFX updates from time to time and Buildship needs to support that Gradle version. As mentioned above, the Buildship files that are required for the projects' configuration are included in the repository.
The . The Gradle Tasks view will list all the tasks that are configured in OpenJFX.
Not all Java projects are also Gradle projects. The project structure for Gradle is such that the root directory contains the parent project (called jfx
, or previously rt
) with all other projects being its children.root project ("jfx") is a Gradle project that configures some other child non-Gradle project (like the "base" project under "modules"). Some projects (like those under "tests/manual") are neither Gradle projects themselves, nor are they configured by the root project. There are 3 projects under "apps/samples" that are Gradle project themselves, but they do not function as such currently.
NOTE: Refreshing a Gradle project through Right Click → Gradle → Refresh Gradle Project
NOTE: this process will override the projects' Eclipse configuration files that come with the repository, and will cause them to not work anymore. This is because Gradle/Buildship does not know yet how to create the correct configuration files by itself. HoweverIf you refresh a project by mistake, since we are using a git repository, we can revert the breaking changes. This will allow us to work with both Eclipse and Gradle/Buildship.
- Install Buildship.
- Go to
File -> Import -> Gradle -> Existing Gradle Projects.
- Set the root directory to the base repository path.
- If your workspace setting is to use the wrapper by default, there is no need to override the settings. Otherwise specify
Gradle wrapper
. Finish and wait for the workspace to rebuild. This will result in many compilation errors as described in the note above.
Revert all .classpath files (and clean and rebuild if it does not happen automatically - this will some take time). There should be no compilation errors.
What this process does is add the Gradle nature and build command to the .project files. This means that these files are now different than the ones in the repo. Additionally, the .settings folder for each project will contain a Buildship pref file. You will need to resolve the conflicts with the upstream repo.is also the reason for not importing the projects as Gradle projects. It is safe to refresh tasks in the Gradle Tasks
view.
Using EGit (TODO this section)
...
Configure Eclipse to use the latest JDK
- Go to
Window -> → Preferences -> → Java -> → Installed JREs
andAdd -> → Standard VM
and point to the latest version. If you want to find a regression or backport, you can switch to earlier versions underInstalled JREs
(will require rebuilding). You might see a warning that Eclipse does not support this Java version, this should not cause issues. - Go to
Window -> → Preferences -> Java -> Compiler→ Java → Compiler
and set the compiler compliance level to the latest. You might not have an option for an unreleased version of Java. For example, if compliance level 11 is not available, install the patch from the update site: http://download.eclipse.org/eclipse/updates/4.9-P-builds/. Similarly, for Java 13 use: https://download.eclipse.org/eclipse/updates/4.13-P-builds.
...
Building the workspace can take some time. However, thanks to Eclipse's incremental compiler, you do not need to rebuild all of it on every change.
Running Applications and JUnit tests
Eclipse can run the applications in the repository (under "apps" and "tests") regardless of Gradle. You will need to add the following VM arguments to the launch configuration:
-Djava.library.path="<path to repo>\modules\javafx.graphics\build\module-lib"
--add-modules=javafx.controls
(or other modules that are required, like "fxml").
JUnit tests can also be run as an alternative to the Gradle tasks. Right click on the resource you want to test (project/package/class) and select Run as -> → JUnit Test
. You might need to add the following VM arguments:
-Djava.library.path="<path to repo>/build/sdk/lib\modules\javafx.graphics\build\module-lib"
-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit
When running test.javafx.scene.web.WebViewT
est
, instead of the -Djavafx.toolkit
argument, useuse instead:
-Djava.library.path=<path to repo>/modules/javafx.graphics/build/module-lib:<path to repo>/modules/javafx.web/build/module-lib
Using working sets
Working sets allow you to group projects. The projects in OpenJFX contain its modules projects, like base and graphics, but also the apps and test projects. If you do not use these, you can create working sets for them and hide them.
Running a dependent project
...
In the project properties, go to Java Build Path -> → Modulepath
and add the required projects.
If when running you receive warnings about missing packages or modules, edit the run configuration by going to its Dependencies -> → Override Dependencies
, then delete the launch dependencies and Override
.
...
Then add -Djava.library.path="<path to repo>\rt\modules\javafx.graphics\build\module-lib"
to the VM arguments in the launch configuration.
Run Sample Code (NOTE: old)
Run Sample Code with Gradle Built Shared Libraries (Note: old)
//TODO - explain how to hook up the shared libraries in the run dialog
//TODO - these are the VM Arguments: -Djava.library.path=${workspace_loc:rt}/build/mac-sdk/rt/lib