Skip to content

Latest commit

 

History

History
85 lines (64 loc) · 4.4 KB

2019-11-28-dev-mode-liberty-maven-plugin.adoc

File metadata and controls

85 lines (64 loc) · 4.4 KB
layout title categories author_picture author_github seo-title seo-description blog_description
post
Dev mode support in Liberty Maven Plug-in 3.1
blog
Dev mode support in Liberty Maven Plug-in 3.1 - OpenLiberty.io
Dev mode support and other enhancements made to the Liberty Maven plug-in in 3.1 to simplify and improve the developer experience.
Dev mode support and other enhancements made to the Liberty Maven plug-in in 3.1 to simplify and improve the developer experience.

Dev mode support in Liberty Maven Plug-in 3.1

Recently we focused on simplifying the use of the Liberty Maven plug-in and improving the developer experience for Open Liberty. This post describes the various enhancements and simplifications that are available in the 3.1 release of liberty-maven-plugin.

What’s new?

The biggest enhancement is the addition of a development mode, which provides, in any text editor or IDE, hot reload and deployment, on demand testing, and debugger support when you’re developing applications. You can read more about dev mode in the Open Liberty development mode blog post.

Other notable enhancements include:

  • The ability to specify Liberty configuration with Maven properties

  • The run goal now implicitly creates the server, installs features referenced by the server.xml, and deploys the application before starting the server in the foreground

For more details, check out the 3.1 release notes.

What changed?

In order to simplify the developer experience with the Liberty Maven Plug-in, we made the following changes:

  • Simplified the goal names

  • Simplified the server installation to install by default the latest Open Liberty kernel from Maven Central

  • Changed the precedence for the common server parameters and removed defaults for individual files

  • Combined the install-apps and deploy goal functionality into a single deploy goal

  • Changed the looseApplication default value to true

  • Modified the package goal to support packageName, packageDirectory, and packageType parameters with logical defaults

For more details, check out the 3.0 release notes.

Simplified pom.xml

With all of these changes, the pom.xml configuration for the liberty-maven-plugin can be greatly simplified. Here are a couple of examples (in versions 3.0 and above, the groupId of the plugin is io.openliberty.tools).

Example 1

---
<project>
    ...
    <build>
        <plugins>
            <!-- Enable liberty-maven-plugin -->
            <plugin>
                <groupId>io.openliberty.tools</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>3.1</version>
            </plugin>
        </plugins>
    </build>
    ...
</project>
---

With the pom.xml in Example 1, you can simply run mvn liberty:run for your project. As a result, liberty-maven-plugin installs the latest Open Liberty kernel from Maven Central, creates the server, installs features referenced by the server.xml (which can be placed in the default location for configDirectory which is src/main/liberty/config), deploy the application, and start the server in the foreground. No further configuration is required to get started!

Example 2

---
<properties>
    <liberty.jvm.minHeap>-Xms512m</liberty.jvm.minHeap>
    <liberty.env.JAVA_HOME>/opt/ibm/java</liberty.env.JAVA_HOME>
    <liberty.var.someVariable1>someValue1</liberty.var.someVariable1>
    <liberty.defaultVar.someDefaultVar1>someDefaultValue1</liberty.defaultVar.someDefaultVar1>
</properties>
---

Example 2 shows how to use Maven properties in the pom.xml to specify Liberty configuration. The properties can also be overridden on the command line using -D<maven property name>. This provides an easy way to test with different server configurations.

So give the 3.1 version of the liberty-maven-plugin a try and let us know what you think! Tap us up on Gitter, or file issues and send us pull requests on GitHub.