/
githubmirror
/
halo
Обзор
Документация
Войти
/
githubmirror
/
halo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
application/build.gradle
327 строк
11 KB
Ryan Wang
Add AI Foundation preset plugin (#10204)
05 авг 2026, 07:19
Не верифицирован
05 авг 2026, 07:19
57a5416
Код
Авторство
О чём код?
import de.undercouch.gradle.tasks.download.Download import groovy.json.JsonOutput import org.gradle.crypto.checksum.Checksum import org.springframework.boot.gradle.tasks.bundling.BootBuildImage import org.springframework.boot.gradle.tasks.bundling.BootJar import org.springframework.util.StringUtils plugins { id 'java' id 'idea' id 'jacoco' alias(libs.plugins.spring.boot) alias(libs.plugins.spring.dependency.management) alias(libs.plugins.git.properties) alias(libs.plugins.undercouch.download) alias(libs.plugins.lombok) alias(libs.plugins.checksum) alias(libs.plugins.springdoc.openapi) alias(libs.plugins.versions) alias(libs.plugins.spotless) } group = 'run.halo.app' tasks.withType(JavaCompile).configureEach { options.release = 21 options.encoding = 'UTF-8' } java { toolchain { languageVersion = JavaLanguageVersion.of(21) } } idea { module { resourceDirs += file("../ui/build/dist/") } } repositories { mavenCentral() flatDir { dir layout.projectDirectory.dir('libs') } } configurations { compileOnly { extendsFrom annotationProcessor } } springBoot { buildInfo { properties { artifact = 'halo' name = 'halo' } } } bootJar { archiveBaseName = 'halo' manifest { attributes 'Implementation-Title': 'Halo Application', 'Implementation-Vendor': 'Halo OSS Team' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE } gitProperties { dotGitDirectory = layout.settingsDirectory.dir('.git') } tasks.named('jar') { enabled = false } dependencies { implementation project(':api') implementation libs.r2dbc.migrate.starter // Fix https://github.com/halo-dev/halo/issues/7289 // Build from https://github.com/halo-dev/thymeleaf/commit/d23498ea297059deff04ba8c3578de59c73ccf03 runtimeOnly ':thymeleaf:3.1.3.RELEASE' runtimeOnly ':thymeleaf-spring6:3.1.3.RELEASE' annotationProcessor platform(project(':platform:application')) annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" annotationProcessor "org.springframework:spring-context-indexer" testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-webtestclient' testImplementation 'org.springframework.security:spring-security-test' testImplementation 'io.projectreactor:reactor-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' annotationProcessor 'com.github.therapi:therapi-runtime-javadoc-scribe' // webjars runtimeOnly 'org.webjars.npm:jsencrypt:3.5.4' runtimeOnly 'org.webjars.npm:normalize.css:8.0.1' } tasks.register('createChecksums', Checksum) { dependsOn tasks.named('bootJar') inputFiles.setFrom(layout.buildDirectory.files('libs')) outputDirectory = layout.buildDirectory.dir("libs") checksumAlgorithm = Checksum.Algorithm.SHA256 } tasks.register('copyUiDist', Copy) { from project(':ui').layout.buildDirectory.dir('dist') into layout.buildDirectory.dir('resources/main') mustRunAfter ':ui:doBuild' } tasks.named('classes') { dependsOn tasks.named('copyUiDist') mustRunAfter tasks.named('downloadPluginPresets') } tasks.named('build') { dependsOn tasks.named('createChecksums') } tasks.named('test', Test) { useJUnitPlatform() maxHeapSize = '1G' finalizedBy jacocoTestReport } tasks.named('jacocoTestReport', JacocoReport) { reports { xml.required = true html.required = false } } tasks.register('downloadPluginPresets', Download) { def presetPlugins = [ [ url : 'https://github.com/halo-dev/plugin-comment-widget/releases/download/v3.1.2/plugin-comment-widget-3.1.2.jar', filename : 'plugin-comment-widget.jar', autoEnable: true, ], [ url : 'https://github.com/halo-dev/plugin-search-widget/releases/download/v1.7.1/plugin-search-widget-1.7.1.jar', filename : 'plugin-search-widget.jar', autoEnable: true, ], [ url : 'https://github.com/halo-dev/plugin-sitemap/releases/download/v1.3.0/plugin-sitemap-1.3.0.jar', filename : 'plugin-sitemap.jar', autoEnable: true, ], [ url : 'https://github.com/halo-dev/plugin-feed/releases/download/v1.5.0/plugin-feed-1.5.0.jar', filename : 'plugin-feed.jar', autoEnable: true, ], [ url : 'https://github.com/halo-sigs/plugin-shiki/releases/download/v1.3.2/plugin-shiki-1.3.2.jar', filename : 'plugin-shiki.jar', autoEnable: true, ], [ url : 'https://github.com/halo-sigs/plugin-editor-hyperlink-card/releases/download/v1.9.1/plugin-editor-hyperlink-card-1.9.1.jar', filename : 'plugin-editor-hyperlink-card.jar', autoEnable: true, ], [ url : 'https://github.com/halo-dev/plugin-ai-foundation/releases/download/v1.0.0/plugin-ai-foundation-1.0.0.jar', filename : 'plugin-ai-foundation.jar', autoEnable: true, ], // Currently, plugin-app-store is not open source, so we need to download it from the official website. // Please see https://github.com/halo-dev/plugin-app-store/issues/55 // https://www.halo.run/store/apps/app-VYJbF/releases/app-release-qafgml3o [ url : 'https://www.halo.run/store/apps/app-VYJbF/releases/download/app-release-k0bgjukb/assets/app-release-k0bgjukb-aizf1wnc', filename : 'appstore.jar', autoEnable: true, ], ] def presetPluginUrls = presetPlugins.collectEntries { [it.url, it.filename] } def presetPluginsDest = layout.buildDirectory.dir('resources/main/presets/plugins') src presetPlugins*.url dest presetPluginsDest eachFile { f -> f.name = presetPluginUrls[f.sourceURL.toString()] } doLast { def presetOptions = presetPlugins.collectEntries { [(it.filename): [autoEnable: it.autoEnable]] } presetPluginsDest.get().file('presets.json').asFile.text = JsonOutput.prettyPrint(JsonOutput.toJson(presetOptions)) } } openApi { outputDir = file("$rootDir/api-docs/openapi/v3_0") waitTimeInSeconds = 60 groupedApiMappings = [ 'http://localhost:8091/v3/api-docs/apis_aggregated.api_v1alpha1': 'aggregated.json', 'http://localhost:8091/v3/api-docs/apis_public.api_v1alpha1' : 'apis_public.api_v1alpha1.json', 'http://localhost:8091/v3/api-docs/apis_console.api_v1alpha1' : 'apis_console.api_v1alpha1.json', 'http://localhost:8091/v3/api-docs/apis_uc.api_v1alpha1' : 'apis_uc.api_v1alpha1.json', 'http://localhost:8091/v3/api-docs/apis_extension.api_v1alpha1' : 'apis_extension.api_v1alpha1.json', ] customBootRun { args = [ '--server.port=8091', '--spring.profiles.active=doc', "--halo.work-dir=${layout.buildDirectory.get()}/tmp/workdir-for-generating-apidocs" ] } } tasks.named('forkedSpringBootRun') { dependsOn ':api:jar' } tasks.named('generateOpenApiDocs') { notCompatibleWithConfigurationCache( 'Task generates OpenAPI docs from a running server and is not compatible with configuration cache' ) outputs.upToDateWhen { false } } tasks.named('forkedSpringBootRun') { notCompatibleWithConfigurationCache( 'JavaExecFork holds references to Task objects (OpenApiGeneratorTask, BootRun), which are not serializable' ) } tasks.named('forkedSpringBootStop') { notCompatibleWithConfigurationCache( 'ExecJoin holds a reference to JavaExecFork (a Task), which is not serializable' ) } def branchProvider = providers.exec { commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' } .standardOutput .asText .map { it.trim().replaceAll("/", "-") } def abbreviatedIdProvider = providers.exec { commandLine 'git', 'rev-parse', '--short', 'HEAD' } .standardOutput .asText .map { it.trim() } def isRelease = project.hasProperty('release') && Boolean.parseBoolean(project.property('release').toString()) def repoProvider = providers.provider { isRelease ? 'halo' : 'halo-dev' } def tagProvider = providers.provider { isRelease ? "${project.version}-cnb" : abbreviatedIdProvider.map { "sha-${it}-cnb" }.get() } def branchTagProvider = branchProvider.map { "${it}-cnb" } def archiveFileProvider = tasks.named('bootJar', BootJar).<RegularFile> flatMap { it.archiveFile } tasks.register('publishToGhcr', BootBuildImage) { def ghcrUserProvider = providers.environmentVariable('GHCR_USERNAME') def ghcrTokenProvider = providers.environmentVariable('GHCR_TOKEN') group = 'publishing' description = 'Build and publish the Docker image to GitHub Container Registry.' imageName = "ghcr.io/halo-dev/${repoProvider.get()}:${tagProvider.get()}" publish = ghcrTokenProvider.map { StringUtils.hasText(it) }.orElse(false) if (!isRelease) { tags.add("ghcr.io/halo-dev/${repoProvider.get()}:${branchTagProvider.get()}") } docker { publishRegistry { username = ghcrUserProvider password = ghcrTokenProvider } } archiveFile.set(archiveFileProvider) } tasks.register('publishToDockerHub', BootBuildImage) { def dockerUserProvider = providers.environmentVariable('DOCKER_USERNAME') def dockerTokenProvider = providers.environmentVariable('DOCKER_TOKEN') group = 'publishing' description = 'Build and publish the Docker image to Docker Hub.' imageName = "halohub/${repoProvider.get()}:${tagProvider.get()}" publish = dockerTokenProvider.map { StringUtils.hasText(it) }.orElse(false) if (!isRelease) { tags.add("halohub/${repoProvider.get()}:${branchTagProvider.get()}") } docker { publishRegistry { username = dockerUserProvider password = dockerTokenProvider } } archiveFile.set(archiveFileProvider) } tasks.register('publishToAllRegistries') { group = 'publishing' description = 'Build and publish the Docker image to all configured registries.' dependsOn tasks.named('publishToGhcr'), tasks.named('publishToDockerHub') } spotless { java { palantirJavaFormat("2.90.0").formatJavadoc(true) } sql { target 'src/**/*.sql' dbeaver() } format 'webResources', { target 'src/main/resources/templates/**/*.html', 'src/main/resources/static/styles/**/*.css', 'src/main/resources/static/js/**/*.js' prettier().config(['tabWidth': 2, 'printWidth': 120]) } }