Fix jar
This commit is contained in:
parent
1b84ab88e3
commit
990cdaf1a4
3 changed files with 73 additions and 59 deletions
53
build.gradle
53
build.gradle
|
@ -1,5 +1,7 @@
|
||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
@ -14,7 +16,7 @@ plugins {
|
||||||
id 'kotlin-multiplatform' version '1.3.31'
|
id 'kotlin-multiplatform' version '1.3.31'
|
||||||
id 'kotlinx-serialization' version '1.3.31'
|
id 'kotlinx-serialization' version '1.3.31'
|
||||||
id "org.kravemir.gradle.sass" version "1.2.2"
|
id "org.kravemir.gradle.sass" version "1.2.2"
|
||||||
id "com.github.johnrengelman.shadow" version "4.0.4"
|
id "com.github.johnrengelman.shadow" version "5.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group "de.kif"
|
group "de.kif"
|
||||||
|
@ -144,14 +146,13 @@ sass {
|
||||||
|
|
||||||
|
|
||||||
def webFolder = new File(project.buildDir, "../web")
|
def webFolder = new File(project.buildDir, "../web")
|
||||||
def jsCompilations = kotlin.targets.js.compilations
|
|
||||||
|
|
||||||
task populateWebFolder(dependsOn: [jsMainClasses, sass]) {
|
task populateWebFolder(dependsOn: [jsMainClasses, sass]) {
|
||||||
doLast {
|
doLast {
|
||||||
copy {
|
copy {
|
||||||
from jsCompilations.main.output
|
from kotlin.targets.js.compilations.main.output
|
||||||
from kotlin.sourceSets.jsMain.resources.srcDirs
|
from kotlin.sourceSets.jsMain.resources.srcDirs
|
||||||
jsCompilations.test.runtimeDependencyFiles.each {
|
kotlin.targets.js.compilations.test.runtimeDependencyFiles.files.each {
|
||||||
if (it.exists() && !it.isDirectory()) {
|
if (it.exists() && !it.isDirectory()) {
|
||||||
from zipTree(it.absolutePath).matching {
|
from zipTree(it.absolutePath).matching {
|
||||||
include '*.js'
|
include '*.js'
|
||||||
|
@ -166,7 +167,7 @@ task populateWebFolder(dependsOn: [jsMainClasses, sass]) {
|
||||||
|
|
||||||
jsJar.dependsOn(populateWebFolder)
|
jsJar.dependsOn(populateWebFolder)
|
||||||
|
|
||||||
def mainClassName = 'de.kif.backend.Main'
|
def mainClassName = 'de.kif.backend.MainKt'
|
||||||
|
|
||||||
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
|
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
|
||||||
main = mainClassName
|
main = mainClassName
|
||||||
|
@ -186,25 +187,39 @@ clean.doFirst {
|
||||||
delete "data"
|
delete "data"
|
||||||
}
|
}
|
||||||
|
|
||||||
task jar(type: ShadowJar, dependsOn: [jvmMainClasses, jsMainClasses, sass]) {
|
jsJar {
|
||||||
|
from webFolder
|
||||||
|
}
|
||||||
|
|
||||||
|
static String buildTime() {
|
||||||
|
def format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")
|
||||||
|
format.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||||
|
return format.format(new Date())
|
||||||
|
}
|
||||||
|
|
||||||
|
task jar(type: ShadowJar, dependsOn: [assemble]) {
|
||||||
|
//minimize()
|
||||||
|
|
||||||
|
from(webFolder) {
|
||||||
|
into "web"
|
||||||
|
includeEmptyDirs false
|
||||||
|
exclude "*.js.map", "*.meta.js", "**/*.scss", "**/_*.css", "**/*.kjsm", "*.MF"
|
||||||
|
}
|
||||||
|
|
||||||
|
from kotlin.targets.jvm.compilations.main.runtimeDependencyFiles
|
||||||
from kotlin.targets.jvm.compilations.main.output
|
from kotlin.targets.jvm.compilations.main.output
|
||||||
|
|
||||||
from(kotlin.targets.js.compilations.main.output) {
|
exclude "**/INDEX.LIST", "**/*.SF", "**/*.RSA"
|
||||||
into "web"
|
|
||||||
exclude '*.meta.js'
|
|
||||||
}
|
|
||||||
from(kotlin.sourceSets.jsMain.resources.srcDirs) {
|
|
||||||
into "web"
|
|
||||||
exclude '*.meta.js'
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations = [kotlin.targets.jvm.compilations.main.compileDependencyFiles]
|
archiveBaseName.set rootProject.name
|
||||||
|
archiveClassifier.set null
|
||||||
baseName = rootProject.name
|
archiveVersion.set null
|
||||||
classifier = null
|
|
||||||
version = null
|
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Main-Class': mainClassName
|
attributes 'Main-Class': mainClassName
|
||||||
|
attributes "Build-Time": buildTime()
|
||||||
|
attributes "Build-Version": project.version
|
||||||
|
attributes "Build-Tools": "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}, java-${System.getProperty('java.version')}"
|
||||||
|
attributes "Build-System": "${System.getProperty("os.name")} '${System.getProperty("os.version")}' (${System.getProperty("os.arch")})"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,9 @@ import io.ktor.application.Application
|
||||||
import io.ktor.server.engine.embeddedServer
|
import io.ktor.server.engine.embeddedServer
|
||||||
import io.ktor.server.netty.Netty
|
import io.ktor.server.netty.Netty
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
object Main {
|
@Suppress("UnusedMainParameter")
|
||||||
@Suppress("UnusedMainParameter")
|
fun main(args: Array<String>) {
|
||||||
@JvmStatic
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
Resources.init()
|
Resources.init()
|
||||||
|
|
||||||
Connection.init()
|
Connection.init()
|
||||||
|
@ -56,5 +53,4 @@ object Main {
|
||||||
host = Configuration.Server.host,
|
host = Configuration.Server.host,
|
||||||
module = Application::main
|
module = Application::main
|
||||||
).start(wait = true)
|
).start(wait = true)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@ object Resources {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
destination.toFile().deleteRecursively()
|
||||||
|
|
||||||
val fileSystem: FileSystem?
|
val fileSystem: FileSystem?
|
||||||
val src: Path = if (uri.scheme == "jar") {
|
val src: Path = if (uri.scheme == "jar") {
|
||||||
fileSystem = FileSystems.newFileSystem(uri, mutableMapOf<String, Any?>())
|
fileSystem = FileSystems.newFileSystem(uri, mutableMapOf<String, Any?>())
|
||||||
|
|
Loading…
Reference in a new issue