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

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay