DEV Community

Salad Lam
Salad Lam

Posted on

Maven notes (1)

Lifecycle

default, clean and site

Phase

When executes

mvn compile
Enter fullscreen mode Exit fullscreen mode

Phase from validate to compile will be gone through.

Full list of phases is here.

Goal

In plugin goals are defined and are binded to phases. For example, the compile goal in maven-compiler-plugin is binded to compile phase.

The order of goal execution of plugins in the same phase is defined by entry order in the plugins section of the pom.xml file.

To list the plugin's goals is binded to the package phase.

mvn help:describe -Dcmd=package
Enter fullscreen mode Exit fullscreen mode

To check goals and phases from plugin's source code

To configure frontend-maven-plugin plugin.

<plugin>
  <groupId>com.github.eirslett</groupId>
  <artifactId>frontend-maven-plugin</artifactId>
  <version>1.15.1</version>
  <executions>
    <execution>
      <id>install-node-and-npm</id>
      <goals>
        <goal>install-node-and-npm</goal>
      </goals>
    </execution>
    <execution>
      <id>npm install</id>
      <goals>
        <goal>npm</goal>
      </goals>
    </execution>
    ..
  </executions>
</plugin>
Enter fullscreen mode Exit fullscreen mode

Following is the class of defining install-node-and-npm and npm goal. They are binded to generate-resources phase.

@Mojo(name="install-node-and-npm", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
public final class InstallNodeAndNpmMojo extends AbstractFrontendMojo {
  // ...
}

@Mojo(name="npm",  defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true)
public final class NpmMojo extends AbstractFrontendMojo {
  // ...
}
Enter fullscreen mode Exit fullscreen mode

Profile

  • add/override properties
  • add dependencies
  • add plugin dependencies
  • add pluginManagement dependencies

set default profile

<!-- (1) --->
<profiles>
  <profile>
    <activation>
      <property>
        <name>debug</name>
      </property>
    </activation>
    ...
  </profile>
</profiles>

<!-- (2) --->
<profile>
  <id>dev</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  ...
</profile>
Enter fullscreen mode Exit fullscreen mode

override enabled profile

assumes profile dev is enabled by default, and to enable profile production

mvn -P=-dev,production
Enter fullscreen mode Exit fullscreen mode

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay