Compare commits
17 Commits
zip
...
ce92e1fae9
| Author | SHA1 | Date | |
|---|---|---|---|
| ce92e1fae9 | |||
| 724f1c87b1 | |||
| 82214d327a | |||
| 92430510b6 | |||
| 8a08520267 | |||
| 0d47b51f3f | |||
| cd628f48b7 | |||
| dc6377179c | |||
| 2c0a1e44ec | |||
| 6f691fcd75 | |||
| 3155a2bbe8 | |||
| 91a82c3736 | |||
| 8ea5207cde | |||
| deb086f4b9 | |||
| c7a199fb2f | |||
| 658ac10375 | |||
| 94269c7a87 |
@@ -39,3 +39,4 @@ node_modules/
|
||||
.yarn-integrity
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
*.zip
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
FROM openjdk:14-alpine as jdkbuilder
|
||||
RUN apk add --no-cache binutils
|
||||
ENV MODULES java.base,java.xml,jdk.httpserver
|
||||
RUN jlink --output /myjdk --module-path $JAVA_HOME/jmods --add-modules $MODULES --no-header-files --no-man-pages --strip-debug --compress=2
|
||||
RUN strip -p --strip-unneeded /myjdk/lib/server/libjvm.so
|
||||
|
||||
FROM maven:3.6.3-jdk-14 as builder
|
||||
WORKDIR /app
|
||||
COPY pom.xml .
|
||||
RUN mvn verify clean --fail-never
|
||||
COPY src/main src/main
|
||||
RUN mvn package
|
||||
|
||||
FROM alpine
|
||||
ENV APPLICATION_USER app
|
||||
RUN adduser -D -g '' $APPLICATION_USER
|
||||
RUN mkdir /app
|
||||
RUN chown -R $APPLICATION_USER /app
|
||||
USER $APPLICATION_USER
|
||||
COPY --from=builder /app/target/kotlin-starter*.jar /app/app.jar
|
||||
COPY --from=jdkbuilder /myjdk /myjdk
|
||||
COPY config.toml /app/config.toml
|
||||
WORKDIR /app
|
||||
EXPOSE 7000
|
||||
CMD ["/myjdk/bin/java", "-server", "-Xmx64m", "-XX:+UseG1GC", "-XX:+UseStringDeduplication", "-jar", "app.jar"]
|
||||
+59
-8
@@ -16,32 +16,53 @@ display = "Java Version"
|
||||
default = "1.4.10"
|
||||
display = "Kotlin Version"
|
||||
|
||||
[repositories]
|
||||
|
||||
[repositories.jcenter]
|
||||
url = "https://jcenter.bintray.com"
|
||||
|
||||
[repositories.arrow]
|
||||
url = "https://dl.bintray.com/arrow-kt/arrow-kt/"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[dependencies.http4k]
|
||||
groupId = "org.http4k"
|
||||
artifactId = "http4k-core"
|
||||
version = "3.260.0"
|
||||
version = "3.261.0"
|
||||
category = "server"
|
||||
default = true
|
||||
|
||||
[dependencies.http4k-server-jetty]
|
||||
groupId = "org.http4k"
|
||||
artifactId = "http4k-server-jetty"
|
||||
version = "3.260.0"
|
||||
version = "3.261.0"
|
||||
category = "server"
|
||||
default = true
|
||||
logger = "org.eclipse.jetty"
|
||||
|
||||
[dependencies.http4k-server-apache]
|
||||
groupId = "org.http4k"
|
||||
artifactId = "http4k-server-apache"
|
||||
version = "3.260.0"
|
||||
version = "3.261.0"
|
||||
category = "server"
|
||||
|
||||
[dependencies.http4k-client-apache]
|
||||
groupId = "org.http4k"
|
||||
artifactId = "http4k-server-apache"
|
||||
version = "3.260.0"
|
||||
artifactId = "http4k-client-apache"
|
||||
version = "3.261.0"
|
||||
category = "server"
|
||||
|
||||
[dependencies.http4k-format-jackson]
|
||||
groupId = "org.http4k"
|
||||
artifactId = "http4k-format-jackson"
|
||||
version = "3.261.0"
|
||||
category = "server"
|
||||
|
||||
[dependencies.http4k-contract]
|
||||
groupId = "org.http4k"
|
||||
artifactId = "http4k-contract"
|
||||
version = "3.261.0"
|
||||
category = "server"
|
||||
|
||||
[dependencies.javalin]
|
||||
@@ -49,12 +70,19 @@ groupId = "io.javalin"
|
||||
artifactId = "javalin"
|
||||
version = "3.10.1"
|
||||
category = "server"
|
||||
logger = "org.eclipse.jetty"
|
||||
|
||||
[dependencies.pebble]
|
||||
groupId = "io.pebbletemplates"
|
||||
artifactId = "pebble"
|
||||
version = "3.1.4"
|
||||
default = true
|
||||
logger = "com.mitchellbosecke.pebble"
|
||||
|
||||
[dependencies.caffeine]
|
||||
groupId = "com.github.ben-manes.caffeine"
|
||||
artifactId = "caffeine"
|
||||
version = "2.8.5"
|
||||
|
||||
[dependencies.logback]
|
||||
groupId = "ch.qos.logback"
|
||||
@@ -79,18 +107,21 @@ groupId = "org.flywaydb"
|
||||
artifactId = "flyway-core"
|
||||
version = "6.5.4"
|
||||
category = "database"
|
||||
logger = "org.flywaydb.core"
|
||||
|
||||
[dependencies.HikariCP]
|
||||
groupId = "com.zaxxer"
|
||||
artifactId = "HikariCP"
|
||||
version = "3.4.5"
|
||||
category = "database"
|
||||
logger = "com.zaxxer.hikari"
|
||||
|
||||
[dependencies.Ktorm]
|
||||
groupId = "me.liuwj.ktorm"
|
||||
artifactId = "ktorm-core"
|
||||
version = "3.0.0"
|
||||
category = "database"
|
||||
logger = "me.liuwj.ktorm.database"
|
||||
|
||||
[dependencies.Ktorm-Mysql]
|
||||
groupId = "me.liuwj.ktorm"
|
||||
@@ -101,7 +132,7 @@ category = "database"
|
||||
[dependencies.junit]
|
||||
groupId = "org.junit.jupiter"
|
||||
artifactId = "junit-jupiter"
|
||||
version = "5.6.2"
|
||||
version = "5.7.0"
|
||||
scope = "test"
|
||||
category = "test"
|
||||
default = true
|
||||
@@ -109,7 +140,7 @@ default = true
|
||||
[dependencies.junit-params]
|
||||
groupId = "org.junit.jupiter"
|
||||
artifactId = "junit-jupiter-params"
|
||||
version = "5.6.2"
|
||||
version = "5.7.0"
|
||||
scope = "test"
|
||||
category = "test"
|
||||
default = true
|
||||
@@ -131,7 +162,7 @@ category = "test"
|
||||
[dependencies.assertJ]
|
||||
groupId = "org.assertj"
|
||||
artifactId = "assertj-core"
|
||||
version = "3.16.1"
|
||||
version = "3.17.2"
|
||||
scope = "test"
|
||||
category = "test"
|
||||
default = true
|
||||
@@ -141,10 +172,30 @@ groupId = "org.kodein.di"
|
||||
artifactId = "kodein-di-jvm"
|
||||
version = "7.0.0"
|
||||
category = "injection"
|
||||
repository = "jcenter"
|
||||
|
||||
[dependencies.Koin]
|
||||
groupId = "org.koin"
|
||||
artifactId = "koin-core"
|
||||
version = "2.1.6"
|
||||
category = "injection"
|
||||
repository = "jcenter"
|
||||
default = true
|
||||
|
||||
[dependencies.Jackson]
|
||||
groupId = "com.fasterxml.jackson.module"
|
||||
artifactId = "jackson-module-kotlin"
|
||||
version = "2.11.2"
|
||||
category = "serialization"
|
||||
|
||||
[dependencies.Kotlinx-serialization]
|
||||
groupId = "org.jetbrains.kotlinx"
|
||||
artifactId = "kotlinx-serialization-runtime"
|
||||
version = "1.0-M1-1.4.0-rc"
|
||||
category = "serialization"
|
||||
|
||||
[dependencies.Arrow-core]
|
||||
groupId = "io.arrow-kt"
|
||||
artifactId = "arrow-core"
|
||||
version = "0.10.5"
|
||||
repository = "arrow"
|
||||
|
||||
@@ -26,11 +26,6 @@
|
||||
<artifactId>pebble</artifactId>
|
||||
<version>3.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.electronwill.night-config</groupId>
|
||||
<artifactId>toml</artifactId>
|
||||
@@ -42,9 +37,9 @@
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.javalin</groupId>
|
||||
<artifactId>javalin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<groupId>org.http4k</groupId>
|
||||
<artifactId>http4k-core</artifactId>
|
||||
<version>3.260.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -74,13 +69,35 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>starter.KotlinStarterKt</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>com.electronwill.night-config:*</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/maven/**</exclude>
|
||||
<exclude>META-INF/proguard/**</exclude>
|
||||
<exclude>META-INF/*.kotlin_module</exclude>
|
||||
<exclude>META-INF/DEPENDENCIES*</exclude>
|
||||
<exclude>META-INF/NOTICE*</exclude>
|
||||
<exclude>META-INF/LICENSE*</exclude>
|
||||
<exclude>LICENSE*</exclude>
|
||||
<exclude>META-INF/README*</exclude>
|
||||
<exclude>META-INF/native-image/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
@@ -3,15 +3,23 @@ package starter
|
||||
import com.electronwill.nightconfig.core.file.FileConfig
|
||||
import com.electronwill.nightconfig.core.Config as NightConfig
|
||||
|
||||
data class StarterConfig(val dependencies: List<Dependency>, val inputs: List<Input>)
|
||||
data class StarterConfig(
|
||||
val dependencies: List<Dependency>,
|
||||
val inputs: List<Input>,
|
||||
val repositories: List<Repository>,
|
||||
)
|
||||
|
||||
class Config {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun FileConfig.configMap(key: String) = this.get<NightConfig>(key).valueMap() as Map<String, NightConfig>
|
||||
|
||||
fun load(): StarterConfig {
|
||||
val cfg = FileConfig.of("config.toml")
|
||||
cfg.load()
|
||||
val dependenciesNode: NightConfig = cfg["dependencies"]
|
||||
@Suppress("UNCHECKED_CAST") val dependenciesMap = dependenciesNode.valueMap() as Map<String, NightConfig>
|
||||
val dependencies = dependenciesMap.map { (name, values) ->
|
||||
|
||||
val dependencies = cfg.configMap("dependencies")
|
||||
.map { (name, values) ->
|
||||
Dependency(
|
||||
name,
|
||||
values["groupId"],
|
||||
@@ -20,16 +28,22 @@ class Config {
|
||||
values.getOrElse("default", false),
|
||||
values.getEnumOrElse("category", Category.Other),
|
||||
values.getEnumOrElse("scope", Scope.Compile),
|
||||
values["logger"],
|
||||
values["repository"],
|
||||
)
|
||||
}
|
||||
|
||||
val inputsNode: NightConfig = cfg["inputs"]
|
||||
@Suppress("UNCHECKED_CAST") val inputMap = inputsNode.valueMap() as Map<String, NightConfig>
|
||||
val inputs = inputMap.map { (name, values) ->
|
||||
val inputs = cfg.configMap("inputs")
|
||||
.map { (name, values) ->
|
||||
Input(name, values["display"], values["default"])
|
||||
}
|
||||
|
||||
return StarterConfig(dependencies, inputs)
|
||||
val repositories = cfg.configMap("repositories")
|
||||
.map { (name, values) ->
|
||||
Repository(name, values["url"])
|
||||
}
|
||||
|
||||
return StarterConfig(dependencies, inputs, repositories)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,7 @@ package starter
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.dsl.bind
|
||||
import org.koin.dsl.module
|
||||
import starter.templates.MainTemplate
|
||||
import starter.templates.PomTemplate
|
||||
import starter.templates.Template
|
||||
import starter.templates.*
|
||||
|
||||
val mainModule = module {
|
||||
single { Config().load() }
|
||||
@@ -18,6 +16,8 @@ val mainModule = module {
|
||||
val templateModule = module {
|
||||
single { PomTemplate(get()) } bind Template::class
|
||||
single { MainTemplate(get()) } bind Template::class
|
||||
single { LogbackTemplate(get()) } bind Template::class
|
||||
single { GitignoreTemplate(get()) } bind Template::class
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package starter
|
||||
|
||||
enum class Category {
|
||||
Server, Injection, Database, Test, Other
|
||||
Server, Injection, Database, Serialization, Test, Other
|
||||
}
|
||||
|
||||
enum class Scope {
|
||||
@@ -15,9 +15,13 @@ data class Dependency(
|
||||
val version: String,
|
||||
val default: Boolean,
|
||||
val category: Category,
|
||||
val scope: Scope
|
||||
val scope: Scope,
|
||||
val logger: String?,
|
||||
val repository: String?,
|
||||
)
|
||||
|
||||
data class Repository(val name: String, val url: String)
|
||||
|
||||
data class Input(val name: String, val display: String, val value: String? = null)
|
||||
|
||||
data class Project(
|
||||
@@ -25,4 +29,5 @@ data class Project(
|
||||
val basePackage: String,
|
||||
val inputs: List<Input>,
|
||||
val dependencies: List<Dependency>,
|
||||
val repositories: List<Repository>,
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ class PebbleModule {
|
||||
loader.suffix = ".twig"
|
||||
return PebbleEngine.Builder()
|
||||
.loader(loader)
|
||||
.cacheActive(false)
|
||||
.cacheActive(true)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,19 @@ package starter
|
||||
import starter.templates.Template
|
||||
import starter.utils.ZipOutput
|
||||
import starter.utils.sanitizeFilename
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
class ProjectZip(private val templates: List<Template>) {
|
||||
|
||||
fun createZip(project: Project): String {
|
||||
val name: String
|
||||
|
||||
ZipOutput(sanitizeFilename(project.name)).use {
|
||||
name = it.name
|
||||
|
||||
templates.forEach { template ->
|
||||
it.write(template.path(project), template.render(project))
|
||||
fun createZip(project: Project): ByteArrayOutputStream {
|
||||
val projectName = sanitizeFilename(project.name)
|
||||
val zipOutput = ZipOutput()
|
||||
zipOutput.use { zip ->
|
||||
templates.filter { it.enabled(project) }.forEach { template ->
|
||||
zip.write(projectName + "/" + template.path(project), template.render(project))
|
||||
}
|
||||
}
|
||||
|
||||
return name
|
||||
return zipOutput.outputStream
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,31 +1,37 @@
|
||||
package starter
|
||||
|
||||
import io.javalin.Javalin
|
||||
import org.http4k.core.HttpHandler
|
||||
import org.http4k.core.Method
|
||||
import org.http4k.core.Response
|
||||
import org.http4k.core.Status
|
||||
import org.http4k.core.body.form
|
||||
import org.http4k.core.body.formAsMap
|
||||
import org.http4k.routing.ResourceLoader
|
||||
import org.http4k.routing.bind
|
||||
import org.http4k.routing.routes
|
||||
import org.http4k.routing.static
|
||||
import org.http4k.server.SunHttp
|
||||
import org.http4k.server.asServer
|
||||
import starter.utils.sanitizeFilename
|
||||
import java.io.File
|
||||
import java.io.ByteArrayInputStream
|
||||
|
||||
class Server(
|
||||
private val views: Views,
|
||||
private val conf: StarterConfig,
|
||||
private val projectZip: ProjectZip,
|
||||
) {
|
||||
|
||||
fun run() {
|
||||
val app = Javalin.create {
|
||||
it.addStaticFiles("/assets")
|
||||
}.start(7000)
|
||||
|
||||
app.get("/") { ctx ->
|
||||
ctx.result(views.index(conf.dependencies, conf.inputs))
|
||||
ctx.contentType("text/html")
|
||||
val indexHandler: HttpHandler = {
|
||||
Response(Status.OK).body(views.index(conf.dependencies, conf.inputs)).header("Content-Type", "text/html")
|
||||
}
|
||||
|
||||
app.post("/") { ctx ->
|
||||
val zipHandler: HttpHandler = { req ->
|
||||
val deps = conf.dependencies.filter {
|
||||
ctx.formParam(it.name) != null
|
||||
req.form(it.name) != null
|
||||
}
|
||||
|
||||
val inputKeys = conf.inputs.map { it.name }
|
||||
val inputs = ctx.formParamMap()
|
||||
val inputs = req.formAsMap()
|
||||
.filter { it.key in inputKeys }
|
||||
.map { (name, value) ->
|
||||
conf.inputs.find { it.name == name }!!.copy(value = value.first())
|
||||
@@ -33,12 +39,30 @@ class Server(
|
||||
|
||||
val projectName = inputs.find { it.name == "name" }!!.value!!
|
||||
val basePackage = inputs.find { it.name == "basePackage" }!!.value!!
|
||||
val project = Project(projectName, basePackage, inputs, deps)
|
||||
|
||||
ctx.contentType("application/zip")
|
||||
ctx.header("Content-Disposition", "attachment; filename=\"${sanitizeFilename(projectName)}.zip\"")
|
||||
val zipFile = projectZip.createZip(project)
|
||||
ctx.result(File(zipFile).readBytes())
|
||||
if (basePackage.contains("/") || basePackage.contains("..")) {
|
||||
Response(Status.BAD_REQUEST).body("Invalid Base Package")
|
||||
} else {
|
||||
val repositories = conf.repositories
|
||||
.filter { repo -> repo.name in deps.mapNotNull { it.repository } }
|
||||
|
||||
val project = Project(projectName, basePackage, inputs, deps, repositories)
|
||||
val outputStream = projectZip.createZip(project)
|
||||
|
||||
Response(Status.OK).header("Content-Type", "application/zip")
|
||||
.header("Content-Disposition", "attachment; filename=\"${sanitizeFilename(projectName)}.zip\"")
|
||||
.body(ByteArrayInputStream(outputStream.toByteArray()))
|
||||
}
|
||||
}
|
||||
|
||||
val app = routes(
|
||||
"/" bind Method.GET to indexHandler,
|
||||
"/" bind Method.POST to zipHandler,
|
||||
static(ResourceLoader.Classpath("/assets"))
|
||||
)
|
||||
|
||||
app.asServer(SunHttp(7000)).start()
|
||||
println("Started on http://localhost:7000")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package starter.templates
|
||||
|
||||
import com.mitchellbosecke.pebble.PebbleEngine
|
||||
import starter.Project
|
||||
import starter.utils.render
|
||||
|
||||
class GitignoreTemplate(private val engine: PebbleEngine) : Template {
|
||||
override fun path(project: Project) =
|
||||
".gitignore"
|
||||
|
||||
override fun render(project: Project) =
|
||||
engine.render("starter/gitignore/index")
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package starter.templates
|
||||
|
||||
import com.mitchellbosecke.pebble.PebbleEngine
|
||||
import starter.Project
|
||||
import starter.utils.prettyPrintXml
|
||||
import starter.utils.render
|
||||
|
||||
class LogbackTemplate(private val engine: PebbleEngine) : Template {
|
||||
override fun path(project: Project) = "src/main/resources/logback.xml"
|
||||
|
||||
override fun enabled(project: Project) = project.dependencies.any { it.name == "logback" }
|
||||
|
||||
override fun render(project: Project): String {
|
||||
val args = mapOf(
|
||||
"loggers" to project.dependencies.mapNotNull { it.logger }.toSet()
|
||||
)
|
||||
val rendered = engine.render("starter/logback/index", args)
|
||||
return prettyPrintXml(rendered)
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import starter.utils.render
|
||||
|
||||
class MainTemplate(private val engine: PebbleEngine) : Template {
|
||||
override fun path(project: Project) =
|
||||
project.basePackage.replace('.', '/') + "/" + project.name.toLowerCase().capitalize() + ".kt"
|
||||
"src/main/kotlin/" + project.basePackage.replace('.', '/') + "/" + project.name.toLowerCase().capitalize() + ".kt"
|
||||
|
||||
override fun render(project: Project) =
|
||||
engine.render("starter/main/main", mapOf("basePackage" to project.basePackage))
|
||||
engine.render("starter/main/index", mapOf("basePackage" to project.basePackage))
|
||||
}
|
||||
|
||||
@@ -11,13 +11,15 @@ class PomTemplate(private val engine: PebbleEngine) : Template {
|
||||
override fun render(project: Project): String {
|
||||
val args: MutableMap<String, Any?> = mutableMapOf(
|
||||
"dependencies" to project.dependencies.sortedBy { it.scope },
|
||||
"repositories" to project.repositories,
|
||||
"kotlinxSerialization" to project.dependencies.any { it.name == "Kotlinx-serialization" },
|
||||
)
|
||||
|
||||
project.inputs.forEach {
|
||||
args[it.name] = it.value
|
||||
}
|
||||
|
||||
val rendered = engine.render("starter/pom/pom", args)
|
||||
val rendered = engine.render("starter/pom/index", args)
|
||||
return prettyPrintXml(rendered)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ import starter.Project
|
||||
|
||||
interface Template {
|
||||
fun path(project: Project): String
|
||||
fun enabled(project: Project): Boolean = true
|
||||
fun render(project: Project): String
|
||||
}
|
||||
|
||||
@@ -2,28 +2,21 @@ package starter.utils
|
||||
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
class ZipOutput(name: String) : AutoCloseable {
|
||||
private val baseDir = File(".").canonicalFile
|
||||
private val zipPath = Paths.get(baseDir.path, "$name.zip")
|
||||
private val zipFile = zipPath.toAbsolutePath().normalize().toFile().apply {
|
||||
createNewFile()
|
||||
}
|
||||
private val outputStream = ZipArchiveOutputStream(zipFile.outputStream())
|
||||
val name: String
|
||||
get() = zipFile.name
|
||||
class ZipOutput : AutoCloseable {
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
private val zipOutputStream = ZipArchiveOutputStream(outputStream)
|
||||
|
||||
fun write(path: String, content: String) {
|
||||
val entry = ZipArchiveEntry(path)
|
||||
outputStream.putArchiveEntry(entry)
|
||||
outputStream.write(content.toByteArray())
|
||||
outputStream.closeArchiveEntry()
|
||||
zipOutputStream.putArchiveEntry(entry)
|
||||
zipOutputStream.write(content.toByteArray())
|
||||
zipOutputStream.closeArchiveEntry()
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
outputStream.finish()
|
||||
outputStream.close()
|
||||
zipOutputStream.finish()
|
||||
zipOutputStream.close()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
target/
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
@@ -9,6 +9,7 @@
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
<logger name="com.mitchellbosecke.pebble" level="INFO"/>
|
||||
<logger name="org.eclipse.jetty" level="INFO"/>
|
||||
{% for logger in loggers %}
|
||||
<logger name="{{ logger }}" level="INFO"/>
|
||||
{% endfor %}
|
||||
</configuration>
|
||||
@@ -1,4 +1,9 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
{% for dep in dependencies %}
|
||||
<dependency>
|
||||
<groupId>{{ dep.groupId }}</groupId>
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
{% if repositories is not empty %}
|
||||
<repositories>
|
||||
{% for repo in repositories %}
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter</name>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
<id>{{ repo.name }}</id>
|
||||
<url>{{ repo.url }}</url>
|
||||
</repository>
|
||||
{% endfor %}
|
||||
</repositories>
|
||||
{% endif %}
|
||||
|
||||
@@ -20,5 +20,19 @@
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>${java.version}</jvmTarget>
|
||||
{% if kotlinxSerialization %}
|
||||
<compilerPlugins>
|
||||
<plugin>kotlinx-serialization</plugin>
|
||||
</compilerPlugins>
|
||||
{% endif %}
|
||||
</configuration>
|
||||
{% if kotlinxSerialization %}
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-serialization</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
{% endif %}
|
||||
</plugin>
|
||||
@@ -9,6 +9,7 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<transformers>
|
||||
<transformer
|
||||
|
||||
Reference in New Issue
Block a user