Skip to content

Commit

Permalink
Make main project file configurable (fixes ReplayMod#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Jul 14, 2024
1 parent 48e2001 commit 280ca72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PreprocessPlugin : Plugin<Project> {
val graph = rootExtension.rootNode ?: throw IllegalStateException("Preprocess graph was not configured.")
val projectNode = graph.findNode(project.name) ?: throw IllegalStateException("Prepocess graph does not contain ${project.name}.")

val coreProjectFile = project.file("../mainProject")
val coreProjectFile = rootExtension.mainProjectFile.asFile.get()
val coreProject = coreProjectFile.readText().trim()
val mcVersion = projectNode.mcVersion
project.extra["mcVersion"] = mcVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.replaymod.gradle.preprocess

import org.gradle.api.Project
import org.gradle.api.file.RegularFileProperty
import java.io.File

open class RootPreprocessExtension : ProjectGraphNodeDSL {
open class RootPreprocessExtension(project: Project) : ProjectGraphNodeDSL {
val mainProjectFile: RegularFileProperty = project.objects.fileProperty()

var rootNode: ProjectGraphNode? = null
get() = field ?: linkNodes()?.also { field = it }

private val nodes = mutableSetOf<Node>()

init {
mainProjectFile.convention(project.layout.projectDirectory.file("versions/mainProject"))
}

fun createNode(project: String, mcVersion: Int, mappings: String): Node {
return Node(project, mcVersion, mappings).also { nodes.add(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class RootPreprocessPlugin : Plugin<Project> {

override fun apply(project: Project) {
project.logger.lifecycle("Preprocessor $version")
project.extensions.create("preprocess", RootPreprocessExtension::class)
project.extensions.create("preprocess", RootPreprocessExtension::class, project)
}
}

0 comments on commit 280ca72

Please sign in to comment.