restructure build process
All checks were successful
Publish to snapshot maven / build (push) Successful in 21s
All checks were successful
Publish to snapshot maven / build (push) Successful in 21s
- separate constants - prevent minecraft and its dependencies from appearing in poms - rename nested jars to frogmods - clean up a bit
This commit is contained in:
parent
e731f57a43
commit
3f25831332
15
src/main/kotlin/dev/frogmc/phytotelma/Constants.kt
Normal file
15
src/main/kotlin/dev/frogmc/phytotelma/Constants.kt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package dev.frogmc.phytotelma
|
||||||
|
|
||||||
|
object Constants {
|
||||||
|
const val MOD_EXTENSION = ".frogmod"
|
||||||
|
const val MOD_METADATA_FILE = "frog.mod.toml"
|
||||||
|
const val MINECRAFT_CONFIGURATION = "minecraftDependency"
|
||||||
|
const val INCLUDE_CONFIGURATION = "include"
|
||||||
|
const val TASK_GROUP = "frogmc"
|
||||||
|
const val BUILD_TASK = "buildFrogmod"
|
||||||
|
const val UPDATE_AW_TASK = "updateAccesswidener"
|
||||||
|
const val DOWNLOAD_ASSETS_TASK = "downloadAssets"
|
||||||
|
const val GEN_RUN_CONFIGS_TASK = "genRunConfigs"
|
||||||
|
const val RUN_CLIENT_TASK = "runClient"
|
||||||
|
const val RUNT_SERVER_TASK = "runServer"
|
||||||
|
}
|
|
@ -1,15 +1,10 @@
|
||||||
package dev.frogmc.phytotelma
|
package dev.frogmc.phytotelma
|
||||||
|
|
||||||
import com.electronwill.nightconfig.core.CommentedConfig
|
|
||||||
import com.electronwill.nightconfig.core.file.FileNotFoundAction
|
|
||||||
import com.electronwill.nightconfig.core.io.WritingMode
|
|
||||||
import com.electronwill.nightconfig.toml.TomlParser
|
|
||||||
import com.electronwill.nightconfig.toml.TomlWriter
|
|
||||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||||
|
import dev.frogmc.phytotelma.build.PhytotelmaBuildTask
|
||||||
import dev.frogmc.phytotelma.common.Env
|
import dev.frogmc.phytotelma.common.Env
|
||||||
import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtension
|
import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtension
|
||||||
import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtensionImpl
|
import dev.frogmc.phytotelma.ext.PhytotelmaGradleExtensionImpl
|
||||||
import dev.frogmc.phytotelma.nest.Nester
|
|
||||||
import dev.frogmc.phytotelma.run.AssetDownloader
|
import dev.frogmc.phytotelma.run.AssetDownloader
|
||||||
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
import dev.frogmc.phytotelma.run.RunConfigGenerator
|
||||||
import dev.frogmc.phytotelma.run.task.RunGameTask
|
import dev.frogmc.phytotelma.run.task.RunGameTask
|
||||||
|
@ -18,26 +13,23 @@ import dev.frogmc.thyroxine.provider.ParchmentProvider
|
||||||
import net.fabricmc.fernflower.api.IFabricJavadocProvider
|
import net.fabricmc.fernflower.api.IFabricJavadocProvider
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.plugins.JavaPlugin
|
||||||
import org.jetbrains.java.decompiler.main.Fernflower
|
import org.jetbrains.java.decompiler.main.Fernflower
|
||||||
import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger
|
import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger
|
||||||
import org.jetbrains.java.decompiler.main.decompiler.SingleFileSaver
|
import org.jetbrains.java.decompiler.main.decompiler.SingleFileSaver
|
||||||
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences
|
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
import java.nio.file.FileSystems
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.StandardCopyOption
|
import kotlin.io.path.createDirectories
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.deleteExisting
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
|
|
||||||
class PhytotelmaPlugin : Plugin<Project> {
|
class PhytotelmaPlugin : Plugin<Project> {
|
||||||
|
|
||||||
private val taskGroup = "frogmc"
|
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
println("> Applying FrogMC Gradle Plugin")
|
println("> Applying FrogMC Gradle Plugin to ${project.name}")
|
||||||
globalCacheDir = project.gradle.gradleUserHomeDir.resolve("caches/phytotelma/").toPath()
|
globalCacheDir = project.gradle.gradleUserHomeDir.resolve("caches/phytotelma/").toPath()
|
||||||
globalCacheDir.createDirectories()
|
globalCacheDir.createDirectories()
|
||||||
localCacheDir = project.projectDir.resolve(".gradle/phytotelma/cache/").toPath()
|
localCacheDir = project.projectDir.resolve(".gradle/phytotelma/cache/").toPath()
|
||||||
|
@ -78,7 +70,7 @@ class PhytotelmaPlugin : Plugin<Project> {
|
||||||
project.extensions.findByType(PhytotelmaGradleExtension::class.java) ?: return
|
project.extensions.findByType(PhytotelmaGradleExtension::class.java) ?: return
|
||||||
|
|
||||||
project.task("genSources").apply {
|
project.task("genSources").apply {
|
||||||
group = taskGroup
|
group = Constants.TASK_GROUP
|
||||||
doFirst {
|
doFirst {
|
||||||
val fileName = remappedGameJarPath.fileName.toString()
|
val fileName = remappedGameJarPath.fileName.toString()
|
||||||
val output =
|
val output =
|
||||||
|
@ -125,71 +117,42 @@ class PhytotelmaPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
project.task("genRunConfigs").apply {
|
project.task(Constants.GEN_RUN_CONFIGS_TASK).apply {
|
||||||
group = taskGroup
|
group = Constants.TASK_GROUP
|
||||||
doFirst {
|
doFirst {
|
||||||
RunConfigGenerator.generate(project)
|
RunConfigGenerator.generate(project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project.tasks.register("runClient", RunGameTask::class.java, Env.CLIENT)
|
project.tasks.register(Constants.RUN_CLIENT_TASK, RunGameTask::class.java, Env.CLIENT)
|
||||||
project.tasks.register("runServer", RunGameTask::class.java, Env.SERVER)
|
project.tasks.register(Constants.RUNT_SERVER_TASK, RunGameTask::class.java, Env.SERVER)
|
||||||
|
|
||||||
|
|
||||||
project.task("downloadAssets").apply {
|
project.task(Constants.DOWNLOAD_ASSETS_TASK).apply {
|
||||||
group = taskGroup
|
group = Constants.TASK_GROUP
|
||||||
doFirst {
|
doFirst {
|
||||||
AssetDownloader.download()
|
AssetDownloader.download()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val includeConfiguration = project.configurations.register("include") {
|
project.configurations.register(Constants.INCLUDE_CONFIGURATION) {
|
||||||
it.isCanBeResolved = true
|
it.isCanBeResolved = true
|
||||||
it.isCanBeConsumed = false
|
it.isCanBeConsumed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
project.tasks.getByName("jar") { task ->
|
project.configurations.register(Constants.MINECRAFT_CONFIGURATION) {
|
||||||
task.outputs.upToDateWhen { false }
|
project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(it)
|
||||||
task.actions.addLast { _ ->
|
project.configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(it)
|
||||||
task.outputs.files.forEach { file ->
|
it.isCanBeResolved = false
|
||||||
val output = file.toPath().parent.resolveSibling("frogmc")
|
it.isCanBeConsumed = false
|
||||||
output.createDirectories()
|
it.isTransitive = false
|
||||||
if (file.name.endsWith(".jar") && !(file.name.contains("-dev.") || file.name.contains("-sources."))) {
|
|
||||||
val outFile = output.resolve(file.name.substring(0, file.name.length - 4) + ".frogmod")
|
|
||||||
Files.copy(file.toPath(), outFile, StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
FileSystems.newFileSystem(outFile).use { fs ->
|
|
||||||
if (includeConfiguration.isPresent) {
|
|
||||||
val jijPath = fs.getPath("META-INF/jars")
|
|
||||||
val files = Nester.run(includeConfiguration.get(), jijPath).map { it.toml() }.toList()
|
|
||||||
if (files.isNotEmpty()) {
|
|
||||||
val manifest = fs.getPath("frog.mod.toml")
|
|
||||||
val config: CommentedConfig =
|
|
||||||
TomlParser().parse(manifest, FileNotFoundAction.THROW_ERROR)
|
|
||||||
if (!config.add("frog.extensions.included_jars", listOf(files))) {
|
|
||||||
println("Failed to add included jars to mod manifest, make sure it doesn't include a key at 'frog.extensions.included_jars'!")
|
|
||||||
}
|
|
||||||
TomlWriter().write(config, manifest, WritingMode.REPLACE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val manifest = fs.getPath("META-INF/MANIFEST.MF")
|
|
||||||
val lines = manifest.readLines().filter { it.isNotBlank() }
|
|
||||||
.plus(
|
|
||||||
"""
|
|
||||||
Built-By: Phytotelma ${this.javaClass.`package`.implementationVersion}
|
|
||||||
Target-Namespace: Mojmap
|
|
||||||
Built-For: Minecraft $minecraftVersion
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
|
||||||
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
|
||||||
}
|
|
||||||
println("Built mod to ${outFile.toUri()}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.tasks.register("updateAccesswidener") {
|
val buildTask = project.tasks.register(Constants.BUILD_TASK, PhytotelmaBuildTask::class.java)
|
||||||
it.group = taskGroup
|
project.tasks.getByName("build").dependsOn(buildTask)
|
||||||
|
|
||||||
|
project.tasks.register(Constants.UPDATE_AW_TASK) {
|
||||||
|
it.group = Constants.TASK_GROUP
|
||||||
it.actions.addFirst {
|
it.actions.addFirst {
|
||||||
AccessWidener.apply(project, remappedGameJarPath)
|
AccessWidener.apply(project, remappedGameJarPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,11 +109,24 @@ private class MojangResponse(val latest: Latest, val versions: List<Version>)
|
||||||
|
|
||||||
private class Latest(val release: String, val snapshot: String)
|
private class Latest(val release: String, val snapshot: String)
|
||||||
|
|
||||||
private class Version(val id: String, val type: String, val url: String, val time: String, val releaseTime: String, val sha1: String, val complianceLevel: Int)
|
private class Version(
|
||||||
|
val id: String,
|
||||||
|
val type: String,
|
||||||
|
val url: String,
|
||||||
|
val time: String,
|
||||||
|
val releaseTime: String,
|
||||||
|
val sha1: String,
|
||||||
|
val complianceLevel: Int
|
||||||
|
)
|
||||||
|
|
||||||
private class VersionUrl(val id: String, val url: String)
|
private class VersionUrl(val id: String, val url: String)
|
||||||
|
|
||||||
class VersionData(val downloads: VersionDownloads, val libraries: List<LibraryDownload>, val id: String, val assetIndex: AssetIndex)
|
class VersionData(
|
||||||
|
val downloads: VersionDownloads,
|
||||||
|
val libraries: List<LibraryDownload>,
|
||||||
|
val id: String,
|
||||||
|
val assetIndex: AssetIndex
|
||||||
|
)
|
||||||
|
|
||||||
class LibraryDownload(val artifact: LibraryArtifact, val name: String)
|
class LibraryDownload(val artifact: LibraryArtifact, val name: String)
|
||||||
class LibraryArtifact(val path: String, val sha1: String, val size: Int, val url: String)
|
class LibraryArtifact(val path: String, val sha1: String, val size: Int, val url: String)
|
||||||
|
|
|
@ -3,7 +3,9 @@ package dev.frogmc.phytotelma.accesswidener
|
||||||
import com.electronwill.nightconfig.core.file.FileNotFoundAction
|
import com.electronwill.nightconfig.core.file.FileNotFoundAction
|
||||||
import com.electronwill.nightconfig.toml.TomlParser
|
import com.electronwill.nightconfig.toml.TomlParser
|
||||||
import com.google.common.hash.Hashing
|
import com.google.common.hash.Hashing
|
||||||
|
import dev.frogmc.phytotelma.Constants
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.plugins.JavaPlugin
|
||||||
import org.gradle.api.plugins.JavaPluginExtension
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
import org.objectweb.asm.*
|
import org.objectweb.asm.*
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
@ -27,7 +29,7 @@ object AccessWidener {
|
||||||
|
|
||||||
private fun getAWFile(project: Project): Path? {
|
private fun getAWFile(project: Project): Path? {
|
||||||
project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.forEach { set ->
|
project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.forEach { set ->
|
||||||
set.resources.filter { it.name == "frog.mod.toml" }.firstOrNull {
|
set.resources.filter { it.name == Constants.MOD_METADATA_FILE }.firstOrNull {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
println("Please make sure a 'frog.mod.toml' file is present in the mod's resources!")
|
println("Please make sure a 'frog.mod.toml' file is present in the mod's resources!")
|
||||||
return null
|
return null
|
||||||
|
@ -43,7 +45,8 @@ object AccessWidener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findDependencyAWs(project: Project): List<Path> {
|
private fun findDependencyAWs(project: Project): List<Path> {
|
||||||
return project.configurations.getByName("runtimeClasspath").resolvedConfiguration.firstLevelModuleDependencies.flatMap { dep ->
|
return project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
|
||||||
|
.resolvedConfiguration.firstLevelModuleDependencies.flatMap { dep ->
|
||||||
dep.moduleArtifacts
|
dep.moduleArtifacts
|
||||||
}.map { it.file }.map { it.toPath() }.toList()
|
}.map { it.file }.map { it.toPath() }.toList()
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
package dev.frogmc.phytotelma.build
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.CommentedConfig
|
||||||
|
import com.electronwill.nightconfig.core.file.FileNotFoundAction
|
||||||
|
import com.electronwill.nightconfig.core.io.WritingMode
|
||||||
|
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.nest.Nester
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.nio.file.FileSystems
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
|
import java.nio.file.StandardCopyOption
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import kotlin.io.path.createDirectories
|
||||||
|
import kotlin.io.path.readLines
|
||||||
|
import kotlin.io.path.writeLines
|
||||||
|
|
||||||
|
abstract class PhytotelmaBuildTask : DefaultTask() {
|
||||||
|
|
||||||
|
@OutputFile
|
||||||
|
val outputFile: Path
|
||||||
|
|
||||||
|
init {
|
||||||
|
group = Constants.TASK_GROUP
|
||||||
|
val includeConfiguration = project.configurations.findByName(Constants.INCLUDE_CONFIGURATION)
|
||||||
|
|
||||||
|
val jarTask = project.tasks.getByName("jar")
|
||||||
|
dependsOn.add(jarTask)
|
||||||
|
|
||||||
|
val output = project.layout.buildDirectory.dir("frogmc").get().asFile.toPath()
|
||||||
|
output.createDirectories()
|
||||||
|
val abstractArchiveTask = (jarTask as AbstractArchiveTask)
|
||||||
|
val filename = abstractArchiveTask.archiveFileName.get()
|
||||||
|
val outFile = output.resolve(filename.substring(0, filename.length - 4) + Constants.MOD_EXTENSION)
|
||||||
|
outputFile = outFile
|
||||||
|
outputs.upToDateWhen { false }
|
||||||
|
inputs.files(jarTask.outputs)
|
||||||
|
|
||||||
|
actions.add { task ->
|
||||||
|
task.inputs.files.forEach { file ->
|
||||||
|
if (file.name.endsWith(".jar") && !(file.name.contains("-dev.") || file.name.contains("-sources."))) {
|
||||||
|
Files.copy(file.toPath(), outFile, StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
FileSystems.newFileSystem(outFile).use { fs ->
|
||||||
|
if (includeConfiguration != null) {
|
||||||
|
val jijPath = fs.getPath("META-INF/jars")
|
||||||
|
val files = Nester.run(includeConfiguration, jijPath).map { it.toml() }.toList()
|
||||||
|
if (files.isNotEmpty()) {
|
||||||
|
val manifest = fs.getPath(Constants.MOD_METADATA_FILE)
|
||||||
|
val config: CommentedConfig =
|
||||||
|
TomlParser().parse(manifest, FileNotFoundAction.THROW_ERROR)
|
||||||
|
if (!config.add("frog.extensions.included_jars", listOf(files))) {
|
||||||
|
println("Failed to add included jars to mod manifest, make sure it doesn't include a key at 'frog.extensions.included_jars'!")
|
||||||
|
}
|
||||||
|
TomlWriter().write(config, manifest, WritingMode.REPLACE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val manifest = fs.getPath("META-INF/MANIFEST.MF")
|
||||||
|
val lines = manifest.readLines().filter { it.isNotBlank() }
|
||||||
|
.plus(
|
||||||
|
"""
|
||||||
|
Built-By: Phytotelma ${this.javaClass.`package`.implementationVersion}
|
||||||
|
Target-Namespace: Mojmap
|
||||||
|
Built-For: Minecraft ${PhytotelmaPlugin.minecraftVersion}
|
||||||
|
Build-Date: ${LocalDateTime.now()}
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
||||||
|
}
|
||||||
|
println("Built mod to ${outFile.toUri()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.frogmc.phytotelma.ext
|
package dev.frogmc.phytotelma.ext
|
||||||
|
|
||||||
|
import dev.frogmc.phytotelma.Constants
|
||||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||||
import dev.frogmc.phytotelma.VersionChecker
|
import dev.frogmc.phytotelma.VersionChecker
|
||||||
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
import dev.frogmc.phytotelma.accesswidener.AccessWidener
|
||||||
|
@ -10,7 +11,8 @@ import dev.frogmc.thyroxine.provider.MojmapProvider
|
||||||
import dev.frogmc.thyroxine.provider.ParchmentProvider
|
import dev.frogmc.thyroxine.provider.ParchmentProvider
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.createParentDirectories
|
||||||
|
import kotlin.io.path.notExists
|
||||||
|
|
||||||
abstract class PhytotelmaGradleExtensionImpl : PhytotelmaGradleExtension {
|
abstract class PhytotelmaGradleExtensionImpl : PhytotelmaGradleExtension {
|
||||||
|
|
||||||
|
@ -20,13 +22,15 @@ abstract class PhytotelmaGradleExtensionImpl: PhytotelmaGradleExtension {
|
||||||
override fun minecraft(version: String, parchmentVersion: String?) {
|
override fun minecraft(version: String, parchmentVersion: String?) {
|
||||||
if (VersionChecker.validateVersion(version)) {
|
if (VersionChecker.validateVersion(version)) {
|
||||||
println("Setting up Minecraft...")
|
println("Setting up Minecraft...")
|
||||||
val parchment = parchmentVersion ?: kotlin.runCatching { ParchmentProvider.findForMinecraftVersion(version) }
|
val parchment =
|
||||||
|
parchmentVersion ?: kotlin.runCatching { ParchmentProvider.findForMinecraftVersion(version) }
|
||||||
.getOrDefault("")
|
.getOrDefault("")
|
||||||
PhytotelmaPlugin.minecraftVersion = version
|
PhytotelmaPlugin.minecraftVersion = version
|
||||||
PhytotelmaPlugin.parchmentVersion = parchment
|
PhytotelmaPlugin.parchmentVersion = parchment
|
||||||
println("Valid version! $version")
|
println("Valid version! $version")
|
||||||
val clientJar = VersionChecker.downloadClient(version)
|
val clientJar = VersionChecker.downloadClient(version)
|
||||||
val remappedJar = PhytotelmaPlugin.localCacheDir.resolve("net/minecraft/client/$version/client-$version-remapped.jar")
|
val remappedJar =
|
||||||
|
PhytotelmaPlugin.localCacheDir.resolve("net/minecraft/client/$version/client-$version-remapped.jar")
|
||||||
remappedJar.createParentDirectories()
|
remappedJar.createParentDirectories()
|
||||||
PhytotelmaPlugin.remappedGameJarPath = remappedJar
|
PhytotelmaPlugin.remappedGameJarPath = remappedJar
|
||||||
println("Time to setup Minecraft!")
|
println("Time to setup Minecraft!")
|
||||||
|
@ -60,19 +64,22 @@ abstract class PhytotelmaGradleExtensionImpl: PhytotelmaGradleExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println("Adding dependencies...")
|
println("Adding dependencies...")
|
||||||
getProject().dependencies.add("implementation", "net.minecrell:terminalconsoleappender:1.2.0")
|
getProject().dependencies.add(
|
||||||
|
Constants.MINECRAFT_CONFIGURATION,
|
||||||
|
"net.minecrell:terminalconsoleappender:1.2.0"
|
||||||
|
)
|
||||||
VersionChecker.getDependencies(version) {
|
VersionChecker.getDependencies(version) {
|
||||||
getProject().dependencies.add("implementation", it)
|
getProject().dependencies.add(Constants.MINECRAFT_CONFIGURATION, it)
|
||||||
}
|
}
|
||||||
VersionChecker.savePomFile(version, remappedJar.parent)
|
VersionChecker.savePomFile(version, remappedJar.parent)
|
||||||
getProject().dependencies.add("implementation", "net.minecraft:client:$version:remapped")
|
getProject().dependencies.add(Constants.MINECRAFT_CONFIGURATION, "net.minecraft:client:$version:remapped")
|
||||||
|
|
||||||
println("Generating run configurations...")
|
println("Generating run configurations...")
|
||||||
RunConfigGenerator.generate(getProject())
|
RunConfigGenerator.generate(getProject())
|
||||||
|
|
||||||
if (applyAW) {
|
if (applyAW) {
|
||||||
getProject().afterEvaluate {
|
getProject().afterEvaluate {
|
||||||
println("Applying AccessWideners..")
|
println("Applying AccessWideners...")
|
||||||
AccessWidener.apply(getProject(), remappedJar)
|
AccessWidener.apply(getProject(), remappedJar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.electronwill.nightconfig.core.Config
|
||||||
import com.electronwill.nightconfig.core.UnmodifiableConfig
|
import com.electronwill.nightconfig.core.UnmodifiableConfig
|
||||||
import com.electronwill.nightconfig.toml.TomlParser
|
import com.electronwill.nightconfig.toml.TomlParser
|
||||||
import com.google.common.jimfs.Jimfs
|
import com.google.common.jimfs.Jimfs
|
||||||
|
import dev.frogmc.phytotelma.Constants
|
||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.artifacts.ProjectDependency
|
import org.gradle.api.artifacts.ProjectDependency
|
||||||
import org.gradle.api.plugins.JavaPlugin
|
import org.gradle.api.plugins.JavaPlugin
|
||||||
|
@ -21,7 +22,6 @@ object Nester {
|
||||||
Jimfs.newFileSystem(com.google.common.jimfs.Configuration.unix()).use { memFs ->
|
Jimfs.newFileSystem(com.google.common.jimfs.Configuration.unix()).use { memFs ->
|
||||||
configuration.dependencies.filterIsInstance<ProjectDependency>().forEach { dependency ->
|
configuration.dependencies.filterIsInstance<ProjectDependency>().forEach { dependency ->
|
||||||
val project = dependency.dependencyProject
|
val project = dependency.dependencyProject
|
||||||
|
|
||||||
project.getTasksByName(JavaPlugin.JAR_TASK_NAME, false).map { t -> t as AbstractArchiveTask }
|
project.getTasksByName(JavaPlugin.JAR_TASK_NAME, false).map { t -> t as AbstractArchiveTask }
|
||||||
.forEach { task ->
|
.forEach { task ->
|
||||||
val location = task.archiveFile.map {
|
val location = task.archiveFile.map {
|
||||||
|
@ -35,7 +35,8 @@ object Nester {
|
||||||
)
|
)
|
||||||
}.get()
|
}.get()
|
||||||
path.createDirectories()
|
path.createDirectories()
|
||||||
val target = path.resolve(location.file.fileName.toString())
|
val target =
|
||||||
|
path.resolve(location.file.fileName.toString().replace(".jar", Constants.MOD_EXTENSION))
|
||||||
if (target.notExists()) {
|
if (target.notExists()) {
|
||||||
Files.copy(location.file, target)
|
Files.copy(location.file, target)
|
||||||
files.add(
|
files.add(
|
||||||
|
@ -44,6 +45,7 @@ object Nester {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
configuration.resolvedConfiguration.firstLevelModuleDependencies.forEach { dep ->
|
configuration.resolvedConfiguration.firstLevelModuleDependencies.forEach { dep ->
|
||||||
dep.moduleArtifacts.forEach { artifact ->
|
dep.moduleArtifacts.forEach { artifact ->
|
||||||
val location = addMetadata(
|
val location = addMetadata(
|
||||||
|
@ -55,7 +57,8 @@ object Nester {
|
||||||
memFs
|
memFs
|
||||||
)
|
)
|
||||||
path.createDirectories()
|
path.createDirectories()
|
||||||
val target = path.resolve(location.file.fileName.toString())
|
val target =
|
||||||
|
path.resolve(location.file.fileName.toString().replace(".jar", Constants.MOD_EXTENSION))
|
||||||
|
|
||||||
if (target.notExists()) {
|
if (target.notExists()) {
|
||||||
Files.copy(location.file, target)
|
Files.copy(location.file, target)
|
||||||
|
@ -90,7 +93,7 @@ object Nester {
|
||||||
)
|
)
|
||||||
if (tempFile.exists()) {
|
if (tempFile.exists()) {
|
||||||
FileSystems.newFileSystem(tempFile).use {
|
FileSystems.newFileSystem(tempFile).use {
|
||||||
val metadata = it.getPath("frog.mod.toml")
|
val metadata = it.getPath(Constants.MOD_METADATA_FILE)
|
||||||
if (metadata.exists()) {
|
if (metadata.exists()) {
|
||||||
return JarMetadata(readModId(metadata), tempFile)
|
return JarMetadata(readModId(metadata), tempFile)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +102,8 @@ object Nester {
|
||||||
tempFile.createParentDirectories()
|
tempFile.createParentDirectories()
|
||||||
input.copyTo(tempFile)
|
input.copyTo(tempFile)
|
||||||
val modId = ("${group}_$name${if (classifier != null) "_$classifier" else ""}").replace(
|
val modId = ("${group}_$name${if (classifier != null) "_$classifier" else ""}").replace(
|
||||||
"\\.".toRegex(), "_").lowercase(Locale.ROOT)
|
"\\.".toRegex(), "_"
|
||||||
|
).lowercase(Locale.ROOT)
|
||||||
FileSystems.newFileSystem(tempFile).use {
|
FileSystems.newFileSystem(tempFile).use {
|
||||||
it.getPath("frog.mod.toml").writeText(
|
it.getPath("frog.mod.toml").writeText(
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -25,7 +25,8 @@ class IdeaAdapter : RunConfigAdapter {
|
||||||
|
|
||||||
val file = folder.resolve("$name.xml")
|
val file = folder.resolve("$name.xml")
|
||||||
|
|
||||||
var module = project.name + "." + project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.getByName(
|
var module =
|
||||||
|
project.name + "." + project.extensions.getByType(JavaPluginExtension::class.java).sourceSets.getByName(
|
||||||
SourceSet.MAIN_SOURCE_SET_NAME
|
SourceSet.MAIN_SOURCE_SET_NAME
|
||||||
).name
|
).name
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.frogmc.phytotelma.run.task
|
package dev.frogmc.phytotelma.run.task
|
||||||
|
|
||||||
|
import dev.frogmc.phytotelma.Constants
|
||||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||||
import dev.frogmc.phytotelma.VersionChecker
|
import dev.frogmc.phytotelma.VersionChecker
|
||||||
import dev.frogmc.phytotelma.common.Env
|
import dev.frogmc.phytotelma.common.Env
|
||||||
|
@ -21,7 +22,7 @@ abstract class RunGameTask @Inject constructor(env: Env) : JavaExec() {
|
||||||
private val classpath: ConfigurableFileCollection = project.objects.fileCollection()
|
private val classpath: ConfigurableFileCollection = project.objects.fileCollection()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
group = "frogmc"
|
group = Constants.TASK_GROUP
|
||||||
val assetPath = PhytotelmaPlugin.globalCacheDir.resolve("assets").absolute()
|
val assetPath = PhytotelmaPlugin.globalCacheDir.resolve("assets").absolute()
|
||||||
val assetIndexPath = assetPath.resolve("indexes")
|
val assetIndexPath = assetPath.resolve("indexes")
|
||||||
if (assetIndexPath.notExists()) {
|
if (assetIndexPath.notExists()) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package dev.frogmc.phytotelma.vineflower
|
package dev.frogmc.phytotelma.vineflower
|
||||||
|
|
||||||
import net.fabricmc.fernflower.api.IFabricJavadocProvider
|
|
||||||
import dev.frogmc.thyroxine.api.data.Parchment
|
import dev.frogmc.thyroxine.api.data.Parchment
|
||||||
|
import net.fabricmc.fernflower.api.IFabricJavadocProvider
|
||||||
import org.jetbrains.java.decompiler.struct.StructClass
|
import org.jetbrains.java.decompiler.struct.StructClass
|
||||||
import org.jetbrains.java.decompiler.struct.StructField
|
import org.jetbrains.java.decompiler.struct.StructField
|
||||||
import org.jetbrains.java.decompiler.struct.StructMethod
|
import org.jetbrains.java.decompiler.struct.StructMethod
|
||||||
|
|
Loading…
Reference in a new issue