Skip to content

Commit

Permalink
Merge pull request #164 from dragove/dragove
Browse files Browse the repository at this point in the history
修改gradle构建脚本为kotlin,更新依赖版本,修正弃用api
  • Loading branch information
dragove authored Feb 16, 2024
2 parents 81da68d + 9221f13 commit b54e26a
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 168 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
major-identifier: "breaking:"
minor-identifier: "feature:"

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
distribution: temurin
java-version: 21

# - name: Startup Mongodb
# uses: supercharge/[email protected]
Expand All @@ -52,11 +52,11 @@ jobs:

- name: Remove aliyun maven mirror
run: |
sed -i '/maven {/,+2d' build.gradle
sed -i '/maven(url/d' build.gradle.kts
- name: Set versions
run: |
sed -i "s/^version.*$/version '${{ steps.version.outputs.version }}'/g" build.gradle
sed -i "s/^version.*$/version = \"${{ steps.version.outputs.version }}\"/g" build.gradle.kts
sed -i 's/"packageVersion.*,/"packageVersion": "${{ steps.version.outputs.version }}",/g' client-config/cpp.json
sed -i 's/"packageVersion.*,/"packageVersion": "${{ steps.version.outputs.version }}",/g' client-config/csharp-netcore.json
sed -i 's/"packageVersion.*,/"packageVersion": "${{ steps.version.outputs.version }}",/g' client-config/rust.json
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amazoncorretto:17-alpine as runner
FROM amazoncorretto:21-alpine as runner
WORKDIR /app
COPY ./build/libs/MaaBackendCenter*.jar /MaaBackendCenter.jar
EXPOSE 7000-9000
Expand Down
154 changes: 0 additions & 154 deletions build.gradle

This file was deleted.

159 changes: 159 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
id("org.springframework.boot") version "3.2.2"
id("io.spring.dependency-management") version "1.1.4"
id("org.springdoc.openapi-gradle-plugin") version "1.8.0"
// id("org.graalvm.buildtools.native") version "0.9.28"
id("org.hidetake.swagger.generator") version "2.19.2"
id("com.gorylenko.gradle-git-properties") version "2.4.1"

kotlin("jvm") version "1.9.22"
kotlin("plugin.spring") version "1.9.22"
kotlin("kapt") version "1.9.22"
}

group = "plus.maa"
version = "2.0"

java {
sourceCompatibility = JavaVersion.VERSION_21
}

repositories {
maven(url = "https://maven.aliyun.com/repository/public/")
maven(url = "https://maven.aliyun.com/repository/spring/")
mavenCentral()
}


dependencies {
val hutoolVersion = "5.8.26"
val mapstructVersion = "1.5.5.Final"

kapt("org.springframework.boot:spring-boot-configuration-processor")

testImplementation("io.mockk:mockk:1.13.9")
testImplementation("org.springframework.boot:spring-boot-starter-test")

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-data-redis")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-cache")
// springdoc 相关依赖没有被自动管理,必须保留版本号,
// springdoc-openapi-starter-webmvc-ui 升级到 2.3.0 以及以上版本会导致 therapi 不兼容
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
implementation("com.github.therapi:therapi-runtime-javadoc:0.15.0")
kapt("com.github.therapi:therapi-runtime-javadoc-scribe:0.15.0")

// kotlin
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")

// kotlin-logging
implementation("io.github.oshai:kotlin-logging-jvm:6.0.3")

implementation("com.squareup.okhttp3:okhttp:4.12.0")
// hutool 的邮箱工具类依赖
implementation("com.sun.mail:javax.mail:1.6.2")
implementation("cn.hutool:hutool-extra:$hutoolVersion")
implementation("cn.hutool:hutool-jwt:$hutoolVersion")
implementation("cn.hutool:hutool-dfa:$hutoolVersion")

// mapstruct
implementation("org.mapstruct:mapstruct:${mapstructVersion}")
kapt("org.mapstruct:mapstruct-processor:${mapstructVersion}")

implementation("org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r")
implementation("org.eclipse.jgit:org.eclipse.jgit.ssh.apache.agent:6.8.0.202311291450-r")
implementation("org.freemarker:freemarker:2.3.32")
implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
implementation("com.github.erosb:everit-json-schema:1.14.4") {
exclude("commons-logging", "commons-logging")
}
implementation("com.google.guava:guava:32.1.3-jre")
implementation("org.aspectj:aspectjweaver:1.9.21")

implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")

swaggerCodegen("org.openapitools:openapi-generator-cli:7.2.0")

}

kapt {
keepJavacAnnotationProcessors = true
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "21"
}
}

tasks.withType<Test> {
useJUnitPlatform()
}


val swaggerOutputDir = layout.buildDirectory.dir("docs")
val swaggerOutputName = "swagger.json"


openApi {
apiDocsUrl = "http://localhost:8848/v3/api-docs"
outputDir = swaggerOutputDir
outputFileName = swaggerOutputName
waitTimeInSeconds = 30
}

swaggerSources {
val clientDir = layout.buildDirectory.dir("clients").get()
val swaggerOutputFile = swaggerOutputDir.get().file(swaggerOutputName)
create("TsFetch") {
setInputFile(file(swaggerOutputFile))
code(closureOf<GenerateSwaggerCode> {
language = "typescript-fetch"
configFile = file("client-config/ts-fetch.json")
// templateDir = file('client-config/typescript-fetch')
rawOptions = listOf("-e", "mustache")
outputDir = file(clientDir.dir("ts-fetch-client"))
})
}
create("CSharp") {
setInputFile(file(swaggerOutputFile))
code(closureOf<GenerateSwaggerCode> {
language = "csharp"
configFile = file("client-config/csharp-netcore.json")
outputDir = file(clientDir.dir("csharp-client"))
// rawOptions = listOf("--type-mappings", "binary=System.IO.Stream")
})
}
create("Cpp") {
setInputFile(file(swaggerOutputFile))
code(closureOf<GenerateSwaggerCode> {
language = "cpp-restsdk"
configFile = file("client-config/cpp.json")
outputDir = file(clientDir.dir("cpp-client"))
})
}
create("Rust") {
setInputFile(file(swaggerOutputFile))
code(closureOf<GenerateSwaggerCode> {
language = "rust"
configFile = file("client-config/rust.json")
outputDir = file(clientDir.dir("rust-client"))
})
}
}


gitProperties {
failOnNoGitDirectory = false
keys = listOf("git.branch", "git.commit.id", "git.commit.id.abbrev", "git.commit.time")
}
2 changes: 1 addition & 1 deletion dev-docker/test-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
networks:
- maa
maa_backend:
image: dragove/maa-backend-center:latest
image: ghcr.io/maaassistantarknights/maabackendcenter:dev
container_name: maa-backend
environment:
- SPRING_DATA_MONGODB_URI=mongodb://mongo/MaaBackend
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "MaaBackendCenter"
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HttpInterfaceConfig {
headers.add("X-GitHub-Api-Version", "2022-11-28")
}
.build()
return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client))
return HttpServiceProxyFactory.builderFor(WebClientAdapter.create(client))
.build()
.createClient(GithubRepository::class.java)
}
Expand Down
Loading

0 comments on commit b54e26a

Please sign in to comment.