Rapid cloud-native development in the Eclipse IDE with Liberty dev mode
The Eclipse integrated development environment (IDE) is one of the most popular IDEs among Java developers. In this post, we showcase how Liberty dev mode and the Liberty Developer Tools Eclipse plugin ensure a seamless development experience for cloud-native Java developers.
Liberty dev mode enables you to quickly and iteratively develop cloud-native Java applications with the latest Jakarta EE and MicroProfile technologies. Dev mode watches your project for file changes and provides hot reload and deployment, on demand testing, and debugger support. You can work with dev mode from anywhere, whether it’s from a terminal with a text editor or your favorite IDE. Liberty Developer Tools is an Eclipse plugin that provides helpful server configuration editor views. In the following sections, we detail the current best practices for using dev mode, and optionally Liberty Developer Tools, to develop your application within the Eclipse IDE.
Check out a demo of working with Liberty dev mode in the Eclipse IDE:
Working with dev mode in the Eclipse IDE with Liberty Developer Tools
If you have Liberty Developer Tools installed in your Eclipse workspace, the server configuration editor views are helpful as you modify your server.xml
and other configuration files. You can easily add new server configuration elements and features to your server.xml
file.
However, dev mode handles a lot of the heavy lifting for developers who use the Liberty runtime. With dev mode, you no longer need to manage your Liberty runtime instances through the Servers view of Liberty Developer Tools. You can disable the Servers view from the Liberty Developer Tools Preferences menu. Disable Liberty Developer Tools' integration for Maven and Gradle projects:
-
For Maven projects: Window → Preferences → Maven → Liberty Integration drop-down to "No".
-
For Gradle projects: Window → Preferences → Gradle → Liberty Integration drop-down to "No".
Setting up the project
In order to use dev mode, your project must be configured to use either the Liberty Maven Plugin or Liberty Gradle Plugin. For Maven projects, specify the Liberty Maven Plugin in your project’s pom.xml
file:
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.5.1</version>
</plugin>
For Gradle projects, specify the Liberty Gradle Plugin in your project’s build.gradle
file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'io.openliberty.tools:liberty-gradle-plugin:3.3'
}
}
Starting dev mode
You can start dev mode through the Eclipse IDE terminal by finding your project in the package explorer and right-clicking Show in Terminal. Alternatively, you can start it from your operating system terminal with one of the following commands:
-
Maven:
mvn liberty:dev
-
Gradle:
gradle libertyDev
Running tests in dev mode
You can run tests on demand by pressing Enter in the terminal running dev mode.
Attaching a debugger
You can attach a debugger to the running server to step through your code at any time. In Eclipse, you can create a debug configuration by selecting Run → Debug Configurations… → Remote Java application. The default port for debugging is 7777
.
Stopping dev mode
You can quit dev mode at any time by pressing CTRL+C or type 'q' and press Enter in the terminal running dev mode.
Additional Resources
For more information on Liberty dev mode, refer to the documentation for the liberty:dev
goal of the Liberty Maven Plugin or the libertyDev
task of the Liberty Gradle Plugin.
If you prefer to develop with Visual Studio Code, check out Open Liberty Tools for VS Code. If you prefer to develop with IntelliJ, check out Open Liberty Tools for IntelliJ IDEA.
What’s next
Watch out for improved Liberty tooling for the Eclipse IDE in the near future. We would love to hear how we can make your experience developing with Liberty even better. If you have any feedback, issues or feature requests, do not hesitate to open a GitHub issue on the Liberty Maven Plugin or Liberty Gradle Plugin repository.