ccmvn
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMaven Build with ccmvn
使用ccmvn进行Maven构建
The tool enables Maven to run in restricted sandbox environments where outbound HTTPS is blocked or DNS resolution is unavailable. It works by creating a local HTTP proxy that Maven uses to access Maven Central.
ccmvnccmvnWhen to Use This Skill
适用场景
- Running Maven builds (,
clean install,package,test, etc.)compile - Building Java projects that depend on Maven Central
- Working in sandboxed environments with network restrictions
- Needing to execute Maven with custom parameters and options
- 运行Maven构建(、
clean install、package、test等)compile - 构建依赖Maven Central的Java项目
- 在存在网络限制的沙箱环境中工作
- 需要使用自定义参数和选项执行Maven
Prerequisites
前置条件
Before using this skill, ensure:
- Maven is installed: The system must have Maven 3.x installed
- Node.js is available: Required for the proxy server (typically pre-installed in Claude Code)
- Proxy configuration (for sandboxed Claude Code): The environment variable should be set if in a restricted sandbox
HTTPS_PROXY
使用此技能前,请确保:
- 已安装Maven:系统必须安装Maven 3.x版本
- Node.js可用:代理服务器需要Node.js(Claude Code中通常已预装)
- 代理配置(针对沙箱环境下的Claude Code):如果处于受限沙箱中,应设置环境变量
HTTPS_PROXY
Basic Usage
基础用法
Simple Build
简单构建
```bash
npx ccmvn clean install
```
bash
npx ccmvn clean installOther Common Commands
其他常用命令
```bash
bash
undefinedPackage the project
打包项目
npx ccmvn package
npx ccmvn package
Run tests
运行测试
npx ccmvn test
npx ccmvn test
Compile only
仅编译
npx ccmvn compile
npx ccmvn compile
Custom parameters
自定义参数
npx ccmvn clean install -DskipTests
npx ccmvn clean install -X # Debug output
```
npx ccmvn clean install -DskipTests
npx ccmvn clean install -X # 调试输出
undefinedHow ccmvn Works
ccmvn工作原理
ccmvn creates a three-layer proxy chain:
```
Maven → Local Proxy → Upstream Sandbox Proxy → Maven Central
(HTTP) (HTTP CONNECT) (HTTP/2 over TLS)
```
ccmvn会创建一个三层代理链:
Maven → 本地代理 → 上游沙箱代理 → Maven Central
(HTTP) (HTTP CONNECT) (HTTP/2 over TLS)Architecture Layers
架构分层
-
Maven → Local Proxy (localhost:8080)
- Plain HTTP communication
- Maven configured via `~/.m2/settings.xml`
- No authentication required locally
-
Local Proxy → Upstream Proxy
- HTTP CONNECT tunneling with JWT authentication
- Upstream proxy performs DNS resolution for sandboxed environments
-
Local Proxy → Maven Central
- HTTP/2 over TLS with ALPN negotiation
- Secure connection to Maven Central repositories
-
Maven → 本地代理(localhost:8080)
- 纯HTTP通信
- 通过配置Maven
~/.m2/settings.xml - 本地无需认证
-
本地代理 → 上游代理
- 带JWT认证的HTTP CONNECT隧道
- 上游代理为沙箱环境执行DNS解析
-
本地代理 → Maven Central
- 基于TLS的HTTP/2通信,支持ALPN协商
- 与Maven Central仓库的安全连接
Automatic Configuration
自动配置
ccmvn automatically:
- Creates `~/.m2/settings.xml` if it doesn't exist
- Configures Maven to use the local proxy as a mirror for Maven Central
- Starts the proxy server before running Maven
- Cleans up the proxy server after Maven completes
ccmvn会自动完成以下操作:
- 如果不存在则创建该文件
~/.m2/settings.xml - 配置Maven将本地代理用作Maven Central的镜像
- 运行Maven前启动代理服务器
- Maven完成后清理代理服务器
Common Maven Commands
常用Maven命令
| Command | Purpose |
|---|---|
| `ccmvn clean` | Remove build artifacts |
| `ccmvn compile` | Compile source code |
| `ccmvn test` | Run tests |
| `ccmvn package` | Create JAR/WAR file |
| `ccmvn install` | Install to local repository |
| `ccmvn deploy` | Deploy to remote repository |
| `ccmvn clean install` | Full clean build and install |
| 命令 | 用途 |
|---|---|
| 移除构建产物 |
| 编译源代码 |
| 运行测试 |
| 创建JAR/WAR文件 |
| 安装到本地仓库 |
| 部署到远程仓库 |
| 完整清理构建并安装 |
Advanced Options
高级选项
Skip Tests During Build
构建时跳过测试
```bash
npx ccmvn clean install -DskipTests
```
bash
npx ccmvn clean install -DskipTestsRun with Debug Output
启用调试输出运行
```bash
npx ccmvn clean install -X
```
bash
npx ccmvn clean install -XSpecify Specific Goals
指定特定目标
```bash
npx ccmvn clean compile test-compile
```
bash
npx ccmvn clean compile test-compileUse Custom Settings File
使用自定义配置文件
Maven will automatically use `~/.m2/settings.xml`. To verify or modify proxy settings, check this file after running ccmvn.
Maven会自动使用。若要验证或修改代理设置,请在运行ccmvn后检查该文件。
~/.m2/settings.xmlTroubleshooting
故障排查
Proxy Connection Issues
代理连接问题
If you see proxy-related errors:
- Ensure `HTTPS_PROXY` environment variable is correctly set (if in a sandboxed environment)
- Check that the proxy server can reach Maven Central
- Verify your proxy credentials are correct
如果遇到代理相关错误:
- 确保环境变量已正确设置(若处于沙箱环境)
HTTPS_PROXY - 检查代理服务器是否能连接到Maven Central
- 验证代理凭据是否正确
Maven Not Found
Maven未找到
If Maven is not installed:
```bash
若未安装Maven:
bash
undefinedInstall Maven (varies by system)
安装Maven(根据系统不同而有所差异)
brew install maven # macOS
apt-get install maven # Ubuntu/Debian
```
brew install maven # macOS
apt-get install maven # Ubuntu/Debian
undefinedMaven Central Timeout
Maven Central超时
If builds timeout accessing Maven Central:
- Check your network connection
- Try again - temporary network issues can cause timeouts
- Use `-X` flag for debug output to see where it's hanging
如果构建时访问Maven Central超时:
- 检查网络连接
- 重试 - 临时网络问题可能导致超时
- 使用标志查看调试输出,确定卡顿时点
-X
Settings.xml Issues
settings.xml问题
ccmvn automatically creates `~/.m2/settings.xml` if missing. If you have a custom settings file:
- Backup your current `~/.m2/settings.xml`
- Remove it and let ccmvn create a fresh one
- Or manually add the proxy mirror configuration
如果缺失,ccmvn会自动创建。若你有自定义配置文件:
~/.m2/settings.xml- 备份当前的
~/.m2/settings.xml - 删除该文件,让ccmvn创建一个新的
- 或手动添加代理镜像配置
Examples
示例
Building a Spring Boot Application
构建Spring Boot应用
```bash
npx ccmvn clean package -DskipTests
```
bash
npx ccmvn clean package -DskipTestsRunning Unit Tests
运行单元测试
```bash
npx ccmvn clean test
```
bash
npx ccmvn clean testFull Build with All Checks
完整构建并执行所有检查
```bash
npx ccmvn clean install
```
bash
npx ccmvn clean installBuilding Specific Module (in multi-module project)
构建特定模块(多模块项目中)
```bash
npx ccmvn clean install -pl module-name
```
bash
npx ccmvn clean install -pl module-nameEnvironment Variables
环境变量
HTTPS_PROXY (Sandboxed Environments Only)
HTTPS_PROXY(仅沙箱环境)
This is automatically used by ccmvn for sandboxed Claude Code environments. In local development, this is typically not needed.
格式:
http://username:jwt_token@host:portccmvn会自动在沙箱环境下的Claude Code中使用该变量。在本地开发中,通常不需要设置。
Security
安全说明
- Local proxy only: The proxy server is only accessible on localhost
- TLS validation: TLS certificates are validated for Maven Central
- End-to-end encryption: Connection through the proxy chain maintains encryption
- Token protection: JWT tokens are only used for authentication to the upstream proxy
- 仅本地代理:代理服务器仅在localhost可访问
- TLS验证:对Maven Central的TLS证书进行验证
- 端到端加密:代理链中的连接保持加密
- 令牌保护:JWT令牌仅用于向上游代理认证
Performance Tips
性能优化建议
- First build: Initial builds will download dependencies - this takes longer
- Incremental builds: Subsequent builds with cached dependencies are much faster
- Skip tests if not needed: Use `-DskipTests` to speed up builds during development
- Use clean install sparingly: Only use `clean` when you have problems or need a fresh build
- 首次构建:初始构建会下载依赖包 - 耗时较长
- 增量构建:后续使用缓存依赖的构建速度会快很多
- 无需测试时跳过:开发期间使用加快构建速度
-DskipTests - 谨慎使用clean install:仅在遇到问题或需要全新构建时使用
clean