Skip to content

Commit

Permalink
add minecraft kmp plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Dec 2, 2023
1 parent d077ef7 commit 5ff9ed0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ Don't forget gradle modules could sync in different order. So in some cases you
evaluationDependsOn(":modules:my-shared-module")
```

Also can be configured with KotlinMultiplatform(Experimental)
```kotlin
kotlin {
jvm {
withJava()
}
minecraftMultiplatform {
bukkitTarget()
velocityTarget()
}
sourceSets {
val bukkitMain by getting {
...
}
}
}

```

## Gratitude

Thanks for moko gradle plugins and arkivanov for inspiration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package ru.astrainteractive.gradleplugin.multiplatform

import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.attributes.Attribute
import org.gradle.api.tasks.SourceSetOutput
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import ru.astrainteractive.gradleplugin.multiplatform.sourceset.JvmSourceSet

open class MinecraftMultiplatformScope(private val project: Project) {
Expand Down Expand Up @@ -92,4 +94,25 @@ open class MinecraftMultiplatformScope(private val project: Project) {
*/
val ProjectDependency.fabricMain: SourceSetOutput
get() = this.sourceSet("fabricMain")

@ExperimentalMultiplatform
fun KotlinMultiplatformExtension.bukkitTarget() {
createMinecraftTarget("bukkit")
}

@ExperimentalMultiplatform
fun KotlinMultiplatformExtension.velocityTarget() {
createMinecraftTarget("velocity")
}

@ExperimentalMultiplatform
fun KotlinMultiplatformExtension.createMinecraftTarget(target: String) {
val minecraftFrameworkAttribute = Attribute.of("MinecraftAttribute", String::class.java)
jvm(target) {
attributes.attribute(minecraftFrameworkAttribute, target)
}
val jvmMain = sourceSets.getByName("jvmMain")
val targetMain = sourceSets.getByName("${target}Main")
targetMain.dependsOn(jvmMain)
}
}

0 comments on commit 5ff9ed0

Please sign in to comment.