eliteforge-java-service-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEliteForge Java Service Generator (Maven Archetype)
EliteForge Java服务生成器(Maven原型)
Goal
目标
Create a new EliteForge Java service by running , and perform project build/initialization through project-internal commands.
scripts/generate.pymake通过运行创建新的EliteForge Java服务,并通过项目内部的命令执行项目构建/初始化。
scripts/generate.pymakePreconditions
前置条件
- Require ,
python3, JDK, and network access (for archetype download).make
- 需要、
python3、JDK以及网络访问权限(用于下载原型)。make
Build Command Policy (MUST follow)
构建命令规范(必须遵守)
- In generated project root, use project-internal targets for build/init/verify tasks.
make - Do not run system Maven commands in generated project (for example: ,
mvn clean install).mvn test - If Maven command is explicitly required in generated project, use project wrapper only: .
./mvnw ... - Never replace with system
./mvnwin command examples or execution steps.mvn
- 在生成的项目根目录中,使用项目内部的目标来执行构建/初始化/验证任务。
make - 不要在生成的项目中运行系统级Maven命令(例如:、
mvn clean install)。mvn test - 如果生成的项目中明确需要Maven命令,仅使用项目包装器:。
./mvnw ... - 在命令示例或执行步骤中,绝对不要用系统替换
mvn。./mvnw
Required Inputs (never infer)
必填输入项(禁止推测)
companyNameproductNameserviceName- Validate all three with:
^[a-z0-9]+(-[a-z0-9]+)*$ - If any value is missing or invalid, ask only for missing/invalid fields.
companyNameproductNameserviceName- 使用正则验证这三个参数。
^[a-z0-9]+(-[a-z0-9]+)*$ - 如果任何值缺失或无效,仅询问缺失/无效的字段。
Workflow (every run)
工作流(每次运行)
- Collect and validate required inputs.
- Build command and run script:
python3 scripts/generate.py --company <companyName> --product <productName> --service <serviceName> [--desc "<projectDescription>"] [--tech "<tech stack text>"] [--enable enableX --enable enableY ...]
- Map tech stack to when user provides stack text:
enableXXX- Use .
references/mapping-rules.md - Pass explicit user switches through .
--enable - Use as canonical flag list.
references/enable-flags.md - If uncertain, ask instead of guessing.
- Use
- Verify result:
- Output folder exists:
app-<companyName>-<productName>-<serviceName>/ - exists in that folder.
pom.xml
- Output folder exists:
- Run post-generation consistency checks in project root ():
<artifactId>/- Java package should match expected package prefix (check and
src/main/java).src/test/java - Maven model name should match expected value (check
pom.xml).<name> pom.xmlshould equal expectedartifactId.artifactId- For any mismatch, report expected vs actual and stop.
- Java package should match expected package prefix (check
- Initialize project in root directory () by running
<artifactId>/and require success (exit codemake install):0- Example:
cd app-<companyName>-<productName>-<serviceName> && make install
- Example:
- For build/test/verification after generation, continue using project targets (for example
make,make test) instead of direct Maven commands; if a Maven command is unavoidable, runmake buildonly../mvnw ... - On failure, return exact error and full executed command (including the failed command).
make
- 收集并验证必填输入项。
- 构建命令并运行脚本:
python3 scripts/generate.py --company <companyName> --product <productName> --service <serviceName> [--desc "<projectDescription>"] [--tech "<tech stack text>"] [--enable enableX --enable enableY ...]
- 当用户提供技术栈文本时,将其映射到:
enableXXX- 使用。
references/mapping-rules.md - 通过传递用户明确指定的开关。
--enable - 将作为标准标志列表。
references/enable-flags.md - 如果不确定,询问用户而非自行猜测。
- 使用
- 验证结果:
- 输出文件夹是否存在:
app-<companyName>-<productName>-<serviceName>/ - 该文件夹中是否存在。
pom.xml
- 输出文件夹是否存在:
- 在项目根目录()中执行生成后的一致性检查:
<artifactId>/- Java包路径应与预期的包前缀匹配(检查和
src/main/java)。src/test/java - Maven模型名称应与预期值匹配(检查中的
pom.xml)。<name> - 中的
pom.xml应等于预期的artifactId。artifactId - 若存在任何不匹配,报告预期值与实际值并停止操作。
- Java包路径应与预期的包前缀匹配(检查
- 在根目录()中通过运行
<artifactId>/初始化项目,并要求执行成功(退出码make install):0- 示例:
cd app-<companyName>-<productName>-<serviceName> && make install
- 示例:
- 生成后的构建/测试/验证操作,继续使用项目的目标(例如
make、make test)而非直接使用Maven命令;若必须使用Maven命令,仅运行make build。./mvnw ... - 若执行失败,返回确切错误信息和完整执行命令(包括失败的命令)。
make
Coordinate Rules (script behavior)
坐标规则(脚本行为)
groupId = cn.<companyName(with '-' -> '.')>.<productName(with '-' -> '.')>artifactId = app-<companyName>-<productName>-<serviceName>
groupId = cn.<companyName(将'-'替换为'.')>.<productName(将'-'替换为'.')>artifactId = app-<companyName>-<productName>-<serviceName>
Expected Values For Post-check
检查预期值
expectedGroupId = groupIdexpectedArtifactId = artifactIdexpectedJavaPackagePrefix = <expectedGroupId>.<serviceName(with '-' -> '.')>- (unless user explicitly requires another naming rule)
expectedMavenModelName = expectedArtifactId
expectedGroupId = groupIdexpectedArtifactId = artifactIdexpectedJavaPackagePrefix = <expectedGroupId>.<serviceName(将'-'替换为'.')>- (除非用户明确要求其他命名规则)
expectedMavenModelName = expectedArtifactId
Quick Examples
快速示例
- Minimal:
python3 scripts/generate.py --company cisdigital --product cap --service cache-center --desc "CAP 缓存中心"
- Post-generation init (required):
cd app-cisdigital-cap-cache-center && make install
- Tech + explicit override:
python3 scripts/generate.py --company cisdigital --product cap --service cache-center --tech "mysql redisson lombok mapstruct" --enable enableJacksonDatatypeJsr310
- 最简示例:
python3 scripts/generate.py --company cisdigital --product cap --service cache-center --desc "CAP 缓存中心"
- 生成后初始化(必填):
cd app-cisdigital-cap-cache-center && make install
- 技术栈 + 显式覆盖:
python3 scripts/generate.py --company cisdigital --product cap --service cache-center --tech "mysql redisson lombok mapstruct" --enable enableJacksonDatatypeJsr310