In this post, we introduce a technology preview for automatically generating a list of features as part of your project’s Open Liberty server configuration. When you run Open liberty in dev mode, features are now automatically generated in your server configuration as you develop your cloud-native Java application.
Dev mode monitors the class files in your application and detects when they use new Open Liberty feature APIs. If dev mode detects features that are not already specified in your server configuration, a new
generated-features.xml file is created in your
configDropins/overrides directory. This function simplifies your developer workflow because you no longer need to manually specify these features. We recommend that you commit this new
generated-features.xml file to your version control.
User-specified features always take precedence over automatically generated features. Automatically generated features will not replace or conflict with features that you have already manually specified in your
Dev mode with automatic generation of features
For Maven projects, specify the Liberty Maven Plugin with version
3.6 and its Sonatype repository in your
For Gradle projects, specify the Liberty Gradle Plugin with version
3.4 and its Sonatype repository in your
apply plugin: 'liberty'
Start dev mode by running the following Maven goal or Gradle task. Automatic feature generation is enabled by default in the previously mentioned Maven and Gradle snapshot releases for this technology preview.
As you make code changes to your application, dev mode monitors API use in your class files and automatically generates and installs new Open Liberty features as needed.
The feature list is generated in a new
configDropins/overrides/generated-features.xml file in your project server configuration directory.
<?xml version="1.0" encoding="UTF-8"?>
<!--This file was generated by the Liberty Maven Plugin and will be overwritten on subsequent runs of the liberty:generate-features goal.
It is recommended that you do not edit this file and that you commit this file to your version control.-->
<!--The following features were generated based on API usage detected in your application-->
As you make changes to your application, dev mode scans for API use only in class files that you have just modified. However, you might run into a scenario where a feature has been generated that is no longer used in any of your classes. You can have dev mode re-scan all class files in your application and generate an optimized list of features by typing 'o' and pressing Enter in the dev mode terminal.
Disabling automatic generation of features in dev mode
To disable automatic feature generation, you can set the
generateFeatures parameter to false by running the following Maven goal or Gradle task.
mvn liberty:dev -DgenerateFeatures=false
gradle libertyDev --generateFeatures=false
You can toggle automatic feature generation on and off by typing 'g' and pressing Enter in the dev mode terminal.
Dev mode help menu
This latest snapshot release also includes a new help menu view in dev mode. By typing 'h' and pressing Enter in the dev mode terminal, you can see a list of hotkeys and actions that you can perform in dev mode.
Automatically generating features outside of dev mode
To generate a server configuration feature list for your application outside of dev mode, compile your project and run the new generate features stand-alone goal or task. You must run the "installFeatures" goal or task afterwards to install the features that are generated.
mvn compile liberty:generate-features
mvn compileJava generateFeatures
To try out automatic generation of features on a demo project, see the generate-features branch of the demo-devmode project.
We welcome your feedback on this technology preview. You can post in the Open Liberty developer experience channel on Gitter or open issues directly in the Liberty Maven Plugin or Liberty Gradle Plugin GitHub repositories.
See the technology preview in action
Please join us for a WebSphere & Liberty Customer Advisory Board (CAB) session Thursday, February 10th where the development team will demonstrate the new capabilities of this technology preview, answer your questions, and listen to your feedback. If you are interested in this CAB session, or any future CAB sessions, it is best to join the WebSphere & Liberty CAB to ensure that you receive reminders for sessions you are interested in plus an email with the session recording and charts.