Skip to content

Commit

Permalink
Merge pull request #61 from HQService/version/2-dev
Browse files Browse the repository at this point in the history
Version/2 dev
  • Loading branch information
cccgh5 authored Jan 18, 2025
2 parents e65f47f + 33ab414 commit 16977cc
Show file tree
Hide file tree
Showing 204 changed files with 7,391 additions and 1,765 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Prepare Gradle
uses: gradle/gradle-build-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Prepare JDK17
- name: Prepare JDK21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Prepare Gradle
uses: gradle/gradle-build-action@v2
Expand Down
57 changes: 26 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ HQFramework는 완성도가 높은 의존성 주입 라이브러리 Koin과 연
```kotlin
package kr.hqservice.exampleplugin.listener

@Component
@Listener
class ExampleListener(
private val exampleService: ExampleService,
private val plugin: Plugin
) : HQListener {
@EventHandler
) {
@Subscribe
fun onExampleEvent(event: BukkitExampleEvent) {
exampleService.doAnything(plugin)
}
Expand All @@ -47,15 +47,14 @@ class ExampleListener(
```kotlin
package kr.hqservice.exampleplugin.service

interface ExampleService : HQService {
interface ExampleService {
fun doAnything(plugin: Plugin)
}
```
```kotlin
package kr.hqservice.exampleplugin.service.impl

@Component
@HQSingleton(binds = [ExampleService::class])
@Service
class ExampleServiceImpl : ExampleService {
override fun doAnything(plugin: Plugin) {
println("Hello ${plugin.name}!")
Expand All @@ -78,12 +77,12 @@ Hello ExamplePlugin!
### 복잡한 의존관계에서의 HQComponent
이번에는 여러 계층의 의존관계를 지닌 컴포넌트들로 예시를 들어보겠습니다.
```kotlin
@Component
@Listener
class ExampleListener(
private val exampleService: ExampleService,
private val exampleConfig: ExampleConfig
) : HQListener {
@EventHandler
) {
@Subscribe
fun onExampleEvent(event: BukkitExampleEvent) {
val result = exampleService.printAndReturn()
if (result == exampleConfig.getConfiguratedString()) {
Expand All @@ -93,12 +92,11 @@ class ExampleListener(
}
```
```kotlin
interface ExampleService : HQService { fun printAndReturn(): String }
interface ExampleConfig : ConfigurationSection, HQSimpleComponent { fun getConfiguratedString(): String }
interface ExampleService { fun printAndReturn(): String }
interface ExampleConfig : ConfigurationSection { fun getConfiguratedString(): String }
```
```kotlin
@Component
@HQSingleton(binds = [ExamplePrimaryService::class])
@Service
class ExampleServiceImpl(private val config: ExampleConfig) : ExampleService {
override fun printAndReturn(): String {
val string = config.getConfiguratedString()
Expand All @@ -107,8 +105,7 @@ class ExampleServiceImpl(private val config: ExampleConfig) : ExampleService {
}
}

@Component
@HQSingleton(binds = [ExampleConfig::class])
@Bean
class ExampleConfigImpl(private val plugin: Plugin) : ExampleConfig {
override fun getConfiguratedString(): String {
return plugin.config.getString("string") ?: throw Exception()
Expand Down Expand Up @@ -200,27 +197,25 @@ class DependedExampleComponentHandler : HQComponentHandler<DependedExampleCompon
이럴때는 Qualifier 을 통해 인스턴스를 가져올 수 있습니다.

---
### Named
### Qualifier
Named QualifierKoinQualifier 입니다. HQFrameworkKoinNamed Qualifier를 지원합니다.
아래는 Named Qualifier 사용에 대한 예제입니다.
```kotlin
interface ExampleService : HQService { fun get(): String }
interface ExampleService { fun get(): String }
```
```kotlin
@Component
@HQSingleton(binds = [ExampleService::class])
@Named("item")
@Service
@Qualifier("item")
class ItemService : ExampleService { override fun get(): String { return "item" } }

@Component
@HQSingleton(binds = [ExampleService::class])
@Named("material")
@Service
@Qualifier("material")
class MaterialService : ExampleService { override fun get(): String { return "material" } }
```
```kotlin
@Component
class ExampleItemListener(@Named("item") private val service: ExampleService) : HQListener {
@EventHandler
@Listener
class ExampleItemListener(@Qualifier("item") private val service: ExampleService) {
@Subscribe
fun onEvent(event: BukkitExampleEvent) {
println(service.get())
}
Expand Down Expand Up @@ -252,16 +247,16 @@ data-source:
```kotlin
interface ExampleDataSource : HQDataSource { fun getName(): String }

@Named("mysql")
@Qualifier("mysql")
@Component
@HQSingleton(binds = [ExampleDataSource::class])
@Singleton(binds = [ExampleDataSource::class])
class MySQLDataSource : ExampleDataSource {
override fun getName(): String { return "mysql datasource" }
}

@Named("sqlite")
@Qualifier("sqlite")
@Component
@HQSingleton(binds = [ExampleDataSource::class])
@Singleton(binds = [ExampleDataSource::class])
class SQLiteDataSource : ExampleDataSource {
override fun getName(): String { return "sqlite datasource" }
}
Expand Down Expand Up @@ -423,7 +418,7 @@ class PacketPlayOutChat : Packet<PacketListenerPlayOut> {
아래는 HQFrameworkByteBuddy 를 사용하여 위의 클래스를 저희의 방식으로 정의했을 때의 대한 예제입니다.
```kotlin
data class PacketPlayOutChat(
var a: IChatBaseComponent
var a: IChatBaseComponent,
var b: ChatMessageType
): Packet() {
override fun read(byteBuf: ByteBuf) {
Expand Down
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val shadowPluginVersion = properties.getProperty("shadowVersion")
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:$shadowPluginVersion")
implementation("com.gradleup.shadow:shadow-gradle-plugin:$shadowPluginVersion")
api(gradleApi())
}

Expand Down
5 changes: 5 additions & 0 deletions build-logic/src/main/kotlin/RuntimeDependencyRelocator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class RelocatedRuntimeScope(
return dependencyHandler.add("runtimeOnly", provider)
}

fun api(provider: Provider<MinimalExternalModuleDependency>): Dependency? {
relocateDependency(provider.get().group!!)
return dependencyHandler.add("api", provider)
}

fun implementation(provider: Provider<MinimalExternalModuleDependency>): Dependency? {
relocateDependency(provider.get().group!!)
return dependencyHandler.add("implementation", provider)
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/hqframework.shadow.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
java
id("com.github.johnrengelman.shadow")
id("com.gradleup.shadow")
}

tasks.shadowJar {
Expand Down
23 changes: 13 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@ kotlin.code.style=official

projectName=HQFramework
projectGroup=kr.hqservice
projectVersion=1.0.2-SNAPSHOT
projectVersion=2.0.1-SNAPSHOT
projectAuthors=vjh0107, cccgh5
projectUrl=https://github.com/HQService/HQFramework

kotlinVersion=1.7.21
kotlinVersion=1.9.24
spigotVersion=1.20.1-R0.1-SNAPSHOT
bungeecordVersion=1.19-R0.1-SNAPSHOT
velocityVersion=3.2.0-SNAPSHOT
velocityVersion=3.3.0-SNAPSHOT
paperWeightVersion=1.7.2

# https://github.com/PaperMC/Folia
foliaVersion=1.20.1-R0.1-SNAPSHOT

# https://github.com/InsertKoinIO/koin
koinVersion=3.3.3
koinVersion=3.6.0-Beta4
# https://github.com/JetBrains/Exposed
exposedVersion=0.41.1
exposedVersion=0.46.0
# https://github.com/Kotlin/kotlinx.coroutines/
coroutinesVersion=1.6.4
coroutinesVersion=1.8.1
# https://github.com/Kotlin/kotlinx.serialization
serializationVersion=1.4.1
serializationVersion=1.7.0
# https://github.com/brettwooldridge/HikariCP
hikariCPVersion=5.0.1
# https://github.com/xerial/sqlite-jdbc
sqliteVersion=3.41.2.1
sqliteVersion=3.47.2.0
# https://github.com/mockk/mockk
mockKVersion=1.13.4
# https://github.com/MockBukkit/MockBukkit
mockBukkitVersion=2.29.0
# https://github.com/mysql/mysql-connector-j
mysqlConnectorVersion=8.0.33
mysqlConnectorVersion=9.1.0
# https://github.com/junit-team/junit5
jUnitVersion=5.9.3
# https://github.com/johnrengelman/shadow
shadowVersion=8.1.1
shadowVersion=8.3.0
# https://github.com/netty/netty
nettyVersion=4.1.24.Final
# https://github.com/google/guava
Expand All @@ -54,3 +55,5 @@ gsonVersion=2.10
AdventureTextVersion=4.17.0

h2Version=2.2.224

bStatsVersion=3.0.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
41 changes: 28 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Loading

0 comments on commit 16977cc

Please sign in to comment.