improve support for multi-module builds
All checks were successful
Publish to snapshot maven / build (push) Successful in 22s
All checks were successful
Publish to snapshot maven / build (push) Successful in 22s
This commit is contained in:
parent
3f25831332
commit
bdc9fe585c
|
@ -32,8 +32,9 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
println("> Applying FrogMC Gradle Plugin to ${project.name}")
|
||||
globalCacheDir = project.gradle.gradleUserHomeDir.resolve("caches/phytotelma/").toPath()
|
||||
globalCacheDir.createDirectories()
|
||||
localCacheDir = project.projectDir.resolve(".gradle/phytotelma/cache/").toPath()
|
||||
val localCacheDir = project.projectDir.resolve(".gradle/phytotelma/cache/").toPath()
|
||||
localCacheDir.createDirectories()
|
||||
ProjectStorage.get(project).localCacheDir = localCacheDir
|
||||
|
||||
project.plugins.let {
|
||||
it.apply("java-library")
|
||||
|
@ -72,9 +73,10 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
project.task("genSources").apply {
|
||||
group = Constants.TASK_GROUP
|
||||
doFirst {
|
||||
val fileName = remappedGameJarPath.fileName.toString()
|
||||
val projectData = ProjectStorage.get(it.project)
|
||||
val fileName = projectData.remappedGameJarPath!!.fileName.toString()
|
||||
val output =
|
||||
remappedGameJarPath.resolveSibling(
|
||||
projectData.remappedGameJarPath!!.resolveSibling(
|
||||
fileName.substring(
|
||||
0,
|
||||
fileName.lastIndexOf("-")
|
||||
|
@ -87,9 +89,9 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
val options = mutableMapOf<String, Any>()
|
||||
println("Preparing Parchment...")
|
||||
val parchment = ParchmentProvider.getParchment(
|
||||
minecraftVersion,
|
||||
parchmentVersion,
|
||||
globalCacheDir.resolve("org/parchmentmc/parchment/$minecraftVersion/$parchmentVersion/")
|
||||
projectData.minecraftVersion!!,
|
||||
projectData.parchmentVersion!!,
|
||||
globalCacheDir.resolve("org/parchmentmc/parchment/${projectData.minecraftVersion}/${projectData.parchmentVersion}/")
|
||||
)
|
||||
options[IFabricJavadocProvider.PROPERTY_NAME] = ParchmentJavadocProvider(parchment)
|
||||
|
||||
|
@ -110,7 +112,7 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
SingleFileSaver(output.toFile()),
|
||||
options, logger
|
||||
)
|
||||
decomp.addSource(remappedGameJarPath.toFile())
|
||||
decomp.addSource(projectData.remappedGameJarPath!!.toFile())
|
||||
|
||||
decomp.decompileContext()
|
||||
}
|
||||
|
@ -131,7 +133,7 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
project.task(Constants.DOWNLOAD_ASSETS_TASK).apply {
|
||||
group = Constants.TASK_GROUP
|
||||
doFirst {
|
||||
AssetDownloader.download()
|
||||
AssetDownloader.download(it.project)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,16 +156,12 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
project.tasks.register(Constants.UPDATE_AW_TASK) {
|
||||
it.group = Constants.TASK_GROUP
|
||||
it.actions.addFirst {
|
||||
AccessWidener.apply(project, remappedGameJarPath)
|
||||
AccessWidener.apply(project, ProjectStorage.get(it.project).remappedGameJarPath!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
lateinit var localCacheDir: Path
|
||||
lateinit var globalCacheDir: Path
|
||||
lateinit var minecraftVersion: String
|
||||
lateinit var remappedGameJarPath: Path
|
||||
lateinit var parchmentVersion: String
|
||||
}
|
||||
}
|
||||
|
|
22
src/main/kotlin/dev/frogmc/phytotelma/ProjectStorage.kt
Normal file
22
src/main/kotlin/dev/frogmc/phytotelma/ProjectStorage.kt
Normal file
|
@ -0,0 +1,22 @@
|
|||
package dev.frogmc.phytotelma
|
||||
|
||||
import org.gradle.api.Project
|
||||
import java.nio.file.Path
|
||||
|
||||
object ProjectStorage {
|
||||
|
||||
private val data = mutableMapOf<Project, ProjectData>()
|
||||
|
||||
fun get(project: Project): ProjectData {
|
||||
if (!data.containsKey(project)){
|
||||
data[project] = ProjectData(null, null, null, null)
|
||||
}
|
||||
return data[project]!!
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ProjectData(var localCacheDir: Path?,
|
||||
var minecraftVersion: String?,
|
||||
var remappedGameJarPath: Path?,
|
||||
var parchmentVersion: String?)
|
|
@ -7,6 +7,7 @@ import com.electronwill.nightconfig.toml.TomlParser
|
|||
import com.electronwill.nightconfig.toml.TomlWriter
|
||||
import dev.frogmc.phytotelma.Constants
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import dev.frogmc.phytotelma.nest.Nester
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
|
@ -66,7 +67,7 @@ abstract class PhytotelmaBuildTask : DefaultTask() {
|
|||
"""
|
||||
Built-By: Phytotelma ${this.javaClass.`package`.implementationVersion}
|
||||
Target-Namespace: Mojmap
|
||||
Built-For: Minecraft ${PhytotelmaPlugin.minecraftVersion}
|
||||
Built-For: Minecraft ${ProjectStorage.get(project).minecraftVersion}
|
||||
Build-Date: ${LocalDateTime.now()}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.frogmc.phytotelma.ext
|
|||
|
||||
import dev.frogmc.phytotelma.Constants
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import dev.frogmc.phytotelma.VersionChecker
|
||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
||||
|
@ -25,14 +26,15 @@ abstract class PhytotelmaGradleExtensionImpl : PhytotelmaGradleExtension {
|
|||
val parchment =
|
||||
parchmentVersion ?: kotlin.runCatching { ParchmentProvider.findForMinecraftVersion(version) }
|
||||
.getOrDefault("")
|
||||
PhytotelmaPlugin.minecraftVersion = version
|
||||
PhytotelmaPlugin.parchmentVersion = parchment
|
||||
val projectData = ProjectStorage.get(getProject())
|
||||
projectData.minecraftVersion = version
|
||||
projectData.parchmentVersion = parchment
|
||||
println("Valid version! $version")
|
||||
val clientJar = VersionChecker.downloadClient(version)
|
||||
val remappedJar =
|
||||
PhytotelmaPlugin.localCacheDir.resolve("net/minecraft/client/$version/client-$version-remapped.jar")
|
||||
projectData.localCacheDir!!.resolve("net/minecraft/client/$version/client-$version-remapped.jar")
|
||||
remappedJar.createParentDirectories()
|
||||
PhytotelmaPlugin.remappedGameJarPath = remappedJar
|
||||
projectData.remappedGameJarPath = remappedJar
|
||||
println("Time to setup Minecraft!")
|
||||
val applyAW = AccessWidener.needsUpdate(getProject())
|
||||
if (remappedJar.notExists() || applyAW) {
|
||||
|
|
|
@ -3,8 +3,10 @@ package dev.frogmc.phytotelma.run
|
|||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import dev.frogmc.phytotelma.VersionChecker
|
||||
import dev.frogmc.phytotelma.common.CachingHttpClient
|
||||
import org.gradle.api.Project
|
||||
import java.net.URI
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Path
|
||||
|
@ -14,8 +16,8 @@ import kotlin.io.path.reader
|
|||
object AssetDownloader {
|
||||
private const val ASSETS_URL = "https://resources.download.minecraft.net"
|
||||
|
||||
fun download() {
|
||||
val version = PhytotelmaPlugin.minecraftVersion
|
||||
fun download(project: Project) {
|
||||
val version = ProjectStorage.get(project).minecraftVersion!!
|
||||
val path = PhytotelmaPlugin.globalCacheDir.resolve("assets")
|
||||
val id = VersionChecker.downloadAssetIndex(version, path.resolve("indexes"))
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.frogmc.phytotelma.run
|
||||
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import dev.frogmc.phytotelma.VersionChecker
|
||||
import dev.frogmc.phytotelma.common.Env
|
||||
import dev.frogmc.phytotelma.run.adapter.EclipseAdapter
|
||||
|
@ -32,7 +33,8 @@ object RunConfigGenerator {
|
|||
if (assetIndexPath.notExists()) {
|
||||
assetIndexPath.createDirectories()
|
||||
}
|
||||
val indexId = VersionChecker.downloadAssetIndex(PhytotelmaPlugin.minecraftVersion, assetIndexPath)
|
||||
val projectData = ProjectStorage.get(project)
|
||||
val indexId = VersionChecker.downloadAssetIndex(projectData.minecraftVersion!!, assetIndexPath)
|
||||
|
||||
val projectName = if (project.rootDir == project.projectDir) "" else " (${project.name})"
|
||||
|
||||
|
@ -48,7 +50,7 @@ object RunConfigGenerator {
|
|||
mutableListOf(
|
||||
"-Xmx${project.properties.getOrDefault("frogmc.gameHeap", "2048M")}",
|
||||
"-Dfrogmc.development=true",
|
||||
"-Dfrogmc.plugin.minecraft.gameJar=${PhytotelmaPlugin.remappedGameJarPath}",
|
||||
"-Dfrogmc.plugin.minecraft.gameJar=${projectData.remappedGameJarPath}",
|
||||
"-Dlog4j2.configurationFile=$log4jPath",
|
||||
"-Dlog4j2.formatMsgLookups=true"
|
||||
).apply {
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.frogmc.phytotelma.run.task
|
|||
|
||||
import dev.frogmc.phytotelma.Constants
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import dev.frogmc.phytotelma.VersionChecker
|
||||
import dev.frogmc.phytotelma.common.Env
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
|
@ -28,7 +29,7 @@ abstract class RunGameTask @Inject constructor(env: Env) : JavaExec() {
|
|||
if (assetIndexPath.notExists()) {
|
||||
assetIndexPath.createDirectories()
|
||||
}
|
||||
val indexId = VersionChecker.downloadAssetIndex(PhytotelmaPlugin.minecraftVersion, assetIndexPath)
|
||||
val indexId = VersionChecker.downloadAssetIndex(ProjectStorage.get(project).minecraftVersion!!, assetIndexPath)
|
||||
val log4jPath = project.rootDir.resolve(".gradle/phytotelma/log4j.xml").toPath().absolute()
|
||||
if (log4jPath.notExists()) {
|
||||
log4jPath.createParentDirectories()
|
||||
|
@ -56,7 +57,7 @@ abstract class RunGameTask @Inject constructor(env: Env) : JavaExec() {
|
|||
jvmArguments.addAll(
|
||||
"-Xmx${project.properties.getOrDefault("frogmc.gameHeap", "2048M")}",
|
||||
"-Dfrogmc.development=true",
|
||||
"-Dfrogmc.plugin.minecraft.gameJar=${PhytotelmaPlugin.remappedGameJarPath}",
|
||||
"-Dfrogmc.plugin.minecraft.gameJar=${ProjectStorage.get(project).remappedGameJarPath}",
|
||||
"-Dlog4j2.configurationFile=$log4jPath",
|
||||
"-Dlog4j2.formatMsgNoLookups=true",
|
||||
writeArgFile()
|
||||
|
|
Loading…
Reference in a new issue