eliteforge-java-service-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EliteForge Java Service Generator (Maven Archetype)

EliteForge Java服务生成器(Maven原型)

Goal

目标

Create a new EliteForge Java service by running
scripts/generate.py
, and perform project build/initialization through project-internal
make
commands.
通过运行
scripts/generate.py
创建新的EliteForge Java服务,并通过项目内部的
make
命令执行项目构建/初始化。

Preconditions

前置条件

  • Require
    python3
    ,
    make
    , JDK, and network access (for archetype download).
  • 需要
    python3
    make
    、JDK以及网络访问权限(用于下载原型)。

Build Command Policy (MUST follow)

构建命令规范(必须遵守)

  • In generated project root, use project-internal
    make
    targets for build/init/verify tasks.
  • 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
    ./mvnw
    with system
    mvn
    in command examples or execution steps.
  • 在生成的项目根目录中,使用项目内部的
    make
    目标来执行构建/初始化/验证任务。
  • 不要在生成的项目中运行系统级Maven命令(例如:
    mvn clean install
    mvn test
    )。
  • 如果生成的项目中明确需要Maven命令,仅使用项目包装器:
    ./mvnw ...
  • 在命令示例或执行步骤中,绝对不要用系统
    mvn
    替换
    ./mvnw

Required Inputs (never infer)

必填输入项(禁止推测)

  • companyName
  • productName
  • serviceName
  • Validate all three with:
    ^[a-z0-9]+(-[a-z0-9]+)*$
  • If any value is missing or invalid, ask only for missing/invalid fields.
  • companyName
  • productName
  • serviceName
  • 使用正则
    ^[a-z0-9]+(-[a-z0-9]+)*$
    验证这三个参数。
  • 如果任何值缺失或无效,仅询问缺失/无效的字段。

Workflow (every run)

工作流(每次运行)

  1. Collect and validate required inputs.
  2. 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 ...]
  3. Map tech stack to
    enableXXX
    when user provides stack text:
    • Use
      references/mapping-rules.md
      .
    • Pass explicit user switches through
      --enable
      .
    • Use
      references/enable-flags.md
      as canonical flag list.
    • If uncertain, ask instead of guessing.
  4. Verify result:
    • Output folder exists:
      app-<companyName>-<productName>-<serviceName>/
    • pom.xml
      exists in that folder.
  5. Run post-generation consistency checks in project root (
    <artifactId>/
    ):
    • Java package should match expected package prefix (check
      src/main/java
      and
      src/test/java
      ).
    • Maven model name should match expected value (check
      pom.xml
      <name>
      ).
    • pom.xml
      artifactId
      should equal expected
      artifactId
      .
    • For any mismatch, report expected vs actual and stop.
  6. Initialize project in root directory (
    <artifactId>/
    ) by running
    make install
    and require success (exit code
    0
    ):
    • Example:
      cd app-<companyName>-<productName>-<serviceName> && make install
  7. For build/test/verification after generation, continue using project
    make
    targets (for example
    make test
    ,
    make build
    ) instead of direct Maven commands; if a Maven command is unavoidable, run
    ./mvnw ...
    only.
  8. On failure, return exact error and full executed command (including the failed
    make
    command).
  1. 收集并验证必填输入项。
  2. 构建命令并运行脚本:
    • python3 scripts/generate.py --company <companyName> --product <productName> --service <serviceName> [--desc "<projectDescription>"] [--tech "<tech stack text>"] [--enable enableX --enable enableY ...]
  3. 当用户提供技术栈文本时,将其映射到
    enableXXX
    • 使用
      references/mapping-rules.md
    • 通过
      --enable
      传递用户明确指定的开关。
    • references/enable-flags.md
      作为标准标志列表。
    • 如果不确定,询问用户而非自行猜测。
  4. 验证结果:
    • 输出文件夹是否存在:
      app-<companyName>-<productName>-<serviceName>/
    • 该文件夹中是否存在
      pom.xml
  5. 在项目根目录(
    <artifactId>/
    )中执行生成后的一致性检查:
    • Java包路径应与预期的包前缀匹配(检查
      src/main/java
      src/test/java
      )。
    • Maven模型名称应与预期值匹配(检查
      pom.xml
      中的
      <name>
      )。
    • pom.xml
      中的
      artifactId
      应等于预期的
      artifactId
    • 若存在任何不匹配,报告预期值与实际值并停止操作。
  6. 在根目录(
    <artifactId>/
    )中通过运行
    make install
    初始化项目,并要求执行成功(退出码
    0
    ):
    • 示例:
      cd app-<companyName>-<productName>-<serviceName> && make install
  7. 生成后的构建/测试/验证操作,继续使用项目的
    make
    目标(例如
    make test
    make build
    )而非直接使用Maven命令;若必须使用Maven命令,仅运行
    ./mvnw ...
  8. 若执行失败,返回确切错误信息和完整执行命令(包括失败的
    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 = groupId
  • expectedArtifactId = artifactId
  • expectedJavaPackagePrefix = <expectedGroupId>.<serviceName(with '-' -> '.')>
  • expectedMavenModelName = expectedArtifactId
    (unless user explicitly requires another naming rule)
  • expectedGroupId = groupId
  • expectedArtifactId = artifactId
  • expectedJavaPackagePrefix = <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