Developing with the Liberty Maven plug-in

Use the liberty-maven-plugin and Eclipse tools to work with WebSphere® Application Server Liberty in a Maven environment.

About this task

The liberty-maven-plugin includes loose application support for web applications in version 2.0 and later. In version 2.1 and later, the plugin includes support for enterprise archive (EAR) files and Liberty assembly projects in addition to web applications. This support enables the WebSphere Application Server Liberty runtime to process updates quickly. Eclipse tools can detect supported Maven projects that are configured to work with the liberty-maven-plugin. Eclipse tools can also automatically create a server in the workbench. Develop and debug within Eclipse and build and package with Maven for a cohesive Maven development experience.

Procedure

  1. Generate a sample project from an archetype.
    1. Enter the following command for web applications: mvn archetype:generate -DarchetypeGroupId=net.wasdev.wlp.maven -DarchetypeArtifactId=liberty-archetype-webapp -DarchetypeVersion=2.0 -DgroupId=ServletSample -DartifactId=ServletSample -Dversion=1.0
    2. Enter the following command for EAR applications: mvn archetype:generate -DarchetypeGroupId=net.wasdev.wlp.maven -DarchetypeArtifactId=liberty-archetype-ear -DarchetypeVersion=2.1-SNAPSHOT -DwlpPluginVersion=2.1-SNAPSHOT -DgroupId=test -DartifactId=test -Dversion=1.0-SNAPSHOT
  2. Run mvn install on your project.
  3. Import your project into an existing Maven project by going to File > Import… > Existing Maven Projects.
    After you import your project, a window appears.
  4. Select Yes or No.

    Select Yes to automatically generate a server in the Servers view. Your application is added and ready for updates.

    Select No to manually create a server.

    Note: To control whether this window appears, select Preferences > Maven > Liberty Integration and select a preference for automatically creating servers.
    • Select Always ask to make the window appear and give you the option to automatically generate a server or not.
    • Select Yes to skip the window and automatically create the server.
    • Select No to skip the window and prevent the automatic creation of the server.
  5. Optional: Create a runtime and server with one of the following methods if you selected No and want to manually create a server:

    Open the Runtime Explorer view to see the location of a runtime in a project. Right-click a list item and select the Create runtime and server action.

    Right-click on a Maven project and select Maven > Create runtime and server.

  6. Develop, run, and debug the application on the generated server.
  7. Use Maven to package the application.