← Back to Skills Marketplace
wu-uk

maven-build-lifecycle

by wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ Security Clean
69
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install fix-build-google-auto-maven-build-lifecycle
Description
Use when working with Maven build phases, goals, profiles, or customizing the build process for Java projects.
README (SKILL.md)

Maven Build Lifecycle

Master Maven's build lifecycle including phases, goals, profiles, and build customization for efficient Java project builds.

Overview

Maven's build lifecycle is a well-defined sequence of phases that execute in order. Understanding the lifecycle is essential for effective build configuration and optimization.

Default Lifecycle Phases

Complete Phase Order

1.  validate      - Validate project structure
2.  initialize    - Initialize build state
3.  generate-sources
4.  process-sources
5.  generate-resources
6.  process-resources - Copy resources to output
7.  compile       - Compile source code
8.  process-classes
9.  generate-test-sources
10. process-test-sources
11. generate-test-resources
12. process-test-resources
13. test-compile  - Compile test sources
14. process-test-classes
15. test          - Run unit tests
16. prepare-package
17. package       - Create JAR/WAR
18. pre-integration-test
19. integration-test - Run integration tests
20. post-integration-test
21. verify        - Run verification checks
22. install       - Install to local repo
23. deploy        - Deploy to remote repo

Common Phase Commands

# Compile only
mvn compile

# Compile and run tests
mvn test

# Create package
mvn package

# Install to local repository
mvn install

# Deploy to remote repository
mvn deploy

# Clean and build
mvn clean install

# Skip tests
mvn install -DskipTests

# Skip test compilation and execution
mvn install -Dmaven.test.skip=true

Clean Lifecycle

1. pre-clean
2. clean         - Delete target directory
3. post-clean
# Clean build artifacts
mvn clean

# Clean specific directory
mvn clean -DbuildDirectory=out

Site Lifecycle

1. pre-site
2. site          - Generate documentation
3. post-site
4. site-deploy   - Deploy documentation
# Generate site
mvn site

# Generate and deploy site
mvn site-deploy

Goals vs Phases

Executing Phases

# Execute phase (runs all previous phases)
mvn package

Executing Goals

# Execute specific goal
mvn compiler:compile
mvn surefire:test
mvn jar:jar

# Multiple goals
mvn dependency:tree compiler:compile

Phase-to-Goal Bindings

\x3Cbuild>
    \x3Cplugins>
        \x3Cplugin>
            \x3CgroupId>org.apache.maven.plugins\x3C/groupId>
            \x3CartifactId>maven-compiler-plugin\x3C/artifactId>
            \x3Cversion>3.12.1\x3C/version>
            \x3Cexecutions>
                \x3Cexecution>
                    \x3Cid>compile-sources\x3C/id>
                    \x3Cphase>compile\x3C/phase>
                    \x3Cgoals>
                        \x3Cgoal>compile\x3C/goal>
                    \x3C/goals>
                \x3C/execution>
            \x3C/executions>
        \x3C/plugin>
    \x3C/plugins>
\x3C/build>

Build Profiles

Profile Definition

\x3Cprofiles>
    \x3Cprofile>
        \x3Cid>development\x3C/id>
        \x3Cactivation>
            \x3CactiveByDefault>true\x3C/activeByDefault>
        \x3C/activation>
        \x3Cproperties>
            \x3Cenv>dev\x3C/env>
            \x3Cskip.integration.tests>true\x3C/skip.integration.tests>
        \x3C/properties>
    \x3C/profile>

    \x3Cprofile>
        \x3Cid>production\x3C/id>
        \x3Cproperties>
            \x3Cenv>prod\x3C/env>
            \x3Cskip.integration.tests>false\x3C/skip.integration.tests>
        \x3C/properties>
        \x3Cbuild>
            \x3Cplugins>
                \x3Cplugin>
                    \x3CgroupId>org.apache.maven.plugins\x3C/groupId>
                    \x3CartifactId>maven-compiler-plugin\x3C/artifactId>
                    \x3Cconfiguration>
                        \x3Cdebug>false\x3C/debug>
                        \x3Coptimize>true\x3C/optimize>
                    \x3C/configuration>
                \x3C/plugin>
            \x3C/plugins>
        \x3C/build>
    \x3C/profile>
\x3C/profiles>

Profile Activation

# Activate by name
mvn install -Pproduction

# Multiple profiles
mvn install -Pproduction,ci

# Deactivate profile
mvn install -P!development

Activation Triggers

\x3Cprofile>
    \x3Cid>jdk17\x3C/id>
    \x3Cactivation>
        \x3C!-- Activate by JDK version -->
        \x3Cjdk>17\x3C/jdk>
    \x3C/activation>
\x3C/profile>

\x3Cprofile>
    \x3Cid>windows\x3C/id>
    \x3Cactivation>
        \x3C!-- Activate by OS -->
        \x3Cos>
            \x3Cfamily>windows\x3C/family>
        \x3C/os>
    \x3C/activation>
\x3C/profile>

\x3Cprofile>
    \x3Cid>ci\x3C/id>
    \x3Cactivation>
        \x3C!-- Activate by environment variable -->
        \x3Cproperty>
            \x3Cname>env.CI\x3C/name>
            \x3Cvalue>true\x3C/value>
        \x3C/property>
    \x3C/activation>
\x3C/profile>

\x3Cprofile>
    \x3Cid>with-config\x3C/id>
    \x3Cactivation>
        \x3C!-- Activate by file existence -->
        \x3Cfile>
            \x3Cexists>src/main/config/app.properties\x3C/exists>
        \x3C/file>
    \x3C/activation>
\x3C/profile>

Resource Filtering

Enable Filtering

\x3Cbuild>
    \x3Cresources>
        \x3Cresource>
            \x3Cdirectory>src/main/resources\x3C/directory>
            \x3Cfiltering>true\x3C/filtering>
            \x3Cincludes>
                \x3Cinclude>**/*.properties\x3C/include>
                \x3Cinclude>**/*.xml\x3C/include>
            \x3C/includes>
        \x3C/resource>
        \x3Cresource>
            \x3Cdirectory>src/main/resources\x3C/directory>
            \x3Cfiltering>false\x3C/filtering>
            \x3Cexcludes>
                \x3Cexclude>**/*.properties\x3C/exclude>
                \x3Cexclude>**/*.xml\x3C/exclude>
            \x3C/excludes>
        \x3C/resource>
    \x3C/resources>
\x3C/build>

Property Substitution

# application.properties
app.name=${project.name}
app.version=${project.version}
app.environment=${env}
build.timestamp=${maven.build.timestamp}

Build Customization

Source and Target Configuration

\x3Cproperties>
    \x3Cmaven.compiler.source>17\x3C/maven.compiler.source>
    \x3Cmaven.compiler.target>17\x3C/maven.compiler.target>
    \x3Cmaven.compiler.release>17\x3C/maven.compiler.release>
    \x3Cproject.build.sourceEncoding>UTF-8\x3C/project.build.sourceEncoding>
\x3C/properties>

Custom Source Directories

\x3Cbuild>
    \x3CsourceDirectory>src/main/java\x3C/sourceDirectory>
    \x3CtestSourceDirectory>src/test/java\x3C/testSourceDirectory>
    \x3Cresources>
        \x3Cresource>
            \x3Cdirectory>src/main/resources\x3C/directory>
        \x3C/resource>
    \x3C/resources>
    \x3CtestResources>
        \x3CtestResource>
            \x3Cdirectory>src/test/resources\x3C/directory>
        \x3C/testResource>
    \x3C/testResources>
\x3C/build>

Final Name and Output

\x3Cbuild>
    \x3CfinalName>${project.artifactId}-${project.version}\x3C/finalName>
    \x3Cdirectory>target\x3C/directory>
    \x3CoutputDirectory>target/classes\x3C/outputDirectory>
    \x3CtestOutputDirectory>target/test-classes\x3C/testOutputDirectory>
\x3C/build>

Multi-Module Builds

Reactor Options

# Build all modules
mvn install

# Build specific module and dependencies
mvn install -pl module-name -am

# Build dependents of a module
mvn install -pl module-name -amd

# Resume from specific module
mvn install -rf :module-name

# Build in parallel
mvn install -T 4
mvn install -T 1C  # 1 thread per CPU core

Module Order Control

\x3C!-- parent/pom.xml -->
\x3Cmodules>
    \x3Cmodule>common\x3C/module>
    \x3Cmodule>api\x3C/module>
    \x3Cmodule>service\x3C/module>
    \x3Cmodule>web\x3C/module>
\x3C/modules>

Test Configuration

Surefire Plugin (Unit Tests)

\x3Cplugin>
    \x3CgroupId>org.apache.maven.plugins\x3C/groupId>
    \x3CartifactId>maven-surefire-plugin\x3C/artifactId>
    \x3Cversion>3.2.3\x3C/version>
    \x3Cconfiguration>
        \x3Cincludes>
            \x3Cinclude>**/*Test.java\x3C/include>
            \x3Cinclude>**/*Tests.java\x3C/include>
        \x3C/includes>
        \x3Cexcludes>
            \x3Cexclude>**/*IntegrationTest.java\x3C/exclude>
        \x3C/excludes>
        \x3Cparallel>methods\x3C/parallel>
        \x3CthreadCount>4\x3C/threadCount>
        \x3CforkCount>1\x3C/forkCount>
        \x3CreuseForks>true\x3C/reuseForks>
    \x3C/configuration>
\x3C/plugin>

Failsafe Plugin (Integration Tests)

\x3Cplugin>
    \x3CgroupId>org.apache.maven.plugins\x3C/groupId>
    \x3CartifactId>maven-failsafe-plugin\x3C/artifactId>
    \x3Cversion>3.2.3\x3C/version>
    \x3Cexecutions>
        \x3Cexecution>
            \x3Cgoals>
                \x3Cgoal>integration-test\x3C/goal>
                \x3Cgoal>verify\x3C/goal>
            \x3C/goals>
        \x3C/execution>
    \x3C/executions>
    \x3Cconfiguration>
        \x3Cincludes>
            \x3Cinclude>**/*IT.java\x3C/include>
            \x3Cinclude>**/*IntegrationTest.java\x3C/include>
        \x3C/includes>
    \x3C/configuration>
\x3C/plugin>

Build Optimization

Incremental Builds

# Skip unchanged modules
mvn install -amd

# Use build cache (requires Maven Daemon)
mvnd install

Parallel Builds

\x3Cbuild>
    \x3Cplugins>
        \x3Cplugin>
            \x3CgroupId>org.apache.maven.plugins\x3C/groupId>
            \x3CartifactId>maven-compiler-plugin\x3C/artifactId>
            \x3Cconfiguration>
                \x3Cfork>true\x3C/fork>
                \x3CcompilerArgs>
                    \x3Carg>-J-Xmx512m\x3C/arg>
                \x3C/compilerArgs>
            \x3C/configuration>
        \x3C/plugin>
    \x3C/plugins>
\x3C/build>

Build Cache

# Enable build cache (Maven 4+)
mvn install -Dmaven.build.cache.enabled=true

Debugging Builds

Verbose Output

# Debug mode
mvn install -X

# Error stacktrace
mvn install -e

# Quiet mode
mvn install -q

Effective POM

# View resolved POM
mvn help:effective-pom

# View effective settings
mvn help:effective-settings

# Active profiles
mvn help:active-profiles

Dependency Analysis

# Check plugin versions
mvn versions:display-plugin-updates

# Check dependency versions
mvn versions:display-dependency-updates

Best Practices

  1. Use Clean Builds - Run mvn clean before releases
  2. Consistent Versions - Lock plugin versions
  3. Profile Isolation - Keep profiles focused
  4. Fail Fast - Use -ff in CI for quick feedback
  5. Parallel Builds - Use -T for multi-module projects
  6. Skip Wisely - Know the difference between skip options
  7. Resource Filtering - Enable only where needed
  8. Test Separation - Unit tests in Surefire, integration in Failsafe
  9. Reproducible Builds - Pin all plugin versions
  10. Document Profiles - Comment profile purposes

Common Pitfalls

  1. Skipping Tests - Don't skip tests in CI
  2. SNAPSHOT in Release - Remove snapshots before release
  3. Missing Clean - Stale files causing issues
  4. Profile Conflicts - Overlapping profile configurations
  5. Resource Filtering - Accidentally filtering binaries
  6. Phase Confusion - Running wrong phase
  7. Memory Issues - Insufficient heap for large builds
  8. Reactor Order - Module dependency issues

CI/CD Integration

GitHub Actions

- name: Build with Maven
  run: mvn -B clean verify -Pci

- name: Release
  run: mvn -B deploy -Prelease -DskipTests

Jenkins Pipeline

stage('Build') {
    steps {
        sh 'mvn -B clean package -DskipTests'
    }
}
stage('Test') {
    steps {
        sh 'mvn -B test'
    }
}
stage('Integration Test') {
    steps {
        sh 'mvn -B verify -DskipUnitTests'
    }
}

When to Use This Skill

  • Setting up new Maven projects
  • Customizing build phases
  • Creating build profiles for environments
  • Configuring test execution
  • Optimizing build performance
  • Debugging build failures
  • Setting up CI/CD pipelines
  • Multi-module project configuration
Usage Guidance
This skill appears coherent and limited to Maven build guidance. It does not request credentials or install code. Before enabling, ensure the agent has mvn available if you expect it to run commands, and be aware that following some instructions (activating profiles by file presence or env vars) implies the agent may inspect your project files or environment — only allow that if you trust the agent with access to the repository/workspace.
Capability Analysis
Type: OpenClaw Skill Name: fix-build-google-auto-maven-build-lifecycle Version: 0.1.0 The skill bundle contains standard documentation and configuration examples for the Apache Maven build lifecycle. It provides educational content on build phases, profiles, and plugin configurations (SKILL.md) without any executable code, data exfiltration attempts, or malicious instructions.
Capability Assessment
Purpose & Capability
Name/description match the SKILL.md content: all instructions are about Maven phases, goals, profiles, resource filtering, and common mvn commands. There are no unrelated binaries, credentials, or config paths requested.
Instruction Scope
SKILL.md stays on-topic: provides commands, XML examples, and notes about profile activation (by JDK, OS, env var, or file existence). The only references to environment or files are standard Maven features (e.g., env.CI or checking for src/main/config/app.properties). There are no instructions to read or exfiltrate unrelated system files or secrets.
Install Mechanism
No install spec and no code files — instruction-only. This minimizes risk because nothing is downloaded or written to disk by the skill itself.
Credentials
The skill declares no required environment variables, secrets, or config paths. The SKILL.md mentions using environment variables only in the context of Maven profile activation (standard practice).
Persistence & Privilege
always is false and the skill is user-invocable; disable-model-invocation is false (agent can invoke it autonomously), which is the platform default and is not combined with other concerning permissions or credentials.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install fix-build-google-auto-maven-build-lifecycle
  3. After installation, invoke the skill by name or use /fix-build-google-auto-maven-build-lifecycle
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.1.0
Bulk publish from all-task-skills-dedup
Metadata
Slug fix-build-google-auto-maven-build-lifecycle
Version 0.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is maven-build-lifecycle?

Use when working with Maven build phases, goals, profiles, or customizing the build process for Java projects. It is an AI Agent Skill for Claude Code / OpenClaw, with 69 downloads so far.

How do I install maven-build-lifecycle?

Run "/install fix-build-google-auto-maven-build-lifecycle" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is maven-build-lifecycle free?

Yes, maven-build-lifecycle is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does maven-build-lifecycle support?

maven-build-lifecycle is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created maven-build-lifecycle?

It is built and maintained by wu-uk (@wu-uk); the current version is v0.1.0.

💬 Comments