We’ve made significant updates to the 220.127.116.11 version of WDT for use with the v2.0 Liberty Maven plugin to improve your experience when working with Liberty servers managed by Maven WAR projects. When your Maven web application project installs a Liberty server, the Eclipse tools can automatically recognize and add the server and runtime to the workbench for easier server interactions.
Trying it out
- Clone the Git repository containing a sample Liberty Maven WAR project available at https://github.com/WASdev/sample.ferret.git to your local filesystem.
- Use the File > Import > Maven > Existing Maven Projects option to import the project.
When you import or open a Liberty Maven WAR project in WDT, or if you update a Maven project in WDT to use
liberty-maven-plugin v2.0 or later (edit the
pom.xml then click Maven > Update project…), WDT displays the following prompt:
This prompt indicates that WDT recognizes your project as a Maven WAR project and prompts you to decide whether to let it add the server and runtime to your Eclipse workspace.
After selecting Yes, you can have all aspects of your application development at your fingertips:
There’s a lot going on here. The workbench is configurable but mine shows:
- The sample project and the Liberty runtime installed in the target folder of the project.
- The project POM using the latest Liberty Maven plugin (liberty-maven-plugin).
- Easy interaction with Git.
- The Servers view where WDT automatically added this server. I started the server from this view. It also shows the Liberty server’s configuration files and distinguishes between the files in the
- The Runtime Explorer view with the Liberty runtime added.
- The console showing the running server and application.
No prompt after import?
Some Eclipse configurations can run into problems connecting to the Maven Central Repository. If your project has Maven Problems in the Markers view that indicate problems transferring artifacts to/from repositories, you can resolve them by using Maven from the command line for actions that require communication with remote repositories:
- Right-click the project and go to Properties > Project Facets (click the link to convert to a faceted project if it appears) and make sure that Dynamic Web Module is selected.
mvn installon the command line from within the directory containing your project’s
- Rebuild your project in the Eclipse workbench using the Project > Clean… action
- Right-click the project within the workbench and click Refresh.
Running the Maven clean goal
If you run the Maven clean goal, WDT removes the server from view. As as soon as you build the project again, it’s back.
Using Maven clean on your project removes your project’s
target files, including the Liberty installation files so the server is removed. Running a Maven install reinstates the server automatically. Closing the Maven project also removes the server. Re-opening the project causes the prompt to appear again and you can select whether or not you want WDT to continue managing your server automatically.
Configuring your Liberty server
Use the Liberty Maven plugin configuration parameters to configure the Liberty server.
For the best development experience, use the Liberty Maven plugin (
liberty-maven-plugin) with the
looseApplication parameter set to
true. This tells the Liberty server to use the application resources from your workspace so that changes to your application are reflected almost instantaneously. The sample used in the screenshot above uses the
pom.xml, which enables the
looseApplication parameter by default. If
looseApplication is set to
false, the application needs to be repackaged so updates take longer to process.
looseApplication and other configuration parameters in the
liberty-maven-plugin configuration, which is located in the project’s
pom.xml file. After updating the
pom.xml file right-click the project, then click Maven > Update project to update the server and runtime instances within the Eclipse workbench.
You can further configure the Liberty server by modifying the server configuration file. Open the Servers view and double-click the Server Configuration node to open the Server Configuration editor. Make changes and save the file to automatically update the server.
Exploring other options with your Maven WAR project
Here are some common things that you can now do with your Maven WAR projects in WDT:
- Perform actions like Start, Stop, and Open Log Files on the generated server in the Servers view.
- Run your web application by right-clicking a resource in the Project Explorer view and selecting Run As > Run On Server.
- Debug your web application by setting a breakpoint in your code and using the Debug As > Debug On Server action.
- Update your application code or resource and see the server pick up the changes on-the-fly.
- Use the Servers view to see a clear representation of the server configuration files within your Maven project. The files listed under the
Maven Targetfolder are derived from your Maven project’s
targetfolder. These files are intended for read-only consumption. Use the files listed directly under the server that correspond to the files in your Maven project’s
srcfolder to update your server’s configuration. They are copied to the target.
- Make changes to your
liberty-maven-pluginconfiguration in your Maven project’s
pom.xmland use the Maven > Update project… menu option to update the server and runtime instances within the Eclipse workbench.
Give it a go!
You can iteratively develop and debug your web application within Eclipse and then build and package your application using Maven. The end result is a cohesive Maven development experience.