This is what users want

Lagom introduces Maven support

Gabriela Motroc
Lagom

The rope knot image via Shutterstock

The first release of Lagom only supported sbt, but after the lack of Maven support became a blocker for many potential users, the team decided to make the investment necessary to run Lagom in Maven.

The first release of Lagom only included support for sbt, a build tool which helped make the implementation of its high productivity development environment very straight forward. The decision was based on the fact that the Lagom development environment could easily interrogate users’ build by executing those tasks to acquire the information it needs to setup Lagom’s hot reloads.

However, according to early feedback, not adding Maven support became a blocker for many potential users, including large companies that have invested greatly in their Maven infrastructure (proxies, developer setup guides, and standardized pom files included). As a result, the Lagom team decided to run Lagom in Maven.

Let’s get started

Lagom’s high productivity development environment is definitely one of its best features, but it is also the hardest feature to implement in a build tool. Lightbend’s James Roper invited people to check it out in Maven and explained that users’ projects can be run using the lagom:runAll goal.

The following happened: Cassandra has been started, a service locator is running on port 8000, a service gateway is running on port 9000 and their services are running on various ports.

Roper also talked about one of the biggest productivity killers, namely build/deploy loops and revealed that Lagom watches all of users’ sources, and automatically recompiling and reloading them as soon as it sees a change. After he added a small string to the messsages returned by the hello service, in hello-impl/src/main/java/com/example/hello/impl/HelloServiceImpl.java

 public ServiceCall<NotUsed, String> hello(String id) {
    return request -> {
      // Look up the hello world entity for the given ID.
      PersistentEntityRef<HelloCommand> ref = persistentEntityRegistry.refFor(HelloEntity.class, id);
      // Ask the entity the Hello command.
      return ref.ask(new Hello(id, Optional.empty()))
          .thenApply(msg -> msg + " <- that's the message");
    };
  }

and hit save, Maven output

[INFO] Copying 1 resource
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /home/jroper/tmp/my-first-system/hello-impl/target/classes

--- (RELOAD) ---

When he hit the service again, the updated message appeared.

$ curl http://localhost:9000/api/hello/Maven
Hello, Maven! <- that's the message

Check out the Lagom documentation to find out more about its Maven support.

Author
Gabriela Motroc
Gabriela Motroc is editor of JAXenter.com and JAX Magazine. Before working at S&S Media she studied International Communication Management at The Hague University of Applied Sciences.

Comments
comments powered by Disqus