# maven远程构建平台 **Repository Path**: a100245/maven-remote-building-platform ## Basic Information - **Project Name**: maven远程构建平台 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-24 - **Last Updated**: 2025-12-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Maven 远程构建平台 从 Git 仓库构建 Maven 项目并下载生成的 JAR 文件。 ## 项目结构 ``` mockjenks2/ ├── backend/ # Spring Boot 后端 │ ├── pom.xml │ └── src/main/ │ ├── java/com/example/mavenbuild/ │ │ ├── MavenBuildApplication.java # 启动类 │ │ ├── config/ │ │ │ └── MavenBuildProperties.java # 配置属性 │ │ ├── controller/ │ │ │ └── BuildController.java # REST API 控制器 │ │ ├── service/ │ │ │ └── BuildService.java # 构建服务 │ │ ├── util/ │ │ │ └── ProcessUtils.java # 安全命令执行工具 │ │ └── dto/ │ │ ├── BuildRequest.java # 请求 DTO │ │ └── BuildResponse.java # 响应 DTO │ └── resources/ │ └── application.yml # 配置文件 │ └── frontend/ # Vue 3 前端 ├── index.html ├── package.json ├── vite.config.ts ├── tsconfig.json └── src/ ├── main.ts ├── App.vue ├── vue-shim.d.ts └── components/ └── BuildForm.vue # 构建表单组件 ``` ## 环境要求 - **后端**: Java 17+, Maven 3.6+ - **前端**: Node.js 18+, npm 9+ ## 后端配置 (application.yml) ```yaml server: port: 8080 maven-build: # 允许的 Git 仓库域名白名单 allowed-domains: - github.com - gitlab.com - gitee.com - bitbucket.org # 默认 Maven 路径(为空时自动查找) default-maven-path: "" # 临时目录 temp-dir: ${java.io.tmpdir}/maven-build # 清理间隔(毫秒)- 1小时 cleanup-interval: 3600000 ``` ## 前端配置 (vite.config.ts) Vite 开发服务器默认配置了代理,将 `/api` 请求转发到后端: ```typescript export default defineConfig({ server: { port: 3000, proxy: { '/api': { target: 'http://localhost:8080', changeOrigin: true } } } }) ``` ## 运行步骤 ### 1. 启动后端 ```bash cd backend mvn spring-boot:run ``` 或者打包后运行: ```bash mvn clean package -DskipTests java -jar target/maven-build-1.0.0.jar ``` ### 2. 启动前端 ```bash cd frontend npm install npm run dev ``` 访问 `http://localhost:3000` 即可使用。 ## API 接口 ### 构建接口 - **URL**: `POST /api/build` - **请求体**: ```json { "gitUrl": "https://github.com/user/repo.git", "username": "optional-username", "accessToken": "optional-token", "mavenPath": "optional-maven-path" } ``` - **响应**: ```json { "taskId": "abc12345", "status": "SUCCESS", "buildLog": "...", "jarFiles": [ { "name": "app-1.0.0.jar", "path": "...", "size": 12345 } ], "errorMessage": null } ``` ### 下载 JAR - **URL**: `GET /api/build/download/{taskId}/{fileName}` ## 安全特性 1. **Git URL 验证**: 只允许白名单域名(github.com、gitlab.com 等) 2. **凭证保护**: 敏感信息(用户名、令牌)在日志中被隐藏 3. **命令注入防护**: 使用严格的参数列表执行命令 4. **临时文件清理**: 构建完成后 1 小时自动清理工作目录 5. **路径遍历防护**: 下载接口验证文件名格式 ## 生产环境部署建议 1. **修改 CORS 配置**: 在 `BuildController` 中限制 `origins` 为前端域名 2. **增加超时时间**: 根据项目大小调整 Maven 构建超时 3. **添加认证**: 为 API 接口添加身份验证 4. **资源限制**: 限制并发构建数量和磁盘空间