Compare commits
3 Commits
cf09799bc6
...
8e6a14b3e0
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e6a14b3e0 | |||
| a1dde23fb3 | |||
| f0155dea31 |
72
config.toml
72
config.toml
@ -16,6 +16,26 @@ display = "Java Version"
|
|||||||
default = "1.4.10"
|
default = "1.4.10"
|
||||||
display = "Kotlin Version"
|
display = "Kotlin Version"
|
||||||
|
|
||||||
|
[versions]
|
||||||
|
http4k = "3.265.0"
|
||||||
|
pebble = "3.1.4"
|
||||||
|
caffeine = "2.8.5"
|
||||||
|
logback = "1.2.3"
|
||||||
|
mariadb = "2.6.2"
|
||||||
|
h2 = "1.4.200"
|
||||||
|
flyway = "7.0.0"
|
||||||
|
hikaricp = "3.4.5"
|
||||||
|
ktorm = "3.0.0"
|
||||||
|
junit = "5.7.0"
|
||||||
|
mokk = "1.10.0"
|
||||||
|
hamkrest = "1.7.0.3"
|
||||||
|
assertj = "3.17.2"
|
||||||
|
kodein-di = "7.1.0"
|
||||||
|
koin = "2.1.6"
|
||||||
|
jackson = "2.11.2"
|
||||||
|
kotlinx-serialization = "1.0-M1-1.4.0-rc"
|
||||||
|
arrow-core = "0.10.5"
|
||||||
|
|
||||||
[repositories]
|
[repositories]
|
||||||
|
|
||||||
[repositories.jcenter]
|
[repositories.jcenter]
|
||||||
@ -29,14 +49,13 @@ url = "https://dl.bintray.com/arrow-kt/arrow-kt/"
|
|||||||
[dependencies.http4k]
|
[dependencies.http4k]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-core"
|
artifactId = "http4k-core"
|
||||||
version = "3.264.0"
|
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
default = true
|
default = true
|
||||||
|
|
||||||
[dependencies.http4k-server-jetty]
|
[dependencies.http4k-server-jetty]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-server-jetty"
|
artifactId = "http4k-server-jetty"
|
||||||
version = "3.264.0"
|
version = "http4k"
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
default = true
|
default = true
|
||||||
logger = "org.eclipse.jetty"
|
logger = "org.eclipse.jetty"
|
||||||
@ -44,94 +63,85 @@ logger = "org.eclipse.jetty"
|
|||||||
[dependencies.http4k-server-apache]
|
[dependencies.http4k-server-apache]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-server-apache"
|
artifactId = "http4k-server-apache"
|
||||||
version = "3.264.0"
|
version = "http4k"
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
|
|
||||||
[dependencies.http4k-client-apache]
|
[dependencies.http4k-client-apache]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-client-apache"
|
artifactId = "http4k-client-apache"
|
||||||
version = "3.264.0"
|
version = "http4k"
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
|
|
||||||
[dependencies.http4k-format-jackson]
|
[dependencies.http4k-format-jackson]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-format-jackson"
|
artifactId = "http4k-format-jackson"
|
||||||
version = "3.264.0"
|
version = "http4k"
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
|
|
||||||
[dependencies.http4k-format-kotlinx-serialization]
|
[dependencies.http4k-format-kotlinx-serialization]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-format-kotlinx-serialization"
|
artifactId = "http4k-format-kotlinx-serialization"
|
||||||
version = "3.264.0"
|
version = "http4k"
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
|
|
||||||
[dependencies.http4k-contract]
|
[dependencies.http4k-contract]
|
||||||
groupId = "org.http4k"
|
groupId = "org.http4k"
|
||||||
artifactId = "http4k-contract"
|
artifactId = "http4k-contract"
|
||||||
version = "3.264.0"
|
version = "http4k"
|
||||||
category = "http4k"
|
category = "http4k"
|
||||||
|
|
||||||
[dependencies.pebble]
|
[dependencies.pebble]
|
||||||
groupId = "io.pebbletemplates"
|
groupId = "io.pebbletemplates"
|
||||||
artifactId = "pebble"
|
artifactId = "pebble"
|
||||||
version = "3.1.4"
|
|
||||||
default = true
|
default = true
|
||||||
logger = "com.mitchellbosecke.pebble"
|
logger = "com.mitchellbosecke.pebble"
|
||||||
|
|
||||||
[dependencies.caffeine]
|
[dependencies.caffeine]
|
||||||
groupId = "com.github.ben-manes.caffeine"
|
groupId = "com.github.ben-manes.caffeine"
|
||||||
artifactId = "caffeine"
|
artifactId = "caffeine"
|
||||||
version = "2.8.5"
|
|
||||||
|
|
||||||
[dependencies.logback]
|
[dependencies.logback]
|
||||||
groupId = "ch.qos.logback"
|
groupId = "ch.qos.logback"
|
||||||
artifactId = "logback-classic"
|
artifactId = "logback-classic"
|
||||||
version = "1.2.3"
|
|
||||||
default = true
|
default = true
|
||||||
|
|
||||||
[dependencies.mariadb]
|
[dependencies.mariadb]
|
||||||
groupId = "org.mariadb.jdbc"
|
groupId = "org.mariadb.jdbc"
|
||||||
artifactId = "mariadb-java-client"
|
artifactId = "mariadb-java-client"
|
||||||
version = "2.6.2"
|
|
||||||
category = "database"
|
category = "database"
|
||||||
|
|
||||||
[dependencies.h2]
|
[dependencies.h2]
|
||||||
groupId = "com.h2database"
|
groupId = "com.h2database"
|
||||||
artifactId = "h2"
|
artifactId = "h2"
|
||||||
version = "1.4.200"
|
|
||||||
category = "database"
|
category = "database"
|
||||||
|
|
||||||
[dependencies.flyway]
|
[dependencies.flyway]
|
||||||
groupId = "org.flywaydb"
|
groupId = "org.flywaydb"
|
||||||
artifactId = "flyway-core"
|
artifactId = "flyway-core"
|
||||||
version = "6.5.4"
|
|
||||||
category = "database"
|
category = "database"
|
||||||
logger = "org.flywaydb.core"
|
logger = "org.flywaydb.core"
|
||||||
|
|
||||||
[dependencies.HikariCP]
|
[dependencies.hikaricp]
|
||||||
groupId = "com.zaxxer"
|
groupId = "com.zaxxer"
|
||||||
artifactId = "HikariCP"
|
artifactId = "HikariCP"
|
||||||
version = "3.4.5"
|
|
||||||
category = "database"
|
category = "database"
|
||||||
logger = "com.zaxxer.hikari"
|
logger = "com.zaxxer.hikari"
|
||||||
|
|
||||||
[dependencies.Ktorm]
|
[dependencies.ktorm]
|
||||||
groupId = "me.liuwj.ktorm"
|
groupId = "me.liuwj.ktorm"
|
||||||
artifactId = "ktorm-core"
|
artifactId = "ktorm-core"
|
||||||
version = "3.0.0"
|
|
||||||
category = "database"
|
category = "database"
|
||||||
logger = "me.liuwj.ktorm.database"
|
logger = "me.liuwj.ktorm.database"
|
||||||
|
|
||||||
[dependencies.Ktorm-Mysql]
|
[dependencies.ktorm-mysql]
|
||||||
groupId = "me.liuwj.ktorm"
|
groupId = "me.liuwj.ktorm"
|
||||||
artifactId = "ktorm-support-mysql"
|
artifactId = "ktorm-support-mysql"
|
||||||
version = "3.0.0"
|
version = "ktorm"
|
||||||
category = "database"
|
category = "database"
|
||||||
|
|
||||||
[dependencies.junit]
|
[dependencies.junit]
|
||||||
groupId = "org.junit.jupiter"
|
groupId = "org.junit.jupiter"
|
||||||
artifactId = "junit-jupiter"
|
artifactId = "junit-jupiter"
|
||||||
version = "5.7.0"
|
|
||||||
scope = "test"
|
scope = "test"
|
||||||
category = "test"
|
category = "test"
|
||||||
default = true
|
default = true
|
||||||
@ -139,7 +149,7 @@ default = true
|
|||||||
[dependencies.junit-params]
|
[dependencies.junit-params]
|
||||||
groupId = "org.junit.jupiter"
|
groupId = "org.junit.jupiter"
|
||||||
artifactId = "junit-jupiter-params"
|
artifactId = "junit-jupiter-params"
|
||||||
version = "5.7.0"
|
version = "junit"
|
||||||
scope = "test"
|
scope = "test"
|
||||||
category = "test"
|
category = "test"
|
||||||
default = true
|
default = true
|
||||||
@ -147,54 +157,46 @@ default = true
|
|||||||
[dependencies.mokk]
|
[dependencies.mokk]
|
||||||
groupId = "io.mockk"
|
groupId = "io.mockk"
|
||||||
artifactId = "mockk"
|
artifactId = "mockk"
|
||||||
version = "1.10.0"
|
|
||||||
scope = "test"
|
scope = "test"
|
||||||
category = "test"
|
category = "test"
|
||||||
|
|
||||||
[dependencies.hamkrest]
|
[dependencies.hamkrest]
|
||||||
groupId = "com.natpryce"
|
groupId = "com.natpryce"
|
||||||
artifactId = "hamkrest"
|
artifactId = "hamkrest"
|
||||||
version = "1.7.0.3"
|
|
||||||
scope = "test"
|
scope = "test"
|
||||||
category = "test"
|
category = "test"
|
||||||
|
|
||||||
[dependencies.assertJ]
|
[dependencies.assertj]
|
||||||
groupId = "org.assertj"
|
groupId = "org.assertj"
|
||||||
artifactId = "assertj-core"
|
artifactId = "assertj-core"
|
||||||
version = "3.17.2"
|
|
||||||
scope = "test"
|
scope = "test"
|
||||||
category = "test"
|
category = "test"
|
||||||
default = true
|
default = true
|
||||||
|
|
||||||
[dependencies.Kodein-DI]
|
[dependencies.kodein-di]
|
||||||
groupId = "org.kodein.di"
|
groupId = "org.kodein.di"
|
||||||
artifactId = "kodein-di-jvm"
|
artifactId = "kodein-di-jvm"
|
||||||
version = "7.0.0"
|
|
||||||
category = "injection"
|
category = "injection"
|
||||||
repository = "jcenter"
|
repository = "jcenter"
|
||||||
|
|
||||||
[dependencies.Koin]
|
[dependencies.koin]
|
||||||
groupId = "org.koin"
|
groupId = "org.koin"
|
||||||
artifactId = "koin-core"
|
artifactId = "koin-core"
|
||||||
version = "2.1.6"
|
|
||||||
category = "injection"
|
category = "injection"
|
||||||
repository = "jcenter"
|
repository = "jcenter"
|
||||||
default = true
|
default = true
|
||||||
|
|
||||||
[dependencies.Jackson]
|
[dependencies.jackson]
|
||||||
groupId = "com.fasterxml.jackson.module"
|
groupId = "com.fasterxml.jackson.module"
|
||||||
artifactId = "jackson-module-kotlin"
|
artifactId = "jackson-module-kotlin"
|
||||||
version = "2.11.2"
|
|
||||||
category = "serialization"
|
category = "serialization"
|
||||||
|
|
||||||
[dependencies.Kotlinx-serialization]
|
[dependencies.kotlinx-serialization]
|
||||||
groupId = "org.jetbrains.kotlinx"
|
groupId = "org.jetbrains.kotlinx"
|
||||||
artifactId = "kotlinx-serialization-runtime"
|
artifactId = "kotlinx-serialization-runtime"
|
||||||
version = "1.0-M1-1.4.0-rc"
|
|
||||||
category = "serialization"
|
category = "serialization"
|
||||||
|
|
||||||
[dependencies.Arrow-core]
|
[dependencies.arrow-core]
|
||||||
groupId = "io.arrow-kt"
|
groupId = "io.arrow-kt"
|
||||||
artifactId = "arrow-core"
|
artifactId = "arrow-core"
|
||||||
version = "0.10.5"
|
|
||||||
repository = "arrow"
|
repository = "arrow"
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -40,7 +40,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.http4k</groupId>
|
<groupId>org.http4k</groupId>
|
||||||
<artifactId>http4k-core</artifactId>
|
<artifactId>http4k-core</artifactId>
|
||||||
<version>3.260.0</version>
|
<version>3.265.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
|||||||
@ -1,55 +1,10 @@
|
|||||||
package starter
|
package starter
|
||||||
|
|
||||||
import org.http4k.core.then
|
|
||||||
import org.http4k.filter.ServerFilters
|
|
||||||
import org.http4k.routing.ResourceLoader
|
|
||||||
import org.http4k.routing.RoutingHttpHandler
|
|
||||||
import org.http4k.routing.routes
|
|
||||||
import org.http4k.routing.static
|
|
||||||
import org.http4k.server.SunHttp
|
|
||||||
import org.http4k.server.asServer
|
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
import org.koin.dsl.bind
|
import starter.modules.mainModule
|
||||||
import org.koin.dsl.module
|
import starter.modules.pebbleModule
|
||||||
import org.koin.dsl.onClose
|
import starter.modules.routesModule
|
||||||
import org.slf4j.Logger
|
import starter.modules.templateModule
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import starter.routes.IndexRouteSupplier
|
|
||||||
import starter.routes.RouteSupplier
|
|
||||||
import starter.routes.ZipRouteSupplier
|
|
||||||
import starter.routes.toRouter
|
|
||||||
import starter.templates.*
|
|
||||||
|
|
||||||
val mainModule = module {
|
|
||||||
single(createdAtStart = true) {
|
|
||||||
get<Logger>().info("Starting on http://localhost:7000")
|
|
||||||
get<RoutingHttpHandler>().asServer(SunHttp(7000)).start()
|
|
||||||
} onClose { it?.stop() }
|
|
||||||
|
|
||||||
single { Config().load() }
|
|
||||||
single { LoggerFactory.getLogger("Starter") }
|
|
||||||
single { Views(get(), get()) }
|
|
||||||
single { ProjectZip(getAll()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
val routesModule = module {
|
|
||||||
single { IndexRouteSupplier(get()) } bind RouteSupplier::class
|
|
||||||
single { ZipRouteSupplier(get(), get()) } bind RouteSupplier::class
|
|
||||||
single {
|
|
||||||
ServerFilters.CatchAll().then(
|
|
||||||
routes(
|
|
||||||
static(ResourceLoader.Classpath("/assets")),
|
|
||||||
getAll<RouteSupplier>().toRouter()
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
startKoin {
|
startKoin {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ data class Dependency(
|
|||||||
val scope: Scope,
|
val scope: Scope,
|
||||||
val logger: String?,
|
val logger: String?,
|
||||||
val repository: String?,
|
val repository: String?,
|
||||||
|
val versionKey: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Repository(val name: String, val url: String)
|
data class Repository(val name: String, val url: String)
|
||||||
@ -31,3 +32,5 @@ data class Project(
|
|||||||
val dependencies: List<Dependency>,
|
val dependencies: List<Dependency>,
|
||||||
val repositories: List<Repository>,
|
val repositories: List<Repository>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class Version(val name: String, val value: String)
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package starter
|
package starter.config
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.UnmodifiableConfig
|
||||||
import com.electronwill.nightconfig.core.file.FileConfig
|
import com.electronwill.nightconfig.core.file.FileConfig
|
||||||
|
import starter.*
|
||||||
import com.electronwill.nightconfig.core.Config as NightConfig
|
import com.electronwill.nightconfig.core.Config as NightConfig
|
||||||
|
|
||||||
data class StarterConfig(
|
data class StarterConfig(
|
||||||
@ -18,18 +20,25 @@ class Config {
|
|||||||
val cfg = FileConfig.of("config.toml")
|
val cfg = FileConfig.of("config.toml")
|
||||||
cfg.load()
|
cfg.load()
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
val versions = cfg.get<UnmodifiableConfig>("versions").valueMap() as Map<String, String>
|
||||||
|
|
||||||
val dependencies = cfg.configMap("dependencies")
|
val dependencies = cfg.configMap("dependencies")
|
||||||
.map { (name, values) ->
|
.map { (name, values) ->
|
||||||
|
val versionKey: String = values["version"] ?: name
|
||||||
|
val version = versions[versionKey] ?: error("Missing version for $name")
|
||||||
|
|
||||||
Dependency(
|
Dependency(
|
||||||
name,
|
name,
|
||||||
values["groupId"],
|
values["groupId"],
|
||||||
values["artifactId"],
|
values["artifactId"],
|
||||||
values["version"],
|
version,
|
||||||
values.getOrElse("default", false),
|
values.getOrElse("default", false),
|
||||||
values.getEnumOrElse("category", Category.Other),
|
values.getEnumOrElse("category", Category.Other),
|
||||||
values.getEnumOrElse("scope", Scope.Compile),
|
values.getEnumOrElse("scope", Scope.Compile),
|
||||||
values["logger"],
|
values["logger"],
|
||||||
values["repository"],
|
values["repository"],
|
||||||
|
versionKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
24
src/main/kotlin/starter/modules/MainModule.kt
Normal file
24
src/main/kotlin/starter/modules/MainModule.kt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package starter.modules
|
||||||
|
|
||||||
|
import org.http4k.routing.RoutingHttpHandler
|
||||||
|
import org.http4k.server.SunHttp
|
||||||
|
import org.http4k.server.asServer
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import org.koin.dsl.onClose
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import starter.ProjectZip
|
||||||
|
import starter.config.Config
|
||||||
|
import starter.views.Views
|
||||||
|
|
||||||
|
val mainModule = module {
|
||||||
|
single(createdAtStart = true) {
|
||||||
|
get<Logger>().info("Starting on http://localhost:7000")
|
||||||
|
get<RoutingHttpHandler>().asServer(SunHttp(7000)).start()
|
||||||
|
} onClose { it?.stop() }
|
||||||
|
|
||||||
|
single { Config().load() }
|
||||||
|
single { LoggerFactory.getLogger("Starter") }
|
||||||
|
single { Views(get(), get()) }
|
||||||
|
single { ProjectZip(getAll()) }
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package starter
|
package starter.modules
|
||||||
|
|
||||||
import com.mitchellbosecke.pebble.extension.escaper.SafeString
|
import com.mitchellbosecke.pebble.extension.escaper.SafeString
|
||||||
import com.mitchellbosecke.pebble.template.EvaluationContext
|
import com.mitchellbosecke.pebble.template.EvaluationContext
|
||||||
@ -6,6 +6,7 @@ import com.mitchellbosecke.pebble.template.PebbleTemplate
|
|||||||
import org.intellij.lang.annotations.Language
|
import org.intellij.lang.annotations.Language
|
||||||
import org.koin.dsl.bind
|
import org.koin.dsl.bind
|
||||||
import org.koin.dsl.module
|
import org.koin.dsl.module
|
||||||
|
import starter.Dependency
|
||||||
import starter.utils.PebbleEngineBuilder
|
import starter.utils.PebbleEngineBuilder
|
||||||
import starter.utils.PebbleEngineBuilder.CacheType.ConcurrentMap
|
import starter.utils.PebbleEngineBuilder.CacheType.ConcurrentMap
|
||||||
import starter.utils.PebbleFunction
|
import starter.utils.PebbleFunction
|
||||||
25
src/main/kotlin/starter/modules/RoutesModule.kt
Normal file
25
src/main/kotlin/starter/modules/RoutesModule.kt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package starter.modules
|
||||||
|
|
||||||
|
import org.http4k.core.then
|
||||||
|
import org.http4k.filter.ServerFilters
|
||||||
|
import org.http4k.routing.ResourceLoader
|
||||||
|
import org.http4k.routing.routes
|
||||||
|
import org.http4k.routing.static
|
||||||
|
import org.koin.dsl.bind
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import starter.routes.IndexRouteSupplier
|
||||||
|
import starter.routes.RouteSupplier
|
||||||
|
import starter.routes.ZipRouteSupplier
|
||||||
|
import starter.routes.toRouter
|
||||||
|
|
||||||
|
val routesModule = module {
|
||||||
|
single { IndexRouteSupplier(get()) } bind RouteSupplier::class
|
||||||
|
single { ZipRouteSupplier(get(), get()) } bind RouteSupplier::class
|
||||||
|
single {
|
||||||
|
ServerFilters.CatchAll().then(
|
||||||
|
routes(
|
||||||
|
static(ResourceLoader.Classpath("/assets")),
|
||||||
|
getAll<RouteSupplier>().toRouter()
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/main/kotlin/starter/modules/TemplateModule.kt
Normal file
12
src/main/kotlin/starter/modules/TemplateModule.kt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package starter.modules
|
||||||
|
|
||||||
|
import org.koin.dsl.bind
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import starter.templates.*
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@ -4,8 +4,7 @@ import org.http4k.core.Method
|
|||||||
import org.http4k.core.Response
|
import org.http4k.core.Response
|
||||||
import org.http4k.core.Status
|
import org.http4k.core.Status
|
||||||
import org.http4k.routing.bind
|
import org.http4k.routing.bind
|
||||||
import starter.StarterConfig
|
import starter.views.Views
|
||||||
import starter.Views
|
|
||||||
|
|
||||||
class IndexRouteSupplier(private val views: Views) : RouteSupplier {
|
class IndexRouteSupplier(private val views: Views) : RouteSupplier {
|
||||||
override fun get() = "/" bind Method.GET to {
|
override fun get() = "/" bind Method.GET to {
|
||||||
|
|||||||
@ -8,15 +8,15 @@ import org.http4k.core.with
|
|||||||
import org.http4k.routing.bind
|
import org.http4k.routing.bind
|
||||||
import starter.Project
|
import starter.Project
|
||||||
import starter.ProjectZip
|
import starter.ProjectZip
|
||||||
import starter.StarterConfig
|
import starter.config.StarterConfig
|
||||||
import starter.extensions.attachment
|
import starter.extensions.attachment
|
||||||
import starter.extensions.badRequest
|
import starter.extensions.badRequest
|
||||||
import starter.extensions.ok
|
import starter.extensions.ok
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
|
|
||||||
class ZipRouteSupplier(
|
class ZipRouteSupplier(
|
||||||
private val conf: StarterConfig,
|
private val conf: StarterConfig,
|
||||||
private val projectZip: ProjectZip,
|
private val projectZip: ProjectZip,
|
||||||
) : RouteSupplier {
|
) : RouteSupplier {
|
||||||
|
|
||||||
override fun get() = "/" bind Method.POST to { req ->
|
override fun get() = "/" bind Method.POST to { req ->
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package starter.templates
|
|||||||
|
|
||||||
import com.mitchellbosecke.pebble.PebbleEngine
|
import com.mitchellbosecke.pebble.PebbleEngine
|
||||||
import starter.Project
|
import starter.Project
|
||||||
|
import starter.Version
|
||||||
import starter.utils.prettyPrintXml
|
import starter.utils.prettyPrintXml
|
||||||
import starter.utils.render
|
import starter.utils.render
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ class PomTemplate(private val engine: PebbleEngine) : Template {
|
|||||||
"dependencies" to project.dependencies.sortedBy { it.scope },
|
"dependencies" to project.dependencies.sortedBy { it.scope },
|
||||||
"repositories" to project.repositories,
|
"repositories" to project.repositories,
|
||||||
"kotlinxSerialization" to project.dependencies.any { it.name == "Kotlinx-serialization" },
|
"kotlinxSerialization" to project.dependencies.any { it.name == "Kotlinx-serialization" },
|
||||||
|
"versions" to project.dependencies.map { Version(name = it.versionKey, value = it.version) }.toSet()
|
||||||
)
|
)
|
||||||
|
|
||||||
project.inputs.forEach {
|
project.inputs.forEach {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package starter
|
package starter.views
|
||||||
|
|
||||||
import com.mitchellbosecke.pebble.PebbleEngine
|
import com.mitchellbosecke.pebble.PebbleEngine
|
||||||
|
import starter.config.StarterConfig
|
||||||
import starter.utils.render
|
import starter.utils.render
|
||||||
|
|
||||||
class Views(private val engine: PebbleEngine, config: StarterConfig) {
|
class Views(private val engine: PebbleEngine, config: StarterConfig) {
|
||||||
@ -8,9 +8,9 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>{{ dep.groupId }}</groupId>
|
<groupId>{{ dep.groupId }}</groupId>
|
||||||
<artifactId>{{ dep.artifactId }}</artifactId>
|
<artifactId>{{ dep.artifactId }}</artifactId>
|
||||||
<version>{{ dep.version }}</version>
|
<version>{{ "${" }}{{ dep.versionKey }}{{ ".version}" }}</version>
|
||||||
{% if dep.scope == "Test" %}
|
{% if dep.scope == "Test" %}
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dependency>
|
</dependency>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@ -12,6 +12,11 @@
|
|||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<main.class>{{ basePackage }}/{{ name | lower | capitalize }}Kt</main.class>
|
<main.class>{{ basePackage }}/{{ name | lower | capitalize }}Kt</main.class>
|
||||||
|
<!-- versions -->
|
||||||
|
{% for version in versions %}
|
||||||
|
<{{version.name}}.version>{{version.value}}</{{version.name}}.version>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
{% include "starter/pom/@dependencies" %}
|
{% include "starter/pom/@dependencies" %}
|
||||||
@ -20,4 +25,4 @@
|
|||||||
|
|
||||||
{% include "starter/pom/@plugins" %}
|
{% include "starter/pom/@plugins" %}
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user