- build.gradle: processUiResources 输出目录 console/ -> ui/(目标 Halo >=2.25.0 官方规范位置), doFirst 同时清理旧构建残留的 console/ 目录;vite.config.ts 注释同步 - plugin.yaml: 新增 spec.logo(logo.svg)/homepage/repo/issues/author.website 与 license.url, logo.svg 以相对路径随包内置(官方插件同款方式) - 已验证: ./gradlew check 全绿(后端 270 + UI 69),clean build -Pversion=0.1.0 三处版本一致(JAR 文件名/plugin.yaml spec.version/Manifest Implementation-Version 均 0.1.0), ui-plugin.json 声明的入口与样式均存在于 JAR 内
109 lines
3.9 KiB
Groovy
109 lines
3.9 KiB
Groovy
plugins {
|
||
id 'java'
|
||
id 'io.freefair.lombok' version '9.2.0'
|
||
id "run.halo.plugin.devtools" version "0.8.0"
|
||
}
|
||
|
||
group = 'run.halo.operationaudit'
|
||
|
||
repositories {
|
||
mavenCentral()
|
||
}
|
||
|
||
dependencies {
|
||
implementation platform('run.halo.tools.platform:plugin:2.26.0')
|
||
compileOnly 'run.halo.app:api'
|
||
|
||
testImplementation 'run.halo.app:api'
|
||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||
testImplementation 'io.projectreactor:reactor-test'
|
||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||
}
|
||
|
||
java {
|
||
toolchain {
|
||
languageVersion = JavaLanguageVersion.of(21)
|
||
}
|
||
}
|
||
|
||
tasks.withType(JavaCompile).configureEach {
|
||
options.encoding = 'UTF-8'
|
||
options.release = 21
|
||
}
|
||
|
||
test {
|
||
useJUnitPlatform()
|
||
testLogging {
|
||
events 'passed', 'skipped', 'failed'
|
||
}
|
||
}
|
||
|
||
// 将 ui 子项目构建产物打包进插件 jar 的 ui/ 目录(Console 前端入口由 ui-plugin.json 清单声明)。
|
||
// 目标 Halo >=2.25.0 时 ui/ 是官方规范输出位置;console/ 为旧项目兼容回退,本插件不再使用。
|
||
tasks.register('processUiResources', Copy) {
|
||
from project(':ui').layout.buildDirectory.dir('dist')
|
||
into layout.buildDirectory.dir('resources/main/ui')
|
||
dependsOn project(':ui').tasks.named('assemble')
|
||
shouldRunAfter tasks.named('processResources')
|
||
// 前端产物带 hash 文件名,先清空目标目录避免历史版本残留进 jar;
|
||
// 同时清掉旧构建可能残留的 console/ 目录,防止过期产物被打进 jar
|
||
doFirst {
|
||
delete layout.buildDirectory.dir('resources/main/ui')
|
||
delete layout.buildDirectory.dir('resources/main/console')
|
||
}
|
||
}
|
||
|
||
tasks.named('classes') {
|
||
dependsOn tasks.named('processUiResources')
|
||
}
|
||
|
||
tasks.named('generatePluginComponentsIdx') {
|
||
notCompatibleWithConfigurationCache('This task invokes "Task.project" at execution time, which is not supported with configuration cache.')
|
||
}
|
||
|
||
halo {
|
||
version = '2.26.1'
|
||
}
|
||
|
||
// API 客户端生成(官方检查清单第 2 条):UI 的 TS 类型与请求方法一律由
|
||
// generateApiClient 任务生成,禁止手写。管线两步:
|
||
// 1) ./gradlew generateOpenApiDocs —— 从运行中的 Halo(Docker haloServer 或
|
||
// useExistingServer 指向的实例)抓取 /v3/api-docs/extensionApis,按 groupingRules
|
||
// 过滤插件路径,落盘到 openApi.outputDir(每次生成先清空,须为专属目录);
|
||
// 2) ./gradlew generateApiClient —— 读取上一步的规范 JSON,产出 TS 客户端到
|
||
// generator.outputDir(同样先清空;产物入库,UI 经 ui/src/api 封装层调用)。
|
||
haloPlugin {
|
||
openApi {
|
||
// 规范 JSON 落盘目录(generateOpenApiDocs 产物 / generateApiClient 输入;
|
||
// 每次生成先清空,须为专属目录,位于 build/ 下不入库)
|
||
outputDir = file("${projectDir}/build/openapi")
|
||
// 仅覆盖插件自有子资源端点(/-/query、/-/export、/-/test);
|
||
// AuditLog 模型类型经响应 schema 引用一并生成
|
||
groupingRules {
|
||
extensionApis {
|
||
displayName = 'Operation Audit Extension API'
|
||
pathsToMatch = [
|
||
'/apis/audit.guichumo.com/v1alpha1/auditlogs/-/**',
|
||
'/apis/audit.guichumo.com/v1alpha1/alerts/-/**',
|
||
]
|
||
}
|
||
}
|
||
groupedApiMappings = [
|
||
'/v3/api-docs/extensionApis': 'extensionApis.json'
|
||
]
|
||
generator {
|
||
outputDir = file("${projectDir}/ui/src/api/generated")
|
||
additionalProperties = [
|
||
useES6 : 'true',
|
||
useSingleRequestParameter : 'true',
|
||
withSeparateModelsAndApi : 'true',
|
||
apiPackage : 'api',
|
||
modelPackage : 'models',
|
||
]
|
||
typeMappings = [
|
||
set: 'Array'
|
||
]
|
||
}
|
||
}
|
||
}
|