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"
|
group = "dev.frogmc"
|
||||||
version = "0.0.1-alpha.21"
|
version = "0.0.1-alpha.22"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
|
|
|
@ -39,10 +39,12 @@ import org.objectweb.asm.commons.ClassRemapper
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
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.FileSystems
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
|
import java.time.LocalDateTime
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.*
|
||||||
|
|
||||||
|
@ -215,24 +217,23 @@ class PhytotelmaPlugin : Plugin<Project> {
|
||||||
storage.mappings!!.reverse(), it
|
storage.mappings!!.reverse(), it
|
||||||
)
|
)
|
||||||
} ?: storage.mappings!!).forNamespaces(storage.targetNamespace, storage.intermediaryNs)
|
} ?: storage.mappings!!).forNamespaces(storage.targetNamespace, storage.intermediaryNs)
|
||||||
val includeConfiguration = project.configurations.findByName(Constants.INCLUDE_CONFIGURATION)
|
|
||||||
task.outputs.files.forEach { file ->
|
task.outputs.files.forEach { file ->
|
||||||
val temp = Files.createTempFile("", file.name)
|
val temp = Files.createTempFile("", file.name)
|
||||||
Files.copy(file.toPath(), temp, StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(file.toPath(), temp, StandardCopyOption.REPLACE_EXISTING)
|
||||||
FileSystems.newFileSystem(temp).use { fs ->
|
FileSystems.newFileSystem(temp).use { fs ->
|
||||||
if (includeConfiguration != null) {
|
val data = ProjectStorage.get(project)
|
||||||
val jijPath = fs.getPath("META-INF/jars")
|
val manifest = fs.getPath("META-INF/MANIFEST.MF")
|
||||||
val files = Nester.run(includeConfiguration, jijPath).map { it.toml() }.toList()
|
val lines = manifest.readLines().filter { it.isNotBlank() }
|
||||||
if (files.isNotEmpty()) {
|
.plus(
|
||||||
val manifest = fs.getPath(Constants.MOD_METADATA_FILE)
|
"""
|
||||||
val config: CommentedConfig =
|
Built-By: Phytotelma ${this.javaClass.`package`.implementationVersion}
|
||||||
tomlParser.parse(manifest, FileNotFoundAction.THROW_ERROR)
|
Target-Namespace: ${data.intermediaryNs}
|
||||||
if (!config.add("frog.extensions.included_jars", files)) {
|
Built-For: Minecraft ${data.minecraftVersion}
|
||||||
println("Failed to add included jars to mod manifest, make sure it doesn't include a key at 'frog.extensions.included_jars'!")
|
Build-Date: ${LocalDateTime.now()}
|
||||||
}
|
""".trimIndent()
|
||||||
tomlWriter.write(config, manifest, WritingMode.REPLACE)
|
).plus(data.jarManifestProperties.entries.joinToString("\n") { it.key+": "+it.value})
|
||||||
}
|
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
||||||
}
|
|
||||||
val metadata = fs.getPath(Constants.MOD_METADATA_FILE)
|
val metadata = fs.getPath(Constants.MOD_METADATA_FILE)
|
||||||
tomlParser.parse(metadata, FileNotFoundAction.READ_NOTHING)
|
tomlParser.parse(metadata, FileNotFoundAction.READ_NOTHING)
|
||||||
.get<String>("frog.extensions.accesswidener")?.let { name ->
|
.get<String>("frog.extensions.accesswidener")?.let { name ->
|
||||||
|
|
|
@ -76,9 +76,10 @@ class ProjectData(
|
||||||
var mappingsName: String?,
|
var mappingsName: String?,
|
||||||
var intermediaryNs: String?,
|
var intermediaryNs: String?,
|
||||||
var targetNamespace: 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>() {
|
class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
||||||
|
@ -92,6 +93,12 @@ class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
||||||
value.mappings?.let { MappingBundleTypeAdapter.write(out, it) } ?: out.nullValue()
|
value.mappings?.let { MappingBundleTypeAdapter.write(out, it) } ?: out.nullValue()
|
||||||
out.name("mappings_name").value(value.mappingsName)
|
out.name("mappings_name").value(value.mappingsName)
|
||||||
out.name("target_namespace").value(value.targetNamespace)
|
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()
|
out.endObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +132,12 @@ class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
|
||||||
}
|
}
|
||||||
} else if (name == "mappings") {
|
} else if (name == "mappings") {
|
||||||
data.mappings = MappingBundleTypeAdapter.read(r)
|
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 {
|
} else {
|
||||||
r.skipValue()
|
r.skipValue()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
package dev.frogmc.phytotelma.build
|
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.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.DefaultTask
|
||||||
import org.gradle.api.tasks.OutputFile
|
import org.gradle.api.tasks.OutputFile
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||||
import java.nio.charset.StandardCharsets
|
|
||||||
import java.nio.file.FileSystems
|
import java.nio.file.FileSystems
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
import java.time.LocalDateTime
|
|
||||||
import kotlin.io.path.createDirectories
|
import kotlin.io.path.createDirectories
|
||||||
import kotlin.io.path.readLines
|
|
||||||
import kotlin.io.path.writeLines
|
|
||||||
|
|
||||||
abstract class PhytotelmaBuildTask : DefaultTask() {
|
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."))) {
|
if (file.name.endsWith(".jar") && !(file.name.contains("-dev.") || file.name.contains("-sources."))) {
|
||||||
Files.copy(file.toPath(), outputFile, StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(file.toPath(), outputFile, StandardCopyOption.REPLACE_EXISTING)
|
||||||
FileSystems.newFileSystem(outputFile).use { fs ->
|
FileSystems.newFileSystem(outputFile).use { fs ->
|
||||||
|
val includeConfiguration = project.configurations.findByName(Constants.INCLUDE_CONFIGURATION)
|
||||||
val manifest = fs.getPath("META-INF/MANIFEST.MF")
|
if (includeConfiguration != null) {
|
||||||
val lines = manifest.readLines().filter { it.isNotBlank() }
|
val jijPath = fs.getPath("META-INF/jars")
|
||||||
.plus(
|
val files = Nester.run(includeConfiguration, jijPath).map { it.toml() }.toList()
|
||||||
"""
|
if (files.isNotEmpty()) {
|
||||||
Built-By: Phytotelma ${this.javaClass.`package`.implementationVersion}
|
val metadata = fs.getPath(Constants.MOD_METADATA_FILE)
|
||||||
Target-Namespace: ${ProjectStorage.get(project).intermediaryNs}
|
val config: CommentedConfig =
|
||||||
Built-For: Minecraft ${ProjectStorage.get(project).minecraftVersion}
|
tomlParser.parse(metadata, FileNotFoundAction.THROW_ERROR)
|
||||||
Build-Date: ${LocalDateTime.now()}
|
if (!config.add("frog.extensions.included_jars", files)) {
|
||||||
""".trimIndent()
|
println("Failed to add included jars to mod manifest, make sure it doesn't include a key at 'frog.extensions.included_jars'!")
|
||||||
)
|
}
|
||||||
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
tomlWriter.write(config, metadata, WritingMode.REPLACE)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
println("Built mod to ${outputFile.toUri()}")
|
println("Built mod to ${outputFile.toUri()}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package dev.frogmc.phytotelma.ext
|
||||||
|
|
||||||
import dev.frogmc.phytotelma.Constants
|
import dev.frogmc.phytotelma.Constants
|
||||||
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
import dev.frogmc.phytotelma.PhytotelmaPlugin
|
||||||
|
import dev.frogmc.phytotelma.ProjectStorage
|
||||||
import dev.frogmc.phytotelma.mappings.filterClasses
|
import dev.frogmc.phytotelma.mappings.filterClasses
|
||||||
import dev.frogmc.phytotelma.mappings.renameDstNamespace
|
import dev.frogmc.phytotelma.mappings.renameDstNamespace
|
||||||
import dev.frogmc.phytotelma.mappings.renameNamespaces
|
import dev.frogmc.phytotelma.mappings.renameNamespaces
|
||||||
|
@ -134,6 +135,7 @@ abstract class MinecraftConfiguration @Inject constructor(
|
||||||
}
|
}
|
||||||
mappingsName = "feather(${conf.version.get()})"
|
mappingsName = "feather(${conf.version.get()})"
|
||||||
targetNamespace = "feather"
|
targetNamespace = "feather"
|
||||||
|
intermediaryNamespace.set("intermediary")
|
||||||
return@provider twoStepMappings(
|
return@provider twoStepMappings(
|
||||||
"net.ornithemc:calamus-intermediary:${version.get()}:v2",
|
"net.ornithemc:calamus-intermediary:${version.get()}:v2",
|
||||||
"net.ornithemc:feather:${conf.version.get()}:v2"
|
"net.ornithemc:feather:${conf.version.get()}:v2"
|
||||||
|
@ -150,6 +152,8 @@ abstract class MinecraftConfiguration @Inject constructor(
|
||||||
}
|
}
|
||||||
mappingsName = "feather(${conf.version.get()})"
|
mappingsName = "feather(${conf.version.get()})"
|
||||||
targetNamespace = "feather-gen2"
|
targetNamespace = "feather-gen2"
|
||||||
|
intermediaryNamespace.set("intermediary")
|
||||||
|
ProjectStorage.get(project).jarManifestProperties["Calamus-Generation"] = "2"
|
||||||
return@provider twoStepMappings(
|
return@provider twoStepMappings(
|
||||||
"net.ornithemc:calamus-intermediary-gen2:${version.get()}:v2",
|
"net.ornithemc:calamus-intermediary-gen2:${version.get()}:v2",
|
||||||
"net.ornithemc:feather-gen2:${conf.version.get()}:v2"
|
"net.ornithemc:feather-gen2:${conf.version.get()}:v2"
|
||||||
|
|
Loading…
Reference in a new issue