Defining the Default Goal

If you are frequently running the weather:run goal from the command line, you may want to specify a default goal for your Maven project. By specifying a default goal, you can run maven from the command line without any arguments, and Maven will execute the weather:run goal.

How do I do that?

To set the default goal for a project, simply list the goal name in the default attribute of the project element:

<?xml version="1.0" encoding="UTF-8"?>
  
<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" 
    xmlns:maven="jelly:maven" default="weather:run">
  
    // ...snip...
  
</project>

When you execute Maven without specifying a goal, Maven will execute the weather:run goal. That was easy enough!

Get Maven: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.