Skip to content

Commit

Permalink
chore: 尝试增加graalvm编译
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Jun 25, 2024
1 parent d5fd869 commit af4029b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
45 changes: 40 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: build
on:
push:
branches:
- dev
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -22,4 +19,42 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Subit ForumBackendKtor Artifact
path: build/libs/*.jar
path: build/libs/*.jar
build-linux-native:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 安装 GraalVM
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm'
# 执行 Gradle Native 构建
- name: Build with Gradle Native
run: ./gradlew nativeBuild
# 上传构建产物
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Subit ForumBackendKtor Linux Artifact
path: build/native/*
build-windows-native:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# 安装 GraalVM
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm'
# 执行 Gradle Native 构建
- name: Build with Gradle Native
run: ./gradlew nativeBuild
# 上传构建产物
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Subit ForumBackendKtor Windows Artifact
path: build/native/*
17 changes: 17 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ plugins {
kotlin("jvm") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
id("io.ktor.plugin") version "2.3.11"
// graalvm
id("org.graalvm.buildtools.native") version "0.10.2"
}

group = "subit"
Expand Down Expand Up @@ -119,4 +121,19 @@ ktor {
allowZip64 = true
archiveFileName = "ForumBackendKtor-${version}-all.jar"
}
}

graalvmNative {
binaries {
named("main") {
mainClass.set("subit.ForumBackendKt")
buildArgs.add("-O4")
}
named("test") {
buildArgs.add("-O0")
}
}
binaries.all {
buildArgs.add("--verbose")
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/subit/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ConfigLoader<T: Any> private constructor(
@Suppress("unused", "MemberVisibilityCanBePrivate")
companion object
{
private val logger = ForumLogger.getLogger()
private val logger by lazy { ForumLogger.getLogger() }
fun init() // 初始化所有配置
{
apiDocsConfig
Expand Down

0 comments on commit af4029b

Please sign in to comment.