mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-19 15:20:55 +00:00
build: make available via maven repo
This commit is contained in:
@@ -4,9 +4,11 @@ import java.io.File
|
|||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.nio.file.FileSystems
|
import java.nio.file.FileSystems
|
||||||
|
import java.nio.file.Path
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.plugins.BasePluginExtension
|
import org.gradle.api.plugins.BasePluginExtension
|
||||||
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.gradle.kotlin.dsl.apply
|
import org.gradle.kotlin.dsl.apply
|
||||||
import org.gradle.kotlin.dsl.configure
|
import org.gradle.kotlin.dsl.configure
|
||||||
import org.gradle.kotlin.dsl.extra
|
import org.gradle.kotlin.dsl.extra
|
||||||
@@ -19,6 +21,25 @@ import kotlin.io.path.createDirectories
|
|||||||
import kotlin.io.path.createFile
|
import kotlin.io.path.createFile
|
||||||
import kotlin.io.path.exists
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
|
private fun Project.installAddonsInto(dest: Path) {
|
||||||
|
FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
|
||||||
|
forSubProjects(":common:addons") {
|
||||||
|
val jar = getJarTask()
|
||||||
|
|
||||||
|
logger.info("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
|
||||||
|
|
||||||
|
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||||
|
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")
|
||||||
|
|
||||||
|
if (!addonPath.exists()) {
|
||||||
|
addonPath.parent.createDirectories()
|
||||||
|
addonPath.createFile()
|
||||||
|
jar.archiveFile.get().asFile.toPath().copyTo(addonPath, overwrite = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Project.configureDistribution() {
|
fun Project.configureDistribution() {
|
||||||
apply(plugin = "com.gradleup.shadow")
|
apply(plugin = "com.gradleup.shadow")
|
||||||
@@ -48,25 +69,17 @@ fun Project.configureDistribution() {
|
|||||||
doLast {
|
doLast {
|
||||||
// https://github.com/johnrengelman/shadow/issues/111
|
// https://github.com/johnrengelman/shadow/issues/111
|
||||||
val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().path
|
val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().path
|
||||||
|
installAddonsInto(dest)
|
||||||
|
}
|
||||||
FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
|
}
|
||||||
forSubProjects(":common:addons") {
|
|
||||||
val jar = getJarTask()
|
tasks.create("installAddonsIntoDefaultJar") {
|
||||||
|
group = "terra"
|
||||||
logger.info("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
|
dependsOn(compileAddons)
|
||||||
|
|
||||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
doLast {
|
||||||
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")
|
val dest = tasks.named<Jar>("jar").get().archiveFile.get().path
|
||||||
|
installAddonsInto(dest)
|
||||||
if (!addonPath.exists()) {
|
|
||||||
addonPath.parent.createDirectories()
|
|
||||||
addonPath.createFile()
|
|
||||||
jar.archiveFile.get().asFile.toPath().copyTo(addonPath, overwrite = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ application {
|
|||||||
mainClass.set(javaMainClass)
|
mainClass.set(javaMainClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named("jar") {
|
||||||
|
finalizedBy("installAddonsIntoDefaultJar")
|
||||||
|
}
|
||||||
|
|
||||||
tasks.getByName("run").setProperty("workingDir", file("./run"))
|
tasks.getByName("run").setProperty("workingDir", file("./run"))
|
||||||
|
|
||||||
addonDir(project.file("./run/terra/addons"), tasks.named("run").get())
|
addonDir(project.file("./run/terra/addons"), tasks.named("run").get())
|
||||||
|
|||||||
Reference in New Issue
Block a user