CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Apache Maven

$ mvn 基金会 中风险
Apache · 代码托管与研发协同 · Apache-2.0 · macos / linux / windows

Apache Maven(mvn)基于 pom.xml 编排 Java/JVM 编译、依赖解析、打包与插件目标执行。它支持 -B(--batch-mode)、--color never 与 -o(--offline),但构建日志为冗长的纯文本且缺少原生 --json 输出。

FCRS-1.0 综合评分
75 /100
良好 (Good)
高置信度 (实测)
零摩擦安装命令
brew install maven
CLI vs MCP 选型建议 优先选 CLI

mvn 直接在本地编译 JVM 字节码、解析 ~/.m2 制品并运行 Surefire/Failsafe 测试套件,MCP 无法替代本地构建执行。

Agent 友好度体检单

本地探针实测证据
— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md
实测版本
Apache Maven 3.9.12 (848fbb4bf2d427b72bdb2471c22fced7ebd9a7a1)
冷启动耗时
577 ms
退出码 (help / 非法参数)
0 / 1
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
 -am,--also-make                         If project list is specified,
                                         also build projects required by
                                         the list
 -amd,--also-make-dependents             If project list is specified,
                                         also build projects that depend
                                         on projects on the list
 -B,--batch-mode                         Run in non-interactive (batch)
                                         mode (disables output color)
 -b,--builder <arg>                      The id of the build strategy to
                                         use
 -C,--strict-checksums                   Fail the build if checksums don't
                                         match
 -c,--lax-checksums                      Warn if checksums don't match
    --color <arg>                        Defines the color mode of the
                                         output. Supported are 'auto',
                                         'always', 'never'.
 -cpu,--check-plugin-updates             Ineffective, only kept for
                                         backward compatibility
 -D,--define <arg>                       Define a user property
 -e,--errors                             Produce execution error messages
 -emp,--encrypt-master-password <arg>    Encrypt master security password
 -ep,--encrypt-password <arg>            Encrypt server password
 -f,--file <arg>                         Force the use of an alternate POM
                                         file (or directory with pom.xml)
 -fae,--fail-at-end                      Only fail the build afterwards;
                                         allow all non-impacted builds to
                                         continue
 -ff,--fail-fast                         Stop at first failure in
                                         reactorized builds
 -fn,--fail-never                        NEVER fail the build, regardless
                                         of project result
 -gs,--global-settings <arg>             Alternate path for the global
                                         settings file
 -gt,--global-toolchains <arg>           Alternate path for the global
                                         toolchains file
 -h,--help                               Display help information
 -itr,--ignore-transitive-repositories   If set, Mav

FCRS-1.0 六维评分拆解

Agent 友好度 15 / 25

支持 -B(--batch-mode)、-q、--color never 与 -o(--offline),但输出为非结构化长文本且缺少 --json 与全局 --dry-run。

  • -B --color never suppresses prompts and ANSI escapes
  • No native --json output across lifecycle goals
安全与权限边界 19 / 25

构建产物隔离在 target/ 与 ~/.m2/repository,但 mvn 缺少空跑模式且 deploy 会向远程仓库推送制品。

  • -o offline mode prevents unexpected network resolution
  • No global --dry-run before running lifecycle plugins
安装与运行摩擦 12 / 15

可通过 Homebrew、SDKMAN 与 ./mvnw wrapper 在 macOS、Linux 与 Windows 运行,依赖宿主 JDK。

  • Requires compatible JDK installed on host
能力覆盖与边际价值 12 / 15

JVM 生态的标准化构建生命周期,但冷启动开销和海量 [INFO] 日志容易消耗上下文窗口。

  • Universal Java build lifecycle; slower incremental builds than Gradle/mvnd
维护与来源背书 9 / 10

Apache 软件基金会旗舰项目(apache/maven),采用 Apache-2.0 协议。

  • Official Apache Software Foundation repository
文档与可验证性 8 / 10

maven.apache.org 提供全面官方文档,但各插件参数分散在独立插件页面。

  • Official CLI reference at maven.apache.org

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 本地配置文件
凭证存储位置

访问公共 Maven Central 无需认证;私有仓库凭据与 GPG 密钥配置在 ~/.m2/settings.xml 中。

潜在副作用
只读查询 本地写入 远端写入
费用与配额提示

Apache-2.0 开源 CLI,免费使用。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Apache Maven (mvn) Agent Rules
- Always pass `-B --color never` (and `-q` or `-fae` where appropriate) to avoid prompts and log bloat.
- Prefer `./mvnw` if present in the repo, and never run `mvn deploy` without explicit user approval.

Agent 高频安全命令配方

只读查询(安全推荐)

非交互打印解析后的完整有效 POM
mvn -B --color never help:effective-pom

展开父 POM、profiles 与属性,查看最终生效的构建配置。

查看项目依赖树
mvn -B --color never dependency:tree

在不运行编译或测试阶段的前提下输出 Maven 传递依赖树。

受控写入与预演

以静默批处理模式运行单元测试
mvn -B -q --color never test

非交互编译并执行单元测试,同时抑制冗长的 [INFO] 进度日志。

核心优势

  • + -B(--batch-mode)与 --color never 确保无交互、无 ANSI 转义输出。
  • + mvn -q 可裁剪大量 [INFO] 日志,仅保留精简的错误诊断信息。
  • + dependency:tree 与 help:effective-pom 可清晰透视传递依赖与最终配置。

注意事项与踩坑点

  • ! 不支持原生 --json 输出或全局 --dry-run 选项。
  • ! 若不使用 -q 或过滤,冗长的生命周期日志会迅速撑爆 Agent 上下文。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI