4
0
Fork 0
mirror of https://github.com/Anvilcraft/modpacktools synced 2024-05-19 20:04:07 +02:00

add maven stuff to build.gradle.kts

This commit is contained in:
LordMZTE 2020-08-09 22:56:06 +02:00
parent d20b9f8186
commit e8cfe17c5b
3 changed files with 33 additions and 8 deletions

View file

@ -17,6 +17,7 @@ plugins {
id("java")
id("application")
id("idea")
id("maven-publish")
id("org.jetbrains.kotlin.jvm") version "1.3.72"
id("org.jetbrains.dokka") version "1.4.0-rc"
}
@ -90,6 +91,25 @@ task("fatJar", Jar::class) {
}
archiveBaseName.set(jarName)
from(configurations.runtimeClasspath.get()
.map {if(it.isDirectory) it else zipTree(it)})
.map {if(it.isDirectory) it else zipTree(it)})
with(tasks.jar.get())
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "modpacktools"
artifact(tasks.getByName("fatJar"))
}
}
repositories {
maven {
url = uri("https://data.tilera.xyz/maven/")
credentials {
username = findProperty("mvnUsername") as String?
password = findProperty("mvnPassword") as String?
}
}
}
}

View file

@ -83,12 +83,12 @@ fun runCommand(args: Array<out String>) {
else
errorColor
)
} catch(e: NoSuchElementException) {
} catch(_: NoSuchElementException) {
fPrintln("Command ${args[0]} not found", *errorColor)
println(helpMessage)
} catch(e: CommandLoader.ConfigMissingException) {
} catch(_: CommandLoader.ConfigMissingException) {
fPrintln("Config is needed for this command yet it is not present. Run 'init' to generate", *errorColor)
} catch(e: CommandLoader.ModpackJsonMissingException) {
} catch(_: CommandLoader.ModpackJsonMissingException) {
fPrintln("Modpackjson is needed for this command yet it is not present.", *errorColor)
} catch(e: MissingConfigValueException) {
fPrintln("The Config value ${e.missingValue} was expected but was not found", *errorColor)

View file

@ -36,6 +36,8 @@ import kotlin.reflect.jvm.isAccessible
* @return the file content as JsonObject
*/
fun File.readAsJson(): JsonObject {
require(this.exists()) {"File to read doesn't exist"}
val reader = FileReader(this)
val out = JsonParser.parseReader(reader) as JsonObject
reader.close()
@ -89,8 +91,8 @@ fun URL.httpPostStr(payload: String, contentType: String, additionalHeaders: Map
* @return the sanitized URL
*/
fun URL.sanitize(): URL? {
return try {
fun URL.sanitize(): URL? =
try {
URI(this.protocol,
this.userInfo,
this.host,
@ -101,7 +103,6 @@ fun URL.sanitize(): URL? {
} catch(e: Exception) {
null
}
}
/**
* gets a function from the receiver and makes it accessible
@ -127,6 +128,8 @@ infix fun File.mergeTo(other: File): File = File(this.path, other.name)
* @param zStream the zip stream to write to
*/
fun Path.toZip(zStream: ZipOutputStream) {
require(this.toFile().exists()) {"File must exist"}
Files.walkFileTree(this, object : SimpleFileVisitor<Path>() {
override fun visitFile(file: Path, attrs: BasicFileAttributes?): FileVisitResult {
zStream.putNextEntry(ZipEntry(this@toZip.relativize(file).toString()))
@ -152,6 +155,8 @@ fun File.toZip(zStream: ZipOutputStream) = this.toPath().toZip(zStream)
* @param outputDir the dir to unzip to
*/
fun File.unzip(outputDir: File) {
require(this.exists()) {"File must exist"}
val stream = ZipInputStream(FileInputStream(this))
while(true) {
val entry = stream.nextEntry ?: break