Skip to content

Commit

Permalink
setup server project dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Sep 24, 2023
1 parent 3ed4ff8 commit 17ba6dc
Showing 1 changed file with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.papermc.paperweight.core.taskcontainers

import io.papermc.paperweight.core.ext
import io.papermc.paperweight.tasks.mache.*
import io.papermc.paperweight.util.*
import io.papermc.paperweight.util.constants.*
Expand All @@ -12,6 +13,9 @@ import org.gradle.kotlin.dsl.*
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking
import org.gradle.api.Task
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.Sync

open class SoftSpoonTasks(
Expand Down Expand Up @@ -60,7 +64,7 @@ open class SoftSpoonTasks(
patchedJar.set(layout.cache.resolve(PATCHED_JAR))
failedPatchJar.set(layout.cache.resolve(FAILED_PATCH_JAR))

sourceDir.set(layout.projectDirectory.dir("Paper-Server/src/vanilla/java"))
sourceDir.set(this.project.ext.serverProject.map { it.layout.projectDirectory.dir("src/vanilla/java") })
}

val macheApplyPatches by tasks.registering(ApplyPatches::class) {
Expand All @@ -85,7 +89,7 @@ open class SoftSpoonTasks(

val macheCopyResources by tasks.registering(Sync::class) {
group = "softspoon"
into(project.layout.projectDirectory.dir("Paper-Server/src/vanilla/resources"))
into(project.ext.serverProject.map { it.layout.projectDirectory.dir("src/vanilla/resources") })
from(project.zipTree(project.layout.cache.resolve(SERVER_JAR_PATH))) {
exclude("**/*.class", "META-INF/**")
}
Expand Down Expand Up @@ -195,5 +199,40 @@ open class SoftSpoonTasks(
"macheDecompiler"("${it.group}:${it.name}:${it.version}")
}
}

this.project.ext.serverProject.get().setupServerProject(mache, libs);
}

private fun Project.setupServerProject(mache: MacheMeta, libs: List<String>) {
if (!projectDir.exists()) {
return
}

// minecraft deps
val macheMinecraft by configurations.creating {
withDependencies {
dependencies {
// setup mc deps
libs.forEach {
"macheMinecraft"(it)
}
}
}
}

// impl extends minecraft
configurations.named(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME) {
extendsFrom(macheMinecraft)
}

// add vanilla source set
the<JavaPluginExtension>().sourceSets.named(SourceSet.MAIN_SOURCE_SET_NAME) {
java {
srcDirs(projectDir.resolve("src/vanilla/java"))
}
resources {
srcDirs(projectDir.resolve("src/vanilla/resources"))
}
}
}
}

0 comments on commit 17ba6dc

Please sign in to comment.