Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
111 lines (84 loc) · 4.08 KB

File metadata and controls

111 lines (84 loc) · 4.08 KB

Building and running the sample using the command line

Clone Git Repo

📌 Switch to Eclipse example

$ git clone https://github.com/WASdev/sample.async.websockets.git

Building the sample with Maven

📌 Switch to Eclipse example

Apache Maven commands
$ mvn install

You can skip tests with the following:

$ mvn install -DskipTests=true

In addition to publishing the WAR to the local Maven repository, the built WAR file is copied into the apps directory of the server configuration located in the async-websocket-wlpcfg directory:

async-websocket-wlpcfg
 +- target
     +- async-websocket-wlpcfg-1.0.zip                         <-- packaged server file containing the server, application, and configuration
        +- wlp
            +- usr
                +- server
                    +- websocketSample
                        +- server.xml                          <-- server configuration
                        +- apps                                <- directory for applications
                            +- async-websocket-application.war <- sample application
                        +- logs                                <- created by running the server locally
                        +- workarea                            <- created by running the server locally

Running the application locally with Maven

📌 Switch to Eclipse example

Change the current directory to the async-websocket-wlpcfg sub-project, and use the following commands to start the server and run the application:

To run the server in the foreground:

$ mvn liberty:run-server

To run the server in a background process:

$ mvn liberty:start-server

To stop the server:

$ mvn liberty:stop-server

Building the sample with Gradle

This project can also be built and run with Gradle. The provided build.gradle file applies the Liberty Gradle Plug-in and is configured to automatically download and install the Liberty Java EE 7 Full Platform runtime from Maven Central. The Liberty Gradle Plug-in has built-in tasks that can be used to create, configure, and run the application on the Liberty server.

Use the following steps to run the application with the Gradle wrapper (Windows machines use gradlew.bat):

  1. Execute the full Gradle build. The Liberty Gradle Plug-in will download and install the Liberty server.
    $ ./gradlew clean build
async-websocket-wlpcfg
+- build
    +- wlp
        +- usr
            +- servers
                +- websocketSample
                    +- server.xml                          <-- server configuration
                    +- apps                                <-- directory for applications
                        +- async-websocket-application     <-- the websocket application
                    +- logs                                <-- created by running the server locally
                    +- workarea                            <-- created by running the server locally

Running the application locally with Gradle

  1. To start the server with the Websocket sample execute:

    $ ./gradlew libertyStart

    Alternatively, execute the run command:

    $ ./gradlew libertyRun --no-daemon

Once the server has started, the application will be available under http://localhost:9082/websocket/.

  1. To stop the server, execute:
    $ ./gradlew libertyStop

Note, if Gradle is properly installed, Gradle commands can be executed directly using gradle and wouldn't require gradlew.

Please refer to the Liberty Gradle Plug-in repository for documentation about using the Liberty Gradle Plug-in.