Skip to content

Commit

Permalink
Update build.gradle.kts
Browse files Browse the repository at this point in the history
  • Loading branch information
qingshu-ui committed Oct 15, 2024
1 parent b5ad781 commit 262a041
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
18 changes: 6 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,15 @@ repositories {
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://maven.duti.dev/releases") }
}
configurations {
// configuration that holds jars to include in the jar
create("extraLibs")
}

val extraLibs: Configuration by configurations.creating
configurations {
named("implementation") {
extendsFrom(getByName("extraLibs"))
// configuration that holds jars to include in the jar
implementation {
extendsFrom(extraLibs)
}
}

fun DependencyHandlerScope.extraLibs(dependencyNotation: String, configure: ModuleDependency.() -> Unit = {}) {
add("extraLibs", dependencyNotation, configure)
}

dependencies {
// This will make it work on most platforms. It automatically chooses the right dependencies at runtime.
val cubiomesVersion = "dev.duti.acheong:cubiomes:1.22.3"
Expand All @@ -78,7 +72,7 @@ dependencies {
"com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962",
"com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78",
"com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126",
"com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229"
"com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229",
)
seedFindingDependencies.forEach { dependency ->
extraLibs(dependency) { isTransitive = false }
Expand Down Expand Up @@ -114,7 +108,7 @@ tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName}" }
}
from(configurations["extraLibs"].map { if (it.isDirectory) it else zipTree(it) })
from(extraLibs.map { if (it.isDirectory) it else zipTree(it) })
}

tasks.withType<Jar>() {
Expand Down
16 changes: 8 additions & 8 deletions src/main/kotlin/anticope/rejects/utils/MeteorManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,40 @@ private inline fun <reified T> registerClasses(packageName: String, addInstance:
}

/**
* Registers all modules in the specified package that are annotated with @AutoRegister.
* Registers all modules in the specified package that are annotated with `@AutoRegister`.
*
* This function scans the given package for classes that extend [Module] and have the @AutoRegister annotation,
* This function scans the given package for classes that extend [Module] and have the `@AutoRegister` annotation,
* creating instances of those classes and adding them to the [Modules] system.
*
* @param packageName The name of the package to search for modules, formatted as "com.example.module".
* @param packageName The name of the package to search for modules, formatted as `com.example.module`.
*
* @throws ClassNotFoundException If the classes in the specified package cannot be found.
*
* Usage example:
* ```
* moduleRegister("com.github.shu.module")
* ```
* This will register all auto-registered modules from the "com.github.shu.module" package.
* This will register all auto-registered modules from the `com.github.shu.module` package.
*/
fun moduleRegister(packageName: String) {
registerClasses<Module>(packageName, Modules.get()::add)
}

/**
* Registers all commands in the specified package that are annotated with @AutoRegister.
* Registers all commands in the specified package that are annotated with `@AutoRegister`.
*
* This function scans the given package for classes that extend [Command] and have the @AutoRegister annotation,
* This function scans the given package for classes that extend [Command] and have the `@AutoRegister` annotation,
* creating instances of those classes and adding them to the [Commands] system.
*
* @param packageName The name of the package to search for commands, formatted as "com.example.command".
* @param packageName The name of the package to search for commands, formatted as `com.example.command`.
*
* @throws ClassNotFoundException If the classes in the specified package cannot be found.
*
* Usage example:
* ```
* commandRegister("com.github.shu.command")
* ```
* This will register all auto-registered commands from the "com.github.shu.command" package.
* This will register all auto-registered commands from the `com.github.shu.command` package.
*/
fun commandRegister(packageName: String) {
registerClasses<Command>(packageName, Commands::add)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/anticope/rejects/utils/PackageScanner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PackageScanner {
/**
* Finds all Kotlin classes in the specified package and filters them based on the provided criteria.
*
* @param packageName The name of the package to search, formatted as "com.example.package".
* @param packageName The name of the package to search, formatted as `com.example.package`.
* @param filter An optional filtering function that takes a [KClass] parameter and returns a boolean value.
* Only classes for which this function returns `true` will be included in the results.
* Defaults to a filter that accepts all classes (returns `true`).
Expand All @@ -26,7 +26,7 @@ class PackageScanner {
* ```
* val classes = findKClasses("com.example") { it.annotations.any { annotation -> annotation is MyAnnotation } }
* ```
* This will return all classes in the "com.example" package that are annotated with `@MyAnnotation`.
* This will return all classes in the `com.example` package that are annotated with `@MyAnnotation`.
*/
@JvmStatic
fun findKClasses(packageName: String, filter: (KClass<*>) -> Boolean = { true }): List<KClass<*>> {
Expand Down

0 comments on commit 262a041

Please sign in to comment.