add manifest property for calamus gen2
All checks were successful
Publish to snapshot maven / build (push) Successful in 25s
All checks were successful
Publish to snapshot maven / build (push) Successful in 25s
This commit is contained in:
parent
ca8d3c9d6a
commit
d72218f62e
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.21"
|
||||
version = "0.0.1-alpha.22"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
|
|
@ -39,10 +39,12 @@ import org.objectweb.asm.commons.ClassRemapper
|
|||
import java.io.OutputStream
|
||||
import java.io.PrintStream
|
||||
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.StandardCopyOption
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import kotlin.io.path.*
|
||||
|
||||
|
@ -215,24 +217,23 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
storage.mappings!!.reverse(), it
|
||||
)
|
||||
} ?: storage.mappings!!).forNamespaces(storage.targetNamespace, storage.intermediaryNs)
|
||||
val includeConfiguration = project.configurations.findByName(Constants.INCLUDE_CONFIGURATION)
|
||||
|
||||
task.outputs.files.forEach { file ->
|
||||
val temp = Files.createTempFile("", file.name)
|
||||
Files.copy(file.toPath(), temp, StandardCopyOption.REPLACE_EXISTING)
|
||||
FileSystems.newFileSystem(temp).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", 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 data = ProjectStorage.get(project)
|
||||
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: ${data.intermediaryNs}
|
||||
Built-For: Minecraft ${data.minecraftVersion}
|
||||
Build-Date: ${LocalDateTime.now()}
|
||||
""".trimIndent()
|
||||
).plus(data.jarManifestProperties.entries.joinToString("\n") { it.key+": "+it.value})
|
||||
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
||||
val metadata = fs.getPath(Constants.MOD_METADATA_FILE)
|
||||
tomlParser.parse(metadata, FileNotFoundAction.READ_NOTHING)
|
||||
.get<String>("frog.extensions.accesswidener")?.let { name ->
|
||||
|
|
|
@ -76,9 +76,10 @@ class ProjectData(
|
|||
var mappingsName: String?,
|
||||
var intermediaryNs: String?,
|
||||
var targetNamespace: String?,
|
||||
var manifestUrl: String?
|
||||
var manifestUrl: String?,
|
||||
var jarManifestProperties: MutableMap<String, String>
|
||||
) {
|
||||
internal constructor() : this(null, null, null, null, null, null, null, null)
|
||||
internal constructor() : this(null, null, null, null, null, null, null, null, mutableMapOf())
|
||||
}
|
||||
|
||||
class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
||||
|
@ -92,6 +93,12 @@ class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
|||
value.mappings?.let { MappingBundleTypeAdapter.write(out, it) } ?: out.nullValue()
|
||||
out.name("mappings_name").value(value.mappingsName)
|
||||
out.name("target_namespace").value(value.targetNamespace)
|
||||
out.name("jar_manifest_properties")
|
||||
out.beginObject()
|
||||
value.jarManifestProperties.forEach { (s, s2) ->
|
||||
out.name(s).value(s2)
|
||||
}
|
||||
out.endObject()
|
||||
out.endObject()
|
||||
}
|
||||
|
||||
|
@ -125,6 +132,12 @@ class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
|||
}
|
||||
} else if (name == "mappings") {
|
||||
data.mappings = MappingBundleTypeAdapter.read(r)
|
||||
} else if (name == "jar_manifest_properties") {
|
||||
r.beginObject()
|
||||
while (r.peek() != JsonToken.END_OBJECT) {
|
||||
data.jarManifestProperties[r.nextName()] = r.nextString()
|
||||
}
|
||||
r.endObject()
|
||||
} else {
|
||||
r.skipValue()
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
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 dev.frogmc.phytotelma.Constants
|
||||
import dev.frogmc.phytotelma.ProjectStorage
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin.Companion.tomlParser
|
||||
import dev.frogmc.phytotelma.PhytotelmaPlugin.Companion.tomlWriter
|
||||
import dev.frogmc.phytotelma.nest.Nester
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
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() {
|
||||
|
||||
|
@ -43,18 +44,20 @@ abstract class PhytotelmaBuildTask : DefaultTask() {
|
|||
if (file.name.endsWith(".jar") && !(file.name.contains("-dev.") || file.name.contains("-sources."))) {
|
||||
Files.copy(file.toPath(), outputFile, StandardCopyOption.REPLACE_EXISTING)
|
||||
FileSystems.newFileSystem(outputFile).use { fs ->
|
||||
|
||||
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: ${ProjectStorage.get(project).intermediaryNs}
|
||||
Built-For: Minecraft ${ProjectStorage.get(project).minecraftVersion}
|
||||
Build-Date: ${LocalDateTime.now()}
|
||||
""".trimIndent()
|
||||
)
|
||||
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
||||
val includeConfiguration = project.configurations.findByName(Constants.INCLUDE_CONFIGURATION)
|
||||
if (includeConfiguration != null) {
|
||||
val jijPath = fs.getPath("META-INF/jars")
|
||||
val files = Nester.run(includeConfiguration, jijPath).map { it.toml() }.toList()
|
||||
if (files.isNotEmpty()) {
|
||||
val metadata = fs.getPath(Constants.MOD_METADATA_FILE)
|
||||
val config: CommentedConfig =
|
||||
tomlParser.parse(metadata, FileNotFoundAction.THROW_ERROR)
|
||||
if (!config.add("frog.extensions.included_jars", 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, metadata, WritingMode.REPLACE)
|
||||
}
|
||||
}
|
||||
}
|
||||
println("Built mod to ${outputFile.toUri()}")
|
||||
}
|
||||
|
|
|
@ -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.mappings.filterClasses
|
||||
import dev.frogmc.phytotelma.mappings.renameDstNamespace
|
||||
import dev.frogmc.phytotelma.mappings.renameNamespaces
|
||||
|
@ -134,6 +135,7 @@ abstract class MinecraftConfiguration @Inject constructor(
|
|||
}
|
||||
mappingsName = "feather(${conf.version.get()})"
|
||||
targetNamespace = "feather"
|
||||
intermediaryNamespace.set("intermediary")
|
||||
return@provider twoStepMappings(
|
||||
"net.ornithemc:calamus-intermediary:${version.get()}:v2",
|
||||
"net.ornithemc:feather:${conf.version.get()}:v2"
|
||||
|
@ -150,6 +152,8 @@ abstract class MinecraftConfiguration @Inject constructor(
|
|||
}
|
||||
mappingsName = "feather(${conf.version.get()})"
|
||||
targetNamespace = "feather-gen2"
|
||||
intermediaryNamespace.set("intermediary")
|
||||
ProjectStorage.get(project).jarManifestProperties["Calamus-Generation"] = "2"
|
||||
return@provider twoStepMappings(
|
||||
"net.ornithemc:calamus-intermediary-gen2:${version.get()}:v2",
|
||||
"net.ornithemc:feather-gen2:${conf.version.get()}:v2"
|
||||
|
|
Loading…
Reference in a new issue