kotlin 1.6, gradle tidying

This commit is contained in:
Adam 2021-11-26 14:30:06 +01:00
parent b3af697636
commit d6a9a58dc9
14 changed files with 74 additions and 295 deletions

View file

@ -6,7 +6,7 @@
1. converts data to images 1. converts data to images
2. hosts a web map 2. hosts a web map
todo ## todo
* add settings * add settings
* is active - whether files are exported or not * is active - whether files are exported or not
@ -15,7 +15,7 @@ todo
* requires on some sort of in-mod cache of map<entity-id, event>) * requires on some sort of in-mod cache of map<entity-id, event>)
* also divide by game-speed? to keep ratio the same * also divide by game-speed? to keep ratio the same
to investigate: ### to investigate:
* https://github.com/starwing/lua-protobuf * https://github.com/starwing/lua-protobuf
* https://github.com/grafi-tt/lunajson * https://github.com/grafi-tt/lunajson
@ -28,4 +28,9 @@ to investigate:
* https://opensource.expediagroup.com/graphql-kotlin/docs/server/spring-server/spring-subscriptions * https://opensource.expediagroup.com/graphql-kotlin/docs/server/spring-server/spring-subscriptions
* https://github.com/YousefED/typescript-json-schema * https://github.com/YousefED/typescript-json-schema
* https://jbrandhorst.com/post/go-protobuf-tips/ * https://jbrandhorst.com/post/go-protobuf-tips/
#### CBOR
https://www.zash.se/lua-cbor.html
https://code.zash.se/lua-cbor/archive/68b3a36d0816.tar.gz

View file

@ -3,35 +3,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
idea idea
`kotlin-dsl` `kotlin-dsl`
kotlin("jvm") version "1.5.31" kotlin("jvm") version "1.6.0"
`java-gradle-plugin` `java-gradle-plugin`
} }
gradlePlugin {
plugins {
create("tstl") {
id = "dev.adamko.tstl"
description =
"Gradle plugin for TypescriptToLua. Requires plugin `com.github.node-gradle.node`."
implementationClass = "dev.adamko.gradle.tstl.TstlPlugin"
}
create("json-kotlin-schema-gen") {
id = "dev.adamko.json-kotlin-schema-gen"
description =
"Gradle plugin for 'json-kotlin-schema-codegen' - Code generation for JSON Schema (Draft 07) https://github.com/pwall567/json-kotlin-schema-codegen"
implementationClass = "dev.adamko.gradle.jsonkotlinschemagen.JsonKotlinSchemaGenPlugin"
}
}
}
dependencies { dependencies {
val kotlinVersion = "1.5.31" val kotlinVersion = "1.6.0"
// implementation(gradleApi())
// implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:${org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion}")
// implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:${kotlinVersion}")
implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion")) implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion"))
implementation("org.jetbrains.kotlin:kotlin-serialization") implementation("org.jetbrains.kotlin:kotlin-serialization")
@ -39,8 +17,6 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
implementation("com.github.node-gradle:gradle-node-plugin:3.1.1") implementation("com.github.node-gradle:gradle-node-plugin:3.1.1")
implementation("net.pwall.json:json-kotlin-schema-codegen:0.53")
} }
val projectJvmTarget = "11" val projectJvmTarget = "11"
@ -49,8 +25,8 @@ tasks.withType<KotlinCompile>().configureEach {
kotlinOptions { kotlinOptions {
jvmTarget = projectJvmTarget jvmTarget = projectJvmTarget
apiVersion = "1.5" apiVersion = "1.6"
languageVersion = "1.5" languageVersion = "1.6"
} }
kotlinOptions.freeCompilerArgs += listOf( kotlinOptions.freeCompilerArgs += listOf(

View file

@ -0,0 +1,45 @@
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
// https://github.com/gradle/gradle/issues/15754#issuecomment-763614651
// https://github.com/gradle/gradle/blob/09fcaacc9848f09aa584b4119be9271bee6916e6/build-logic/build-logic-base/settings-plugin/src/main/kotlin/gradlebuild.repositories.settings.gradle.kts#L68
// Cannot use 'FAIL_ON_PROJECT_REPOS' because
// - the 'gradle-guides-plugin' adds a repo (which it should not do)
// - the 'kotlin-gradle-plugin' adds a repo (and removes it afterwards) to download NodeJS
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://jitpack.io")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
// Declare the Node.js download repository
ivy("https://nodejs.org/dist/") {
name = "Node Distributions at $url"
patternLayout { artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") }
metadataSources { artifact() }
content { includeModule("org.nodejs", "node") }
}
ivy("https://github.com/yarnpkg/yarn/releases/download") {
name = "Yarn Distributions at $url"
patternLayout { artifact("v[revision]/[artifact](-v[revision]).[ext]") }
metadataSources { artifact() }
content { includeModule("com.yarnpkg", "yarn") }
}
}
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
}
}
}

View file

@ -1,43 +1,3 @@
rootProject.name = "buildSrc" rootProject.name = "buildSrc"
enableFeaturePreview("VERSION_CATALOGS") apply(from = "./repositories.settings.gradle.kts")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
// Declare the Node.js download repository
ivy {
name = "Node.js"
setUrl("https://nodejs.org/dist/")
patternLayout {
artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]")
}
metadataSources {
artifact()
}
content {
includeModule("org.nodejs", "node")
}
}
}
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
}
}
}
}

View file

@ -26,7 +26,7 @@ kotlin {
} }
dependencies { dependencies {
val kotlinWrappersVersion = "0.0.1-pre.263-kotlin-1.5.31" val kotlinWrappersVersion = "0.0.1-pre.270-kotlin-1.6.0"
implementation( implementation(
project.dependencies.enforcedPlatform( project.dependencies.enforcedPlatform(
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}" "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"

View file

@ -36,6 +36,7 @@ dependencies {
testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion") testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
testImplementation("io.kotest:kotest-property-jvm:$kotestVersion") testImplementation("io.kotest:kotest-property-jvm:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-json:$kotestVersion") testImplementation("io.kotest:kotest-assertions-json:$kotestVersion")
testImplementation("io.mockk:mockk:1.12.0") testImplementation("io.mockk:mockk:1.12.0")
//</editor-fold> //</editor-fold>
@ -46,8 +47,8 @@ tasks.withType<KotlinCompile>().configureEach {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
apiVersion = "1.5" apiVersion = "1.6"
languageVersion = "1.5" languageVersion = "1.6"
} }
kotlinOptions.freeCompilerArgs += listOf( kotlinOptions.freeCompilerArgs += listOf(

View file

@ -1,12 +0,0 @@
package dev.adamko.gradle
import org.gradle.kotlin.dsl.`component-model-base`
import org.gradle.kotlin.dsl.kotlin
plugins {
base
}

View file

@ -1,24 +0,0 @@
package dev.adamko.gradle.tstl
import com.github.gradle.node.NodePlugin
import dev.adamko.gradle.tstl.tasks.TypescriptToLuaTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.BasePlugin
import org.gradle.kotlin.dsl.withType
import org.gradle.language.base.plugins.LifecycleBasePlugin
class TstlPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.plugins.withType<NodePlugin> {
}
project.plugins.withType<BasePlugin> {
project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME) {
dependsOn(project.tasks.withType<TypescriptToLuaTask>())
}
}
}
}

View file

@ -1,50 +0,0 @@
package dev.adamko.gradle.tstl.tasks
import com.github.gradle.node.npm.task.*
import org.gradle.api.file.*
import org.gradle.api.provider.*
import org.gradle.api.tasks.*
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
import org.gradle.kotlin.dsl.*
abstract class TypescriptToLuaTask : NpmTask() {
@get:Internal
val intermediateOutputDir: RegularFileProperty = project.objects.fileProperty()
.convention { temporaryDir }
@get:Internal
val intermediateOutputCanonicalPath: Provider<String> =
intermediateOutputDir.map { it.asFile.canonicalPath }
@get:Input
val identifier: Property<String> = project.objects.property<String>().convention(name)
@get:Internal
val luaOutputDirConvention: Provider<Directory> =
project.layout.buildDirectory.map { it.dir("typescriptToLua/${identifier.get()}") }
@get:OutputDirectory
val luaOutputDir: DirectoryProperty = project.objects.directoryProperty()
.convention(luaOutputDirConvention)
init {
group = "typescriptToLua"
execOverrides { standardOutput = System.out }
super.dependsOn(project.tasks.withType<NpmSetupTask>())
ignoreExitValue.set(false)
}
@TaskAction
fun convert() {
args.set(parseSpaceSeparatedArgs("-- --outDir ${intermediateOutputCanonicalPath.get()}"))
project.delete(intermediateOutputDir.get())
super.exec()
}
}

View file

@ -6,7 +6,7 @@
## compilation ## ## compilation ##
jvm = "11" jvm = "11"
kotlin = "1.5.31" kotlin = "1.6.0"
## libs ## ## libs ##
http4k = "4.16.1.0" http4k = "4.16.1.0"
@ -45,9 +45,9 @@ sendgrid = { group = "com.sendgrid", name = "sendgrid-java", version
## kotlin ## ## kotlin ##
kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin" } kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin" }
kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version = "1.3.0" } kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version = "1.3.0" }
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.5.2" } kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.6.0-RC" }
kotlinx-html = { group = "org.jetbrains.kotlinx", name = "kotlinx-html", version = "0.7.3" } kotlinx-html = { group = "org.jetbrains.kotlinx", name = "kotlinx-html", version = "0.7.3" }
## http4k ## ## http4k ##
http4k-bom = { group = "org.http4k", name = "http4k-bom", version.ref = "http4k" } http4k-bom = { group = "org.http4k", name = "http4k-bom", version.ref = "http4k" }

View file

@ -1,4 +1,3 @@
import org.gradle.process.internal.DefaultExecSpec
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
@ -21,8 +20,8 @@ kotlin {
compilations.configureEach { compilations.configureEach {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
apiVersion = "1.5" apiVersion = "1.6"
languageVersion = "1.5" languageVersion = "1.6"
} }
} }
} }
@ -76,7 +75,7 @@ kotlin {
sourceSets.all { sourceSets.all {
languageSettings.apply { languageSettings.apply {
languageVersion = "1.5" languageVersion = "1.6"
// enableLanguageFeature("InlineClasses") // language feature name // enableLanguageFeature("InlineClasses") // language feature name
optIn("kotlin.OptIn") optIn("kotlin.OptIn")
optIn("kotlin.RequiresOptIn") optIn("kotlin.RequiresOptIn")
@ -91,25 +90,8 @@ kotlin {
} }
//kotlin.js()
// .compilations
// .getByName(KotlinCompilation.MAIN_COMPILATION_NAME)
// .npmProject
// .useTool()
afterEvaluate { afterEvaluate {
// val nodeJsExecTstl by tasks.creating(NodeJsExec::class) {
// group = project.name
//
// nodeArgs += listOf(
// "tstl",
// )
// }
val kotlinJsCompilation: KotlinJsCompilation = val kotlinJsCompilation: KotlinJsCompilation =
kotlin.targets kotlin.targets
.flatMap { it.compilations } .flatMap { it.compilations }
@ -124,8 +106,7 @@ afterEvaluate {
errorOutput = System.err errorOutput = System.err
workingDir = npmProject.dir workingDir = npmProject.dir
executable = executable = when (npmProject.nodeJs.requireConfigured().isWindows) {
when (npmProject.nodeJs.requireConfigured().isWindows) {
true -> "npx.cmd" true -> "npx.cmd"
false -> "npx" false -> "npx"
} }
@ -134,58 +115,6 @@ afterEvaluate {
} }
tasks.create("asd") {
group = project.name
doLast {
val execSpec =
project.objects.newInstance(DefaultExecSpec::class.java).apply {
isIgnoreExitValue = false
standardOutput = System.out
errorOutput = System.err
}
kotlin.targets
.flatMap { it.compilations }
.filterIsInstance<KotlinJsCompilation>()
.filter { it.name == KotlinCompilation.MAIN_COMPILATION_NAME }
.forEach {
org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec.create(it, "blahDeBlah") {
}
execSpec.workingDir = it.npmProject.dir
execSpec.executable =
when (it.npmProject.nodeJs.requireConfigured().isWindows) {
true -> "npx.cmd"
false -> "npx"
}
execSpec.args("tstl", "--version")
// execSpec.commandLine
// it.npmProject.useTool(
// execSpec,
// "typescript-to-lua/dist/tstl.js",
// listOf(),
// listOf( "--outDir","$buildDir/testAsd"),
// listOf("--version"),
// listOf(),
// )
}
exec {
execSpec.copyTo(this)
}
}
}
} }

View file

@ -1,13 +1,8 @@
package dev.adamko.factorioevents.model package dev.adamko.factorioevents.model
import dev.adamko.factorioevents.model.FBuiltInType.FNumber.F_float import kotlinx.serialization.SerialName
import dev.adamko.factorioevents.model.FBuiltInType.FNumber.F_int import kotlinx.serialization.Serializable
import dev.adamko.factorioevents.model.FBuiltInType.FNumber.F_uint import kotlinx.serialization.json.JsonClassDiscriminator
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.json.*
import kotlinx.serialization.modules.*
@Serializable @Serializable
@ -44,7 +39,6 @@ data class EntityData(
val player_index: UInt?, val player_index: UInt?,
) : FactorioObjectData ) : FactorioObjectData
data class SurfaceData( data class SurfaceData(
override val objectName: String, override val objectName: String,
val name: String, val name: String,

View file

@ -5,7 +5,6 @@ import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
plugins { plugins {
idea idea
id("dev.adamko.factoriowebmap.archetype.node") id("dev.adamko.factoriowebmap.archetype.node")
id("dev.adamko.tstl")
} }
val projectId: String by project.extra val projectId: String by project.extra

View file

@ -1,58 +1,14 @@
rootProject.name = "factorio-web-map" rootProject.name = "factorio-web-map"
//includeBuild("modules/protoc-gradle-plugin")
include( include(
":modules:mod", ":modules:mod",
// ":modules:server",
":modules:kt-rcon", ":modules:kt-rcon",
":modules:factorio-events-data-model", ":modules:factorio-events-data-model",
// ":modules:factorio-events-data-model2",
":modules:factorio-events-processor", ":modules:factorio-events-processor",
":modules:factorio-events-kafka-pipe", ":modules:factorio-events-kafka-pipe",
) )
enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
@Suppress("UnstableApiUsage") apply(from = "./buildSrc/repositories.settings.gradle.kts")
dependencyResolutionManagement {
// https://github.com/gradle/gradle/issues/15754#issuecomment-763614651
// https://github.com/gradle/gradle/blob/09fcaacc9848f09aa584b4119be9271bee6916e6/build-logic/build-logic-base/settings-plugin/src/main/kotlin/gradlebuild.repositories.settings.gradle.kts#L68
// Cannot use 'FAIL_ON_PROJECT_REPOS' because
// - the 'gradle-guides-plugin' adds a repo (which it should not do)
// - the 'kotlin-gradle-plugin' adds a repo (and removes it afterwards) to download NodeJS
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
mavenCentral()
maven("https://jitpack.io")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
// Declare the Node.js download repository
ivy("https://nodejs.org/dist/") {
name = "Node Distributions at $url"
patternLayout { artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") }
metadataSources { artifact() }
content { includeModule("org.nodejs", "node") }
}
}
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
}
}
}
}