properly generate and collect and create source sets for jvm+kt+ts (but kotlin multiplatform js doesn't work????)
todo: clean up this is really messy
This commit is contained in:
parent
00b3dc3554
commit
ac8428f36d
6 changed files with 167 additions and 280 deletions
|
|
@ -1,13 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
idea
|
idea
|
||||||
base
|
base
|
||||||
|
|
||||||
// val kotlinVersion = "1.5.31"
|
|
||||||
// kotlin("jvm") version kotlinVersion apply false
|
|
||||||
// kotlin("js") version kotlinVersion apply false
|
|
||||||
// kotlin("multiplatform") version kotlinVersion apply false
|
|
||||||
|
|
||||||
// id("com.github.node-gradle.node") version "3.1.1" apply false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.adamko.factoriowebmap"
|
group = "dev.adamko.factoriowebmap"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.adamko.gradle.pbandg.pattern
|
package dev.adamko.gradle.pbandg.pattern
|
||||||
|
|
||||||
|
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.findByType
|
import org.gradle.kotlin.dsl.findByType
|
||||||
|
|
@ -18,30 +19,36 @@ class KotlinMultiplatformProjectConfiguration : Plugin<Project> {
|
||||||
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||||
project.logger.lifecycle("Kotlin Multiplatform source sets: ${sourceSets.joinToString { "${it.name} / ${it.kotlin.sourceDirectories.files.joinToString()}" }}")
|
project.logger.lifecycle("Kotlin Multiplatform source sets: ${sourceSets.joinToString { "${it.name} / ${it.kotlin.sourceDirectories.files.joinToString()}" }}")
|
||||||
|
|
||||||
sourceSets.whenObjectAdded {
|
// sourceSets.whenObjectAdded {
|
||||||
this.name
|
// this.name
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
val jvmProto = this.sourceSets.maybeCreate("jvmProto").apply {
|
||||||
|
|
||||||
|
kotlin.srcDir(project.layout.pbAndGBuildDir.get().dir("generated-sources/java"))
|
||||||
|
kotlin.srcDir(project.layout.pbAndGBuildDir.get().dir("generated-sources/kotlin"))
|
||||||
|
|
||||||
|
dependsOn(sourceSets.maybeCreate("jvmMain"))
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
val protoJvm = this.sourceSets.maybeCreate("protoJvm").apply {
|
val tsProto = this.sourceSets.maybeCreate("tsProto").apply {
|
||||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
|
||||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
kotlin.srcDir(project.layout.pbAndGBuildDir.get().dir("generated-sources/typescript"))
|
||||||
|
|
||||||
|
dependsOn(sourceSets.maybeCreate("jsMain"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val protoTypescript = this.sourceSets.maybeCreate("protoJvm").apply {
|
// this.sourceSets.findByName("jvmMain")?.apply {
|
||||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
//// protoJvm.dependsOn(this)
|
||||||
}
|
//// dependsOn(protoJvm)
|
||||||
|
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
||||||
this.sourceSets.findByName("jvmMain")?.apply {
|
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
||||||
// protoJvm.dependsOn(this)
|
// }
|
||||||
// dependsOn(protoJvm)
|
// this.sourceSets.findByName("jsMain")?.apply {
|
||||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/java"))
|
//// protoTypescript.dependsOn(this)
|
||||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/kotlin"))
|
//// dependsOn(protoTypescript)
|
||||||
}
|
// kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
||||||
this.sourceSets.findByName("jsMain")?.apply {
|
// }
|
||||||
// protoTypescript.dependsOn(this)
|
|
||||||
// dependsOn(protoTypescript)
|
|
||||||
kotlin.srcDir(project.layout.buildDirectory.dir("pbAndG/generated-sources/typescript"))
|
|
||||||
}
|
|
||||||
|
|
||||||
project.logger.lifecycle("Kotlin Multiplatform source sets: ${sourceSets.joinToString { "${it.name} / ${it.kotlin.sourceDirectories.files.joinToString()}" }}")
|
project.logger.lifecycle("Kotlin Multiplatform source sets: ${sourceSets.joinToString { "${it.name} / ${it.kotlin.sourceDirectories.files.joinToString()}" }}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,11 @@
|
||||||
package dev.adamko.gradle.pbandg
|
package dev.adamko.gradle.pbandg
|
||||||
|
|
||||||
|
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||||
import dev.adamko.gradle.pbandg.pattern.KotlinJvmProjectConfiguration
|
import dev.adamko.gradle.pbandg.pattern.KotlinJvmProjectConfiguration
|
||||||
import dev.adamko.gradle.pbandg.pattern.KotlinMultiplatformProjectConfiguration
|
import dev.adamko.gradle.pbandg.pattern.KotlinMultiplatformProjectConfiguration
|
||||||
import dev.adamko.gradle.pbandg.settings.PBAndGSettings
|
import dev.adamko.gradle.pbandg.settings.PBAndGSettings
|
||||||
import dev.adamko.gradle.pbandg.task.ProtobufCompileTask
|
import dev.adamko.gradle.pbandg.task.ProtobufCompileTask
|
||||||
import dev.adamko.gradle.pbandg.task.ProtobufPrepareLibrariesTask
|
import dev.adamko.gradle.pbandg.task.ProtobufPrepareLibrariesTask
|
||||||
import dev.adamko.gradle.pbandg.task.options.ProtocOutput.JavaOutput
|
|
||||||
import dev.adamko.gradle.pbandg.task.options.ProtocOutput.KotlinOutput
|
|
||||||
|
|
||||||
//plugins {
|
|
||||||
// `kotlin-dsl`
|
|
||||||
//}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
base
|
base
|
||||||
|
|
@ -63,6 +58,9 @@ project.dependencies {
|
||||||
protobufLibraryDependencies("com.google.protobuf:protobuf-javalite:3.19.1")
|
protobufLibraryDependencies("com.google.protobuf:protobuf-javalite:3.19.1")
|
||||||
// implementation("com.google.protobuf:protobuf-javalite:3.19.1")
|
// implementation("com.google.protobuf:protobuf-javalite:3.19.1")
|
||||||
// implementation("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
// implementation("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
||||||
|
// protobufLibraryDependencies("com.google.protobuf:protobuf-javalite:3.19.1")
|
||||||
|
//// implementation("com.google.protobuf:protobuf-javalite:3.19.1")
|
||||||
|
//// implementation("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
val protobufPrepareLibrariesTask =
|
val protobufPrepareLibrariesTask =
|
||||||
|
|
@ -70,12 +68,6 @@ val protobufPrepareLibrariesTask =
|
||||||
librarySources.set(protobufLibraryDependencies)
|
librarySources.set(protobufLibraryDependencies)
|
||||||
}
|
}
|
||||||
|
|
||||||
//project.dependencies {
|
|
||||||
// protobufLibraryDependencies("com.google.protobuf:protobuf-javalite:3.19.1")
|
|
||||||
//// implementation("com.google.protobuf:protobuf-javalite:3.19.1")
|
|
||||||
//// implementation("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
|
||||||
//}
|
|
||||||
|
|
||||||
project.tasks.withType<ProtobufCompileTask> {
|
project.tasks.withType<ProtobufCompileTask> {
|
||||||
dependsOn(protocDep, protobufPrepareLibrariesTask)
|
dependsOn(protocDep, protobufPrepareLibrariesTask)
|
||||||
protobufLibraryDirectories.add(protobufPrepareLibrariesTask.flatMap { it.librariesDirectory })
|
protobufLibraryDirectories.add(protobufPrepareLibrariesTask.flatMap { it.librariesDirectory })
|
||||||
|
|
@ -85,10 +77,25 @@ project.tasks.withType<ProtobufCompileTask> {
|
||||||
protocExecutable.set(exe)
|
protocExecutable.set(exe)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert `.proto` files to Kotlin */
|
val aggregateTask = project.tasks.register<Sync>("protobufCompileAll") {
|
||||||
val pbCompileTask = project.tasks.register<ProtobufCompileTask>(Constants.PBG_TASK_COMPILE) {
|
group = Constants.PBG_TASK_GROUP
|
||||||
protocOutputs += KotlinOutput()
|
|
||||||
protocOutputs += JavaOutput()
|
dependsOn(tasks.withType<ProtobufCompileTask>())
|
||||||
}
|
|
||||||
|
val genSrcDir = project.layout.pbAndGBuildDir.map { it.dir("generated-sources") }
|
||||||
|
|
||||||
|
val pbCompileTasks = tasks.withType<ProtobufCompileTask>()
|
||||||
|
from(pbCompileTasks.map { it.temporaryDir })
|
||||||
|
into(genSrcDir)
|
||||||
|
includeEmptyDirs = false
|
||||||
|
|
||||||
|
}
|
||||||
|
//project.tasks.assemble { dependsOn(aggregateTask) }
|
||||||
|
|
||||||
|
|
||||||
|
///** Convert `.proto` files to Kotlin */
|
||||||
|
//val pbCompileTask = project.tasks.create<ProtobufCompileTask>("protobufJava") {
|
||||||
|
// protocOutputs += KotlinOutput()
|
||||||
|
// protocOutputs += JavaOutput()
|
||||||
|
//}
|
||||||
|
|
||||||
project.tasks.assemble { dependsOn(pbCompileTask) }
|
|
||||||
|
|
@ -1,36 +1,32 @@
|
||||||
package dev.adamko.gradle.pbandg.task
|
package dev.adamko.gradle.pbandg.task
|
||||||
|
|
||||||
import dev.adamko.gradle.pbandg.Constants
|
import dev.adamko.gradle.pbandg.Constants
|
||||||
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
|
||||||
import dev.adamko.gradle.pbandg.task.options.ProtocOutput
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.DomainObjectSet
|
|
||||||
import org.gradle.api.file.Directory
|
import org.gradle.api.file.Directory
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
import org.gradle.api.provider.ListProperty
|
import org.gradle.api.provider.ListProperty
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.provider.Provider
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputFile
|
import org.gradle.api.tasks.InputFile
|
||||||
import org.gradle.api.tasks.InputFiles
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.kotlin.dsl.property
|
import org.gradle.kotlin.dsl.property
|
||||||
|
|
||||||
|
import dev.adamko.gradle.pbandg.Constants.pbAndGBuildDir
|
||||||
|
|
||||||
abstract class ProtobufCompileTask : DefaultTask() {
|
abstract class ProtobufCompileTask : DefaultTask() {
|
||||||
|
|
||||||
@get:InputFile
|
@get:InputFile
|
||||||
abstract val protocExecutable: RegularFileProperty
|
abstract val protocExecutable: RegularFileProperty
|
||||||
|
|
||||||
@get:OutputDirectory
|
|
||||||
val generatedSources: DirectoryProperty = project.objects.directoryProperty()
|
|
||||||
.convention(project.pbAndGBuildDir.map { it.dir("generated-sources") })
|
|
||||||
|
|
||||||
@get:InputFiles
|
@get:InputFiles
|
||||||
abstract val protobufLibraryDirectories: ListProperty<Directory>
|
abstract val protobufLibraryDirectories: ListProperty<Directory>
|
||||||
|
|
||||||
@get:Input
|
// @get:Input
|
||||||
abstract val protocOutputs: DomainObjectSet<ProtocOutput>
|
// abstract val protocOutputs: DomainObjectSet<ProtocOutput>
|
||||||
// = project.objects.domainObjectSet(ProtocOutput::class.java)
|
// = project.objects.domainObjectSet(ProtocOutput::class.java)
|
||||||
|
|
||||||
@get:Input
|
@get:Input
|
||||||
|
|
@ -43,35 +39,37 @@ abstract class ProtobufCompileTask : DefaultTask() {
|
||||||
val cliParamProtoPath: Property<String> =
|
val cliParamProtoPath: Property<String> =
|
||||||
project.objects.property<String>().convention("--proto_path=")
|
project.objects.property<String>().convention("--proto_path=")
|
||||||
|
|
||||||
|
@get:OutputDirectory
|
||||||
|
val outputDir: RegularFileProperty =
|
||||||
|
project.objects.fileProperty().convention { temporaryDir }
|
||||||
|
|
||||||
|
// @get:Internal
|
||||||
|
// val outputPath: Provider<String> = outputDir.map { it.asFile.canonicalPath }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
group = Constants.PBG_TASK_GROUP
|
group = Constants.PBG_TASK_GROUP
|
||||||
}
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun compile() {
|
fun compile() {
|
||||||
|
// prepare directories
|
||||||
val workDir = temporaryDir
|
project.mkdir(outputDir)
|
||||||
// project.delete(workDir)
|
|
||||||
|
|
||||||
project.exec {
|
project.exec {
|
||||||
executable(protocExecutable.asFile.get())
|
executable(protocExecutable.asFile.get())
|
||||||
workingDir(workDir)
|
workingDir(outputDir.asFile.get())
|
||||||
|
|
||||||
// prepare directories
|
// val mapOutputsToOutputDir =
|
||||||
project.mkdir(workingDir)
|
// protocOutputs.associateWith { outputDir.get().asFile.resolve(it.outputDirectoryName) }
|
||||||
project.mkdir(generatedSources)
|
// mapOutputsToOutputDir.values.forEach { project.mkdir(it) }
|
||||||
|
//
|
||||||
val mapOutputsToOutputDir =
|
// // set args
|
||||||
protocOutputs.associateWith { workingDir.resolve(it.outputDirectoryName) }
|
// mapOutputsToOutputDir
|
||||||
mapOutputsToOutputDir.values.forEach { project.mkdir(it) }
|
// .map { (opt, dir) ->
|
||||||
|
// val optionsSuffix = if (opt.protocOptions.isBlank()) "" else ":"
|
||||||
// set args
|
// "${opt.cliParam}=${opt.protocOptions}$optionsSuffix$dir"
|
||||||
mapOutputsToOutputDir
|
// }
|
||||||
.map { (opt, dir) ->
|
// .also { args(it) }
|
||||||
val optionsSuffix = if (opt.protocOptions.isBlank()) "" else ":"
|
|
||||||
"${opt.cliParam}=${opt.protocOptions}$optionsSuffix$dir"
|
|
||||||
}
|
|
||||||
.also { args(it) }
|
|
||||||
args(cliArgs.get())
|
args(cliArgs.get())
|
||||||
|
|
||||||
val protoPath = cliParamProtoPath.get()
|
val protoPath = cliParamProtoPath.get()
|
||||||
|
|
@ -83,76 +81,6 @@ abstract class ProtobufCompileTask : DefaultTask() {
|
||||||
args("$targetProtoFile")
|
args("$targetProtoFile")
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync compiled files
|
|
||||||
project.sync {
|
|
||||||
from(workDir)
|
|
||||||
into(generatedSources)
|
|
||||||
includeEmptyDirs = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean up temp-dir
|
|
||||||
project.delete(workDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
{
|
|
||||||
group = "protobuf"
|
|
||||||
dependsOn(protobufCompiler, protoLibsTask)
|
|
||||||
|
|
||||||
standardOutput = System.out
|
|
||||||
|
|
||||||
executable(protobufCompiler.singleFile)
|
|
||||||
workingDir(temporaryDirFactory)
|
|
||||||
|
|
||||||
val outDir = project.layout.buildDirectory.dir("protobuf/generated-sources")
|
|
||||||
outputs.dir(outDir)
|
|
||||||
|
|
||||||
val protoLibsDir: Provider<File> = protoLibsTask.map { it.destinationDir }
|
|
||||||
|
|
||||||
val javaOut = workingDir.resolve("java")
|
|
||||||
val kotlinOut = workingDir.resolve("kotlin")
|
|
||||||
val protoFile by project.objects.fileProperty()
|
|
||||||
.convention(project.layout.projectDirectory.file("src/main/proto/FactorioServerLogRecord.proto"))
|
|
||||||
|
|
||||||
val protoFileParent = project.provider { protoFile.asFile.parentFile }
|
|
||||||
|
|
||||||
val isLiteEnabled: Boolean by project.objects.property<Boolean>().convention(true)
|
|
||||||
|
|
||||||
doFirst {
|
|
||||||
project.delete(workingDir)
|
|
||||||
|
|
||||||
project.mkdir(outDir)
|
|
||||||
project.mkdir(javaOut)
|
|
||||||
project.mkdir(kotlinOut)
|
|
||||||
|
|
||||||
val liteOpt: String = when (isLiteEnabled) {
|
|
||||||
true -> "lite:"
|
|
||||||
false -> ""
|
|
||||||
}
|
|
||||||
|
|
||||||
args(
|
|
||||||
parseSpaceSeparatedArgs(
|
|
||||||
"""
|
|
||||||
--proto_path=${protoLibsDir.get()}
|
|
||||||
--proto_path=${protoFileParent.get()}
|
|
||||||
--java_out=$liteOpt$javaOut
|
|
||||||
--kotlin_out=$liteOpt$kotlinOut
|
|
||||||
$protoFile
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
doLast {
|
|
||||||
project.sync {
|
|
||||||
from(workingDir)
|
|
||||||
into(outDir)
|
|
||||||
}
|
|
||||||
project.delete(workingDir)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import dev.adamko.gradle.pbandg.task.ProtobufCompileTask
|
import dev.adamko.gradle.pbandg.task.ProtobufCompileTask
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
|
//import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.RootPackageJsonTask
|
//import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.RootPackageJsonTask
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.adamko.factoriowebmap.archetype.base")
|
id("dev.adamko.factoriowebmap.archetype.base")
|
||||||
|
|
@ -21,31 +21,25 @@ dependencies {
|
||||||
// api("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
// api("com.google.protobuf:protobuf-kotlin-lite:3.19.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
idea {
|
|
||||||
workspace {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets.all {
|
// sourceSets.all {
|
||||||
languageSettings.apply {
|
// languageSettings.apply {
|
||||||
languageVersion = "1.5"
|
// languageVersion = "1.5"
|
||||||
// enableLanguageFeature("InlineClasses") // language feature name
|
//// enableLanguageFeature("InlineClasses") // language feature name
|
||||||
optIn("kotlin.OptIn")
|
// optIn("kotlin.OptIn")
|
||||||
optIn("kotlin.ExperimentalStdlibApi")
|
// optIn("kotlin.ExperimentalStdlibApi")
|
||||||
optIn("kotlin.time.ExperimentalTime")
|
// optIn("kotlin.time.ExperimentalTime")
|
||||||
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
|
// optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
|
||||||
optIn("kotlin.js.ExperimentalJsExport")
|
// optIn("kotlin.js.ExperimentalJsExport")
|
||||||
// progressiveMode = true // false by default
|
//// progressiveMode = true // false by default
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//<editor-fold desc="Protobuf">
|
//<editor-fold desc="Protobuf">
|
||||||
sourceSets {
|
// sourceSets {
|
||||||
val proto by creating {
|
// val proto by creating {
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Java">
|
//<editor-fold desc="Java">
|
||||||
|
|
@ -57,6 +51,22 @@ kotlin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold desc="JS">
|
||||||
|
// js(IR) {
|
||||||
|
// binaries.executable()
|
||||||
|
//// browser {
|
||||||
|
////// commonWebpackConfig {
|
||||||
|
////// cssSupport.enabled = true
|
||||||
|
////// }
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// useCommonJs()
|
||||||
|
// nodejs()
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val jvmMain by getting {
|
val jvmMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -66,74 +76,18 @@ kotlin {
|
||||||
}
|
}
|
||||||
val jvmTest by getting {
|
val jvmTest by getting {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//</editor-fold>
|
|
||||||
|
|
||||||
//<editor-fold desc="JS">
|
// val jsMain by getting {
|
||||||
js(IR) {
|
// dependencies {
|
||||||
binaries.executable()
|
// implementation(npm("ts-proto", "1.83.3"))
|
||||||
browser {
|
// }
|
||||||
commonWebpackConfig {
|
// }
|
||||||
cssSupport.enabled = true
|
//
|
||||||
}
|
// val jsTest by getting {
|
||||||
}
|
// dependencies {
|
||||||
|
// implementation(kotlin("test-js"))
|
||||||
useCommonJs()
|
// }
|
||||||
nodejs()
|
// }
|
||||||
|
|
||||||
compilations["main"].apply {
|
|
||||||
packageJson {
|
|
||||||
customField(
|
|
||||||
"scripts",
|
|
||||||
mapOf(
|
|
||||||
"build" to "tstl",
|
|
||||||
"dev" to "tstl --watch",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
|
|
||||||
val jsMain by getting {
|
|
||||||
kotlin.srcDir("externals02")
|
|
||||||
// kotlin.srcDir("externals")
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
val kotlinWrappersVersion = "0.0.1-pre.254-kotlin-1.5.31"
|
|
||||||
implementation(
|
|
||||||
project.dependencies.enforcedPlatform(
|
|
||||||
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
|
|
||||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
|
|
||||||
// implementation(npm("react", "17.0.2"))
|
|
||||||
// implementation(npm("react-dom", "17.0.2"))
|
|
||||||
|
|
||||||
// implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7") {
|
|
||||||
// because("https://github.com/Kotlin/kotlinx-nodejs")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// implementation(npm("typescript-to-lua", "1.0.1"))
|
|
||||||
// implementation(npm("typed-factorio", "0.7.1"))
|
|
||||||
// implementation(npm("lua-types", "2.11.0"))
|
|
||||||
// implementation(npm("typescript", "4.4.3"))
|
|
||||||
|
|
||||||
|
|
||||||
implementation(npm("ts-proto", "1.83.3"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val jsTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-js"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
|
|
@ -142,58 +96,56 @@ kotlin {
|
||||||
//rootProject.tasks.withType<RootPackageJsonTask>().configureEach {
|
//rootProject.tasks.withType<RootPackageJsonTask>().configureEach {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
val rootPackageJson by rootProject.tasks.getting(RootPackageJsonTask::class)
|
//val rootPackageJson by rootProject.tasks.getting(RootPackageJsonTask::class)
|
||||||
val nodePath: Directory by extra {
|
//val nodePath: Directory by extra {
|
||||||
val file = rootPackageJson.rootPackageJson.parentFile.normalize()
|
// val file = rootPackageJson.rootPackageJson.parentFile.normalize()
|
||||||
logger.lifecycle("Kotlin/JS NODE_PATH: $file")
|
// logger.lifecycle("Kotlin/JS NODE_PATH: $file")
|
||||||
project.layout.dir(provider { file }).get()
|
// project.layout.dir(provider { file }).get()
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
val nodeModulesDir: Directory by extra {
|
//val nodeModulesDir: Directory by extra {
|
||||||
val file = nodePath.dir(NpmProject.NODE_MODULES)
|
// val file = nodePath.dir(NpmProject.NODE_MODULES)
|
||||||
logger.lifecycle("Kotlin/JS NODE_MODULES: $file")
|
// logger.lifecycle("Kotlin/JS NODE_MODULES: $file")
|
||||||
file
|
// file
|
||||||
}
|
//}
|
||||||
|
|
||||||
// build/js/node_modules/ts-proto/node_modules/.bin
|
// build/js/node_modules/ts-proto/node_modules/.bin
|
||||||
|
//
|
||||||
tasks.protobufCompile {
|
tasks.register<ProtobufCompileTask>("protobufJava") {
|
||||||
description = "proto2java"
|
description = "proto2java"
|
||||||
protoFile.set(layout.projectDirectory.file("src/proto/FactorioServerLogRecord.proto"))
|
protoFile.set(file("$projectDir/src/proto/FactorioServerLogRecord.proto"))
|
||||||
|
|
||||||
|
cliArgs.add("--java_out=lite:${project.mkdir("$temporaryDir/java").canonicalPath}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.create<ProtobufCompileTask>("protobufKotlin") {
|
||||||
|
description = "proto2kotlin"
|
||||||
|
protoFile.set(file("$projectDir/src/proto/FactorioServerLogRecord.proto"))
|
||||||
|
|
||||||
|
cliArgs.add("--kotlin_out=lite:${project.mkdir("$temporaryDir/kotlin").canonicalPath}")
|
||||||
|
}
|
||||||
|
|
||||||
tasks.create<ProtobufCompileTask>("protobufTypescript") {
|
tasks.create<ProtobufCompileTask>("protobufTypescript") {
|
||||||
description = "proto2typescript"
|
description = "proto2typescript"
|
||||||
|
|
||||||
// data class PluginTs(
|
// linux:
|
||||||
// override val cliParam: String = "--plugin",
|
|
||||||
// override val protocOptions: String = "",
|
|
||||||
// override val outputDirectoryName: String =
|
|
||||||
// "${project.buildDir}/js/packages/factorio-web-map-factorio-events-data-model/node_modules/.bin/protoc-gen-ts_proto.cmd",
|
|
||||||
// ) : ProtocOutput
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// data class OutputTs(
|
|
||||||
// override val cliParam: String = "--ts_proto_out",
|
|
||||||
// override val protocOptions: String = "",
|
|
||||||
// override val outputDirectoryName: String = "${project.buildDir}/pbAndG/generated-sources/typescript",
|
|
||||||
// ) : ProtocOutput
|
|
||||||
//
|
|
||||||
// protocOutputs.add(PluginTs())
|
|
||||||
// protocOutputs.add(OutputTs())
|
|
||||||
|
|
||||||
|
|
||||||
// cliArgs.add("--plugin=${rootProject.buildDir}/js/packages/factorio-web-map-factorio-events-data-model/node_modules/.bin/protoc-gen-ts_proto.cmd")
|
// cliArgs.add("--plugin=${rootProject.buildDir}/js/packages/factorio-web-map-factorio-events-data-model/node_modules/.bin/protoc-gen-ts_proto.cmd")
|
||||||
|
// windows:
|
||||||
cliArgs.add("--plugin=protoc-gen-ts_proto=${rootProject.buildDir}/js/packages/factorio-web-map-factorio-events-data-model/node_modules/.bin/protoc-gen-ts_proto.cmd")
|
cliArgs.add("--plugin=protoc-gen-ts_proto=${rootProject.buildDir}/js/packages/factorio-web-map-factorio-events-data-model/node_modules/.bin/protoc-gen-ts_proto.cmd")
|
||||||
|
|
||||||
val outdir = temporaryDir.resolve("typescript")
|
cliArgs.add("--ts_proto_out=${project.mkdir("$temporaryDir/typescript").canonicalPath}")
|
||||||
val f: File = project.mkdir(outdir)
|
|
||||||
|
|
||||||
cliArgs.add("--ts_proto_out=${outdir.canonicalPath}")
|
cliArgs.addAll(
|
||||||
cliArgs.add("--ts_proto_opt=useOptionals=true")
|
"--ts_proto_opt=useOptionals=true",
|
||||||
// cliArgs.add("--proto_path=${rootProject.rootDir}")
|
"--ts_proto_opt=outputServices=false",
|
||||||
|
"--ts_proto_opt=outputJsonMethods=false",
|
||||||
|
"--ts_proto_opt=outputEncodeMethods=false",
|
||||||
|
"--ts_proto_opt=forceLong=string",
|
||||||
|
"--ts_proto_opt=forceLong=number",
|
||||||
|
"--ts_proto_opt=esModuleInterop=true",
|
||||||
|
"--ts_proto_opt=exportCommonSymbols=false",
|
||||||
|
// "--proto_path=${rootProject.rootDir}",
|
||||||
|
)
|
||||||
|
|
||||||
protoFile.set(layout.projectDirectory.file("src/proto/FactorioServerLogRecord.proto"))
|
protoFile.set(file("$projectDir/src/proto/FactorioServerLogRecord.proto"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ option java_multiple_files = true;
|
||||||
|
|
||||||
package dev.adamko.factorioevents;
|
package dev.adamko.factorioevents;
|
||||||
|
|
||||||
import "google/protobuf/any.proto";
|
//import "google/protobuf/any.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
//import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
message FactorioServerLogRecord {
|
message FactorioServerLogRecord {
|
||||||
string mod_version = 1;
|
string mod_version = 1;
|
||||||
|
|
@ -54,7 +54,7 @@ message LuaPlayer {
|
||||||
|
|
||||||
// https://lua-api.factorio.com/next/LuaEntity.html
|
// https://lua-api.factorio.com/next/LuaEntity.html
|
||||||
message LuaEntity {
|
message LuaEntity {
|
||||||
uint32 unit_number = 1; // (optional) unique ID
|
optional uint32 unit_number = 1; // (optional) unique ID
|
||||||
string name = 2;
|
string name = 2;
|
||||||
string type = 3;
|
string type = 3;
|
||||||
string status = 4; // https://lua-api.factorio.com/next/defines.html#defines.entity_status
|
string status = 4; // https://lua-api.factorio.com/next/defines.html#defines.entity_status
|
||||||
|
|
@ -62,8 +62,8 @@ message LuaEntity {
|
||||||
bool is_active = 8;
|
bool is_active = 8;
|
||||||
bool is_moving = 9;
|
bool is_moving = 9;
|
||||||
|
|
||||||
uint32 player_index = 50; // (optional) The player connected to this character or nil if none.
|
optional uint32 player_index = 50; // (optional) The player connected to this character or nil if none.
|
||||||
uint32 last_user_index = 51; // (optional) The last player that changed any setting on this entity.
|
optional uint32 last_user_index = 51; // (optional) The last player that changed any setting on this entity.
|
||||||
|
|
||||||
Colour colour = 100; // (optional)
|
Colour colour = 100; // (optional)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue