[Editor] Connect :editor with :game modules - create Game Engine provider
From now on the editor is able to build an output *.jar file taking the :game *.jar artefact as the base
This commit is contained in:
@@ -47,6 +47,17 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter'
|
||||
}
|
||||
|
||||
task copyGameEngine(type: Copy) {
|
||||
dependsOn(":game:build")
|
||||
|
||||
from project(':game').file('build/libs/game.jar')
|
||||
into file("build/resources/main/engine")
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(copyGameEngine)
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn(":proto:build")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.bartlomiejpluta.base.editor.code.build.game
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import java.io.File
|
||||
|
||||
@Component
|
||||
class DefaultGameEngineProvider : GameEngineProvider {
|
||||
|
||||
override fun provideBaseGameEngine(target: File) {
|
||||
javaClass.getResourceAsStream("/engine/game.jar").use { ris ->
|
||||
target.outputStream().use { fos ->
|
||||
ris.copyTo(fos)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.code.build.game
|
||||
|
||||
import java.io.File
|
||||
|
||||
interface GameEngineProvider {
|
||||
fun provideBaseGameEngine(target: File)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.code.build.pipeline
|
||||
|
||||
import com.bartlomiejpluta.base.editor.code.build.compiler.ScriptCompiler
|
||||
import com.bartlomiejpluta.base.editor.code.build.game.GameEngineProvider
|
||||
import com.bartlomiejpluta.base.editor.code.build.packager.JarPackager
|
||||
import com.bartlomiejpluta.base.editor.project.context.ProjectContext
|
||||
import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
@@ -17,6 +18,9 @@ class DefaultBuildPipelineService : BuildPipelineService {
|
||||
@Autowired
|
||||
private lateinit var packager: JarPackager
|
||||
|
||||
@Autowired
|
||||
private lateinit var engineProvider: GameEngineProvider
|
||||
|
||||
@Autowired
|
||||
private lateinit var projectContext: ProjectContext
|
||||
|
||||
@@ -24,8 +28,11 @@ class DefaultBuildPipelineService : BuildPipelineService {
|
||||
projectContext.project?.let {
|
||||
prepareBuildDirectory(it)
|
||||
|
||||
val outputFile = File(it.buildOutDirectory, OUTPUT_JAR_NAME)
|
||||
|
||||
compiler.compile(it.codeFSNode, it.buildClassesDirectory)
|
||||
packager.pack(it.buildClassesDirectory, File(it.buildOutDirectory, OUTPUT_JAR_NAME))
|
||||
engineProvider.provideBaseGameEngine(outputFile)
|
||||
packager.pack(it.buildClassesDirectory, outputFile, "BOOT-INF/classes")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user