fix nesting bugs
All checks were successful
Publish to snapshot maven / build (push) Successful in 20s
All checks were successful
Publish to snapshot maven / build (push) Successful in 20s
This commit is contained in:
parent
9360e2e4d6
commit
181462f0b4
|
@ -2,6 +2,7 @@ package dev.frogmc.phytotelma.nest
|
|||
|
||||
import com.electronwill.nightconfig.core.Config
|
||||
import com.electronwill.nightconfig.core.UnmodifiableConfig
|
||||
import com.electronwill.nightconfig.toml.TomlParser
|
||||
import com.google.common.jimfs.Jimfs
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
|
@ -34,13 +35,10 @@ object Nester {
|
|||
)
|
||||
}.get()
|
||||
path.createDirectories()
|
||||
val target = path.resolve(location.fileName.toString())
|
||||
Files.copy(location, target)
|
||||
val target = path.resolve(location.file.fileName.toString())
|
||||
Files.copy(location.file, target)
|
||||
files.add(
|
||||
NestedJar(("${dependency.group}_${dependency.name}${if (task.archiveClassifier.isPresent) "_${task.archiveClassifier}" else ""}").replace(
|
||||
"\\.".toRegex(),
|
||||
"_"
|
||||
).lowercase(Locale.ROOT), target.absolute().toString())
|
||||
NestedJar(location.modId, target.absolute().toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -55,17 +53,17 @@ object Nester {
|
|||
memFs
|
||||
)
|
||||
path.createDirectories()
|
||||
val target = path.resolve(location.fileName.toString())
|
||||
Files.copy(location, target)
|
||||
val target = path.resolve(location.file.fileName.toString())
|
||||
|
||||
if (target.notExists()) {
|
||||
Files.copy(location.file, target)
|
||||
files.add(
|
||||
NestedJar(("${dep.moduleGroup}_${dep.moduleName}${if (artifact.classifier != null) "_${artifact.classifier}" else ""}").replace(
|
||||
"\\.".toRegex(),
|
||||
"_"
|
||||
).lowercase(Locale.ROOT), target.absolute().toString())
|
||||
NestedJar(location.modId, target.absolute().toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
|
@ -76,7 +74,7 @@ object Nester {
|
|||
version: String,
|
||||
classifier: String?,
|
||||
memFs: FileSystem
|
||||
): Path {
|
||||
): JarMetadata {
|
||||
FileSystems.newFileSystem(input).use { original ->
|
||||
val toml = original.getPath("frog.mod.toml")
|
||||
if (toml.notExists()) {
|
||||
|
@ -90,13 +88,16 @@ object Nester {
|
|||
)
|
||||
if (tempFile.exists()) {
|
||||
FileSystems.newFileSystem(tempFile).use {
|
||||
if (it.getPath("frog.mod.toml").exists()){
|
||||
return tempFile
|
||||
val metadata = it.getPath("frog.mod.toml")
|
||||
if (metadata.exists()){
|
||||
return JarMetadata(readModId(metadata), tempFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
tempFile.createParentDirectories()
|
||||
input.copyTo(tempFile)
|
||||
val modId = ("${group}_$name${if (classifier != null) "_$classifier" else ""}").replace(
|
||||
"\\.".toRegex(), "_").lowercase(Locale.ROOT)
|
||||
FileSystems.newFileSystem(tempFile).use {
|
||||
it.getPath("frog.mod.toml").writeText(
|
||||
"""
|
||||
|
@ -104,12 +105,7 @@ object Nester {
|
|||
manifest_version = "1.0.0"
|
||||
|
||||
[frog.mod]
|
||||
id = "${
|
||||
("${group}_$name${if (classifier != null) "_$classifier" else ""}").replace(
|
||||
"\\.".toRegex(),
|
||||
"_"
|
||||
).lowercase(Locale.ROOT)
|
||||
}"
|
||||
id = "$modId"
|
||||
name = "$name"
|
||||
version = "${version.replace("(\\d+\\.\\d+\\.\\d+)(.*)".toRegex(), "$1+$2")}"
|
||||
license = ""
|
||||
|
@ -119,13 +115,19 @@ object Nester {
|
|||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
return tempFile
|
||||
return JarMetadata(modId, tempFile)
|
||||
}
|
||||
return input
|
||||
return JarMetadata(readModId(toml), input)
|
||||
}
|
||||
}
|
||||
|
||||
private fun readModId(toml: Path): String {
|
||||
return TomlParser().parse(toml.inputStream()).get("frog.mod.id")
|
||||
}
|
||||
}
|
||||
|
||||
data class JarMetadata(val modId: String, val file: Path)
|
||||
|
||||
class NestedJar(val id: String, val path: String){
|
||||
fun toml(): UnmodifiableConfig {
|
||||
val config = Config.inMemory()
|
||||
|
|
Loading…
Reference in a new issue