Skip to content

Commit 58c2a06

Browse files
committed
feat: Introduce Scala 3 and Enhance V8 Engine Integration
Actively begin the adoption of Scala 3, with plans for small, non-breaking migrations in the future. Improve V8 Engine implementation by integrating Javet for better performance and stability.
1 parent d1fc4be commit 58c2a06

File tree

16 files changed

+618
-495
lines changed

16 files changed

+618
-495
lines changed

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,37 @@
1212

1313
## Overview
1414

15-
A Modular Plugin Toolkit built on [Fairy Framework](https://github.com/FairyProject/fairy), featuring modular design and leveraging modern Java 21 features.
16-
It provides essential tools and utilities for modern Minecraft plugin development with cross-platform support for Spigot, Paper, and Folia.
15+
A Modular Plugin Toolkit built on [Fairy Framework](https://github.com/FairyProject/fairy), featuring modular design and
16+
leveraging modern Java 21 features.
17+
It provides essential tools and utilities for modern Minecraft plugin development with cross-platform support for
18+
Spigot, Paper, and Folia.
1719

1820
## Core Modules
1921

20-
- [**foundation**](foundation/README.md) - Core foundation module providing essential testing infrastructure, utilities, and base abstractions for all library modules.
22+
- [**foundation**](foundation/README.md) - Core foundation module providing essential testing infrastructure, utilities,
23+
and base abstractions for all library modules.
2124
- [**annotation**](annotation/README.md) - Powerful annotation processing framework with flexible scanning options and
2225
lifecycle management.
23-
- [**aop**](aop/README.md) - Enterprise-grade Aspect-Oriented Programming framework with ClassLoader isolation, providing performance monitoring, thread safety, logging, and exception handling aspects.
26+
- [**aop**](aop/README.md) - Enterprise-grade Aspect-Oriented Programming framework with ClassLoader isolation,
27+
providing performance monitoring, thread safety, logging, and exception handling aspects.
2428
- [**commons**](commons/README.md) - Essential utilities including VarHandle injection, task scheduling, virtual thread
2529
scheduling, JSON operations, and random object generation.
2630
- [**configuration**](configuration/README.md) - Flexible configuration framework built on SimplixStorage with
2731
serialization support.
2832
- [**mongodb**](mongodb/README.md) - Streamlined MongoDB integration with Morphia for efficient data persistence.
2933
- [**cache**](cache/README.md) - Multi-tier caching system integrating Caffeine and Redis, providing comprehensive lock
3034
management and a generic framework for thread-safe resource access.
31-
- [**player**](player/README.md) - Enterprise-grade distributed data management framework building high-performance entity-relationship data layers. Capable of **seamlessly handling thousands of inter-entity** relationship networks and state synchronization.
35+
- [**player**](player/README.md) - Enterprise-grade distributed data management framework building high-performance
36+
entity-relationship data layers. Capable of **seamlessly handling thousands of inter-entity** relationship networks
37+
and state synchronization.
3238
- [**script**](script/README.md) - Powerful, flexible, extensible, and high-performance script execution engine wrapper
3339
that supports `Rhino`, `Nashorn` and `V8` `JavaScript` engines.
3440

3541
- [**experimental**](experimental/README.md) - Some experimental modules that can significantly improve performance, but
3642
may be too complex to use or temporarily unstable.
3743
- [**third-party-schedulers**](experimental/third-party-schedulers/README.md) - Achieves distributed task processing
38-
via gRPC external task schedulers (currently implemented in Rust), enabling large plugin decoupling and performance improvements (for backends
44+
via gRPC external task schedulers (currently implemented in Rust), enabling large plugin decoupling and
45+
performance improvements (for backends
3946
that cannot directly access the Bukkit API). Ideal for machine learning, anti-cheat large data computation,
4047
mathematics, and similar
4148
applications.
@@ -101,15 +108,25 @@ is a Folia fork with many useful optimizations, configurable vanilla features, a
101108

102109
![luminol-mc-logo.png](./luminol-mc-logo.png)
103110

104-
[PromptX](https://github.com/Deepractice/PromptX) is an AI application-native professional capability enhancement system developed by [Deepractice](https://github.com/Deepractice), playing a key role in this project.
111+
[PromptX](https://github.com/Deepractice/PromptX) is an AI application-native professional capability enhancement system
112+
developed by [Deepractice](https://github.com/Deepractice), playing a key role in this project.
105113

106114
![promptx-logo.png](./promptx-logo.png)
107115

108116
## Contributing
109117

110-
We warmly welcome more developers to join our open source project and contribute their strength. Whether it's sharing ideas, creating Issues, or submitting Pull Requests, every contribution is significant!
118+
We warmly welcome more developers to join our open source project and contribute their strength. Whether it's sharing
119+
ideas, creating Issues, or submitting Pull Requests, every contribution is significant!
111120

112-
We are very liberal with our use of AI. You can use any AI you want to write and contribute code, as long as it all works and meets the requirements in [CLAUDE.md](CLAUDE.md) (this is a Chinese document).
121+
We are very liberal with our use of AI. You can use any AI you want to write and contribute code, as long as it all
122+
works and meets the requirements in [CLAUDE.md](CLAUDE.md) (this is a Chinese document).
123+
124+
## Future plans
125+
126+
We are treating this library as a major dependency for keeping our entire server running (LegacyLands Minecraft server),
127+
and we are actively introducing Scala 3 into it. There will be small portions of non-breaking migration to Scala 3 in
128+
the future, leveraging its superior type system, concurrency model, and functional programming capabilities for better
129+
performance and maintainability.
113130

114131
## Star History
115132

README_ZHCN.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ dependencies {
9595

9696
![promptx-logo.png](./promptx-logo.png)
9797

98+
## 贡献
99+
100+
我们热烈欢迎更多开发者加入我们的开源项目,贡献自己的力量。无论是分享想法、创建 Issue,还是提交 Pull Request,每一份贡献都是有意义的!
101+
102+
我们对使用 AI 非常宽容。您可以使用任何 AI 来编写和贡献代码,只要它能正常工作并满足 [CLAUDE.md](CLAUDE.md) 中的要求即可。
103+
104+
## 未来计划
105+
106+
我们将这个库作为维持整个服务器运行(LegacyLands Minecraft 服务器)的主要依赖,并正在积极引入 Scala 3。未来将进行小部分的非破坏性迁移到
107+
Scala 3,利用其优越的类型系统、并发模型和函数式编程能力来获得更好的性能和可维护性。
108+
98109
## Star 历史
99110

100111
[![Star History Chart](https://api.star-history.com/svg?repos=LegacyLands/legacy-lands-library&type=Date)](https://star-history.com/#LegacyLands/legacy-lands-library&Date)

build.gradle.kts

Lines changed: 138 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ plugins {
1313
// Java plugin
1414
id("java-library") apply true
1515

16+
// Scala
17+
id("scala") apply true
18+
1619
// Fairy framework plugin
17-
id("io.fairyproject") version "0.7.13b3-SNAPSHOT" apply false
20+
id("io.fairyproject") version "0.8b1-SNAPSHOT" apply false
1821

1922
// Dependency management plugin
2023
id("io.spring.dependency-management") version "1.1.7"
@@ -23,7 +26,7 @@ plugins {
2326
id("org.jetbrains.kotlin.jvm") version "2.1.21" apply false
2427

2528
// Shadow plugin, provides the ability to shade fairy and other dependencies to compiled jar
26-
id("com.github.johnrengelman.shadow") version "8.1.1" apply true
29+
id("com.gradleup.shadow") version "9.0.0-rc1" apply true
2730

2831
// Lombok
2932
id("io.freefair.lombok") version "8.13.1" apply false
@@ -34,7 +37,7 @@ plugins {
3437

3538
allprojects {
3639
// Apply Shadow plugin
37-
apply(plugin = "com.github.johnrengelman.shadow")
40+
apply(plugin = "com.gradleup.shadow")
3841

3942
// Configure repositories
4043
repositories {
@@ -54,19 +57,36 @@ java {
5457
}
5558
}
5659

60+
dependencies {
61+
compileOnly("org.scala-lang:scala3-library_3:3.7.1")
62+
}
63+
5764
subprojects {
5865
// Apply necessary plugins
5966
apply(plugin = "java-library")
67+
apply(plugin = "scala")
6068
apply(plugin = "io.fairyproject")
6169
apply(plugin = "io.spring.dependency-management")
6270
apply(plugin = "org.jetbrains.kotlin.jvm")
63-
apply(plugin = "com.github.johnrengelman.shadow")
71+
apply(plugin = "com.gradleup.shadow")
6472
apply(plugin = "io.freefair.lombok")
6573

6674
// Configure dependencies
6775
dependencies {
68-
compileOnlyApi("io.fairyproject:bukkit-platform")
76+
val depend by if (project.name != "foundation") {
77+
configurations.compileOnly
78+
} else {
79+
configurations.api
80+
}
81+
6982
api("io.fairyproject:bukkit-bootstrap")
83+
compileOnlyApi("io.fairyproject:bukkit-platform")
84+
compileOnly("org.spigotmc:spigot-api:${properties("spigot.version")}-R0.1-SNAPSHOT")
85+
86+
depend("org.scala-lang:scala3-library_3:3.7.1")
87+
depend("org.apache.commons:commons-lang3:3.17.0")
88+
depend("com.google.guava:guava:33.4.0-jre")
89+
7090
compileOnlyApi("io.fairyproject:mc-animation")
7191
compileOnlyApi("io.fairyproject:bukkit-command")
7292
compileOnlyApi("io.fairyproject:bukkit-gui")
@@ -81,52 +101,119 @@ subprojects {
81101
compileOnlyApi("io.fairyproject:bukkit-timer")
82102
compileOnlyApi("io.fairyproject:bukkit-nbt")
83103
compileOnlyApi("io.fairyproject:mc-tablist")
84-
compileOnly("org.spigotmc:spigot-api:${properties("spigot.version")}-R0.1-SNAPSHOT")
85-
implementation("org.apache.commons:commons-lang3:3.17.0")
86104
}
87105

88106
// Configure ShadowJar task
89107
tasks.withType(ShadowJar::class) {
90108
dependencies {
91109
exclude(dependency("com.google.code.gson:.*:.*"))
110+
111+
// Exclude Kotlin
112+
exclude(dependency("org.jetbrains.kotlin:.*:.*"))
113+
exclude(dependency("org.jetbrains:annotations:.*"))
114+
115+
// Exclude SLF4J
116+
exclude(dependency("org.slf4j:.*:.*"))
117+
118+
// Exclude dependencies that would be relocated to io.fairyproject.libs
119+
exclude(dependency("net.kyori:.*:.*"))
120+
exclude(dependency("com.cryptomorin.xseries:.*:.*"))
121+
exclude(dependency("org.yaml:snakeyaml:.*"))
122+
exclude(dependency("com.github.retrooper:packetevents:.*"))
123+
exclude(dependency("io.github.retrooper:packetevents:.*"))
92124
}
93125

126+
// Exclude all io.fairyproject.libs packages since they exist in fairy lib plugin
127+
exclude("io/fairyproject/libs/**")
128+
94129
// Relocate fairy to avoid plugin conflict
95-
relocate("io.fairyproject.bootstrap", "${properties("package")}.fairy.bootstrap")
130+
val libsPackage = "${properties("package")}.libs"
131+
96132
relocate("net.kyori", "io.fairyproject.libs.kyori")
97133
relocate("com.cryptomorin.xseries", "io.fairyproject.libs.xseries")
98134
relocate("org.yaml.snakeyaml", "io.fairyproject.libs.snakeyaml")
99135
relocate("com.google.gson", "io.fairyproject.libs.gson")
100136
relocate("com.github.retrooper.packetevents", "io.fairyproject.libs.packetevents")
101137
relocate("io.github.retrooper.packetevents", "io.fairyproject.libs.packetevents")
102-
relocate("io.fairyproject.bukkit.menu", "${properties("package")}.fairy.menu")
103138

104139
// Relocate
105-
relocate("de.leonhard.storage", "${properties("package")}.libs.simplixstorage")
106-
relocate("org.reflections", "${properties("package")}.libs.reflections")
107-
relocate("net.wesjd.anvilgui", "${properties("package")}.libs.anvilgui")
140+
relocate("scala", "$libsPackage.scala")
141+
142+
relocate("io.fairyproject.bootstrap", "$libsPackage.io.fairyproject.bootstrap")
143+
relocate("io.fairyproject.bukkit.menu", "$libsPackage.io.fairyproject.bukkit.menu")
144+
145+
relocate("de.leonhard.storage", "$libsPackage.de.leonhard.storage")
146+
relocate("net.wesjd.anvilgui", "$libsPackage.net.wesjd.anvilgui")
108147

109148
archiveClassifier.set("plugin")
110149
mergeServiceFiles()
150+
111151
exclude("META-INF/maven/**")
152+
exclude("**/*.tasty")
153+
154+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
155+
}
156+
157+
// Configure source sets for Scala/Java joint compilation
158+
sourceSets {
159+
main {
160+
java {
161+
setSrcDirs(emptyList<String>())
162+
}
163+
scala {
164+
setSrcDirs(listOf("src/main/java", "src/main/scala"))
165+
}
166+
}
167+
}
168+
169+
// Configure task dependencies and order
170+
tasks.named<JavaCompile>("compileJava") {
171+
enabled = false
172+
}
173+
174+
// Configure Scala compilation to output to classes directory
175+
tasks.named<ScalaCompile>("compileScala") {
176+
// Ensure clean output directory
177+
doFirst {
178+
destinationDirectory.get().asFile.deleteRecursively()
179+
destinationDirectory.get().asFile.mkdirs()
180+
}
112181
}
113182

114183
// Configure sourcesJar task
115184
tasks.register<Jar>("sourcesJar") {
116185
exclude("fairy.json")
117-
dependsOn(tasks.named("shadowJar"))
118-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
119-
from(zipTree(tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().asFile))
186+
// Check if shadowJar task exists before depending on it
187+
if (tasks.names.contains("shadowJar")) {
188+
dependsOn(tasks.named("shadowJar"))
189+
from(zipTree(tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().asFile))
190+
}
120191
from(sourceSets.main.get().allSource)
121192
archiveClassifier.set("sources")
193+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
122194
}
123195

124-
// Disable Javadoc warnings
196+
// Configure Javadoc for Scala/Java mixed projects
125197
tasks.withType<Javadoc> {
198+
// Ensure compilation is done before javadoc
199+
dependsOn(tasks.named("compileScala"))
200+
201+
// Set source to include Java files from Scala source directories
202+
source = fileTree("src/main/java") + fileTree("src/main/scala")
203+
include("**/*.java")
204+
205+
// Use classpath from compileScala to resolve Lombok-generated classes
206+
classpath = sourceSets.main.get().compileClasspath + files(sourceSets.main.get().output)
207+
126208
options {
127209
this as StandardJavadocDocletOptions
128210
addStringOption("Xdoclint:-missing", "-quiet")
211+
addStringOption("Xdoclint:-html", "-quiet")
212+
addStringOption("Xdoclint:-reference", "-quiet")
129213
}
214+
215+
// Disable failOnError for modules with Lombok
216+
isFailOnError = false
130217
}
131218

132219
// Configure javadocJar task
@@ -139,33 +226,64 @@ subprojects {
139226
tasks.register("allJar") {
140227
dependsOn("shadowJar", "sourcesJar", "javadocJar")
141228
}
229+
230+
// After project evaluation, configure shadowJar dependencies
231+
afterEvaluate {
232+
tasks.withType<ShadowJar> {
233+
// Find all project dependencies and make shadowJar depend on their shadowJar tasks
234+
project.configurations.findByName("compileClasspath")?.allDependencies?.forEach { dep ->
235+
if (dep is ProjectDependency) {
236+
val depProject = rootProject.allprojects.find { it.name == dep.name }
237+
if (depProject != null && depProject != project) {
238+
dependsOn(depProject.tasks.named("shadowJar"))
239+
}
240+
}
241+
}
242+
}
243+
}
142244
}
143245

144246
publishing {
145247
if (isGitHubActions) {
146248
publications {
147249
rootProject.subprojects.forEach { subproject ->
148-
create<MavenPublication>("shadow-${subproject.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}") {
250+
create<MavenPublication>(
251+
"shadow-${
252+
subproject.name.replaceFirstChar {
253+
if (it.isLowerCase()) it.titlecase(
254+
Locale.getDefault()
255+
) else it.toString()
256+
}
257+
}"
258+
) {
149259
val shadowJarTask = subproject.tasks.named<ShadowJar>("shadowJar")
150260
artifact(shadowJarTask.get().archiveFile.get())
151261

152262
groupId = group.toString()
153263
artifactId = subproject.name
154-
version = "${properties("version")}-${LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MM-yy-hhmmss"))}"
264+
version = "${properties("version")}-${
265+
LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MM-yy-hhmmss"))
266+
}"
155267
description = ""
156268
pom {
157269
description.set("")
158270
}
159271
}
160272
}
161273
}
274+
162275
// GitHub Packages
163276
repositories {
164277
maven {
165278
url = uri("https://maven.pkg.github.com/LegacyLands/legacy-lands-library/")
166279
credentials {
167-
username = project.findProperty("githubUsername")?.toString() ?: System.getenv("GITHUB_USERNAME")?.toString() ?: error("GitHub username is missing")
168-
password = project.findProperty("githubToken")?.toString() ?: System.getenv("GITHUB_TOKEN")?.toString() ?: error("GitHub token is missing")
280+
username =
281+
project.findProperty("githubUsername")?.toString() ?: System.getenv("GITHUB_USERNAME") ?: error(
282+
"GitHub username is missing"
283+
)
284+
password =
285+
project.findProperty("githubToken")?.toString() ?: System.getenv("GITHUB_TOKEN")
286+
?: error("GitHub token is missing")
169287
}
170288
}
171289
}

0 commit comments

Comments
 (0)