English | 简体中文
Medal-core is fully developed by Kotlin, compatible with Kotlin Multiplatform, with rich extension functions and Kotlin-DSL, supports flexible policy configuration, and is compatible with IOS/Android and packet delivery of various channels.
Medal-core is a unified core library for packet DSL, build, modify, delivery, and post-processing, and completes all processing of packets in the fastest and most efficient way.
- PacketBuiltIn:The core library has a built-in structure for most of the packets, allowing for rapid packet building
- Self-implementation policy configuration resolution:Custom JSON policy configuration, Kotlin-DSL configuration, and dynamic policy configuration are supported
- MultiPlatformSupport:It supports IOS/Android and data packet delivery from various channels, which is easy to set up and easy to use
- AbundantExtensionFunctions:A large number of extension functions are supported to facilitate the rapid construction of data packets
- BuiltInSQLite:In the future, built-in SQLite will be supported to support the construction and operation of user databases
Here's a simple example of using Medal-core, showing how to use Medal-core to quickly process packets
suspend fun main() {
latestVersion = getLatestVersion()
platformManager.switchToAndroid(Channel.Official)
val user = User(
userId = primitive { 12345678 },
password = "medal-test-password"
)
buildStrategy {
version = 1
description = "Android - Get user credentials"
packet {
i = "V202"
retry = 4
ext("sk") { "sk" }
ext("ui") { "ui" }
onSuccess { true }
}
}.execute(user) {
println("Response: ${responses["V202"]}")
println("Val sk: ${variables["sk"]}")
println("Val ui: ${variables["ui"]}")
}
}
suspend fun main() {
latestVersion = getLatestVersion()
platformManager.switchToAndroid(Channel.Official)
val user = User(
userId = primitive { 12345678 },
password = "medal-test-password"
)
"""
{
"version": 1,
"description": "Android - Get user credentials",
"packets": [
{
"i": "V202",
"r": 0,
"t": {},
"repeat": 1,
"retry": 4,
"extract": {
"sk": "d.sk",
"ui": "d.ui"
},
"onSuccess": true
}
]
}
""".trimIndent().to<StrategyConfig>().execute(user) {
println("Response: ${responses["V202"]}")
println("Val sk: ${variables["sk"]}")
println("Val ui: ${variables["ui"]}")
}
}
The above two methods are completely equivalent, and both use the Medal-core method to construct packets, execute packets, and process packets
- JDK 21 - jvm、JDK 17 - android
- Kotlin 2.1.0
- Maven 3.6.3+ or Gradle 8.10.2
Make sure that the kotlin plugin for your IDE supports kotlin 2.1.0 or later
Incompatible Gradle 8.12 or above
If you build in Intellij IDEA with an error,or build with Maven、 try enabling the following settings: Settings / Build, Execution, Deployment / Build Tools / Maven / Runner / Delegate IDE build/run actions to Maven.
Make sure your project root of settings.gradle.kts
is added Maven Central repository
dependencyResolutionManagement {
repositories {
mavenCentral()
maven("https://maven.aliyun.com/repository/public") // Optional for China Mainland users
}
}
Then add dependency in build.gradle.kts
dependencies {
implementation("io.github.smfdrummer:medal-core:${latest.version}")
}
Including latest.version is the latest version number,you can find it in Maven Central
Make sure your project root of settings.gradle
is added Maven Central repository
dependencyResolutionManagement {
repositories {
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public' } // Optional for China Mainland users
}
}
Then add dependency in build.gradle
dependencies {
implementation 'io.github.smfdrummer:medal-core:{{latest.version}}'
}
Including latest.version is the latest version number,you can find it in Maven Central
Add the following to the pom.xml
file:
- Add Maven Central repository (If it is not included by default):
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<!-- Aliyun public Maven repository for China Mainland users -->
<repository>
<id>aliyun-central</id>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
- Add medal-core dependency:
<dependencies>
<dependency>
<groupId>io.github.smfdrummer</groupId>
<artifactId>medal-core</artifactId>
<version>latest.version</version>
</dependency>
</dependencies>
Including latest.version is the latest version number,you can find it in Maven Central
For more information, please visit: Wiki learn how to use it
Medal-core is released under the AGPL 3.0 license
Unless commercially licensed, the code needs to be open source in any way you modify or use it
Only projects for personal use and open source can use this library, otherwise there will be a fee
Please comply with the license regulations and do not violate the license regulations, otherwise you will be held legally responsible
Thank you for using Medal-core, and if you have any questions or suggestions, please take Issues
Projects cite the following open source projects (in no particular order):
- Kotlinx Serialization
- Kotlinx Serialization JsonPath
- Arrow-kt
- Ktor
- Logback & Logback Android
- Bouncy Castle
- Reflections
- Kronos-orm
If you like Medal-core and want to support the development of the project, you can sponsor in the following ways: AiFaDian