← 返回 Skills 市场
wu-uk

maven-build-lifecycle

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
69
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install fix-build-google-auto-maven-build-lifecycle
功能描述
Use when working with Maven build phases, goals, profiles, or customizing the build process for Java projects.
使用说明 (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
安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install fix-build-google-auto-maven-build-lifecycle
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /fix-build-google-auto-maven-build-lifecycle 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug fix-build-google-auto-maven-build-lifecycle
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

maven-build-lifecycle 是什么?

Use when working with Maven build phases, goals, profiles, or customizing the build process for Java projects. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 69 次。

如何安装 maven-build-lifecycle?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install fix-build-google-auto-maven-build-lifecycle」即可一键安装,无需额外配置。

maven-build-lifecycle 是免费的吗?

是的,maven-build-lifecycle 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

maven-build-lifecycle 支持哪些平台?

maven-build-lifecycle 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 maven-build-lifecycle?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论