Bug 43: Add TeaVM support to Open Eggbert II
This commit is contained in:
parent
3cfbd07654
commit
9c0dd4cff9
.gitignorebuild.gradle
core
build.gradle
src/main/java/com/openeggbert/core
html/src/test/java
lwjgl3
teavm
2
.gitignore
vendored
2
.gitignore
vendored
@ -153,6 +153,8 @@ Thumbs.db
|
||||
*.*#
|
||||
*#*#
|
||||
/assets/assets.txt
|
||||
/assets/assets_.txt
|
||||
|
||||
|
||||
## Special cases:
|
||||
|
||||
|
151
build.gradle
151
build.gradle
@ -1,82 +1,109 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://s01.oss.sonatype.org' }
|
||||
maven { url 'https://repo.openeggbert.com' }
|
||||
gradlePluginPortal()
|
||||
mavenLocal()
|
||||
google()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://repo.openeggbert.com/releases/' }
|
||||
maven { url 'https://repo.openeggbert.com/snapshots/' }
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:8.1.4"
|
||||
classpath "io.freefair.gradle:lombok-plugin:8.3"
|
||||
classpath "org.docstr:gwt-gradle-plugin:$gwtPluginVersion"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://s01.oss.sonatype.org' }
|
||||
maven { url 'https://repo.openeggbert.com' }
|
||||
gradlePluginPortal()
|
||||
mavenLocal()
|
||||
google()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://repo.openeggbert.com/releases/' }
|
||||
maven { url 'https://repo.openeggbert.com/snapshots/' }
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:8.1.4"
|
||||
classpath "io.freefair.gradle:lombok-plugin:8.3"
|
||||
classpath "org.docstr:gwt-gradle-plugin:$gwtPluginVersion"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
|
||||
// This allows you to "Build and run using IntelliJ IDEA", an option in IDEA's Settings.
|
||||
idea {
|
||||
module {
|
||||
outputDir file('build/classes/java/main')
|
||||
testOutputDir file('build/classes/java/test')
|
||||
// This allows you to "Build and run using IntelliJ IDEA", an option in IDEA's Settings.
|
||||
idea {
|
||||
module {
|
||||
outputDir file('build/classes/java/main')
|
||||
testOutputDir file('build/classes/java/test')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure(subprojects - project(':android')) {
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'io.freefair.lombok'
|
||||
sourceCompatibility = 11
|
||||
compileJava {
|
||||
options.incremental = true
|
||||
}
|
||||
// From https://lyze.dev/2021/04/29/libGDX-Internal-Assets-List/
|
||||
// The article can be helpful when using assets.txt in your project.
|
||||
compileJava.doLast {
|
||||
// projectFolder/assets
|
||||
def assetsFolder = new File("${project.rootDir}/assets/")
|
||||
// projectFolder/assets/assets.txt
|
||||
def assetsFile = new File(assetsFolder, "assets.txt")
|
||||
// delete that file in case we've already created it
|
||||
assetsFile.delete()
|
||||
|
||||
// iterate through all files inside that folder
|
||||
// convert it to a relative path
|
||||
// and append it to the file assets.txt
|
||||
fileTree(assetsFolder).collect { assetsFolder.relativePath(it) }.each {
|
||||
assetsFile.append(it + "\n")
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'io.freefair.lombok'
|
||||
sourceCompatibility = 11
|
||||
compileJava {
|
||||
options.incremental = true
|
||||
}
|
||||
// From https://lyze.dev/2021/04/29/libGDX-Internal-Assets-List/
|
||||
// The article can be helpful when using assets.txt in your project.
|
||||
tasks.register('generateAssetList') {
|
||||
inputs.dir("${project.rootDir}/assets/")
|
||||
// projectFolder/assets
|
||||
File assetsFolder = new File("${project.rootDir}/assets/")
|
||||
// projectFolder/assets/assets.txt
|
||||
File assetsFile = new File(assetsFolder, "assets.txt")
|
||||
File assets_File = new File(assetsFolder, "assets_.txt")
|
||||
// delete that file in case we've already created it
|
||||
assetsFile.delete()
|
||||
assets_File.delete()
|
||||
|
||||
// iterate through all files inside that folder
|
||||
// convert it to a relative path
|
||||
// and append it to the file assets.txt
|
||||
fileTree(assetsFolder).collect { assetsFolder.relativePath(it) }.each {
|
||||
assetsFile.append(it + "\n")
|
||||
assets_File.append(it + "\n")
|
||||
}
|
||||
|
||||
}
|
||||
processResources.dependsOn 'generateAssetList'
|
||||
|
||||
task copyAssetsTxt {
|
||||
doLast {
|
||||
def sourceFile = file('assets/assets.txt')
|
||||
def targetFile = file('assets/assets_.txt')
|
||||
|
||||
if (sourceFile.exists()) {
|
||||
targetFile.text = sourceFile.text
|
||||
println "Successfully copied assets.txt to assets_.txt"
|
||||
} else {
|
||||
println "Source file assets.txt does not exist"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources.dependsOn generateAssetList
|
||||
|
||||
|
||||
compileJava {
|
||||
options.incremental = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
version = '0.0.0-SNAPSHOT'
|
||||
ext.appName = 'open-eggbert'
|
||||
version = '0.0.0-SNAPSHOT'
|
||||
ext.appName = 'open-eggbert'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://s01.oss.sonatype.org' }
|
||||
// You may want to remove the following line if you have errors downloading dependencies.
|
||||
mavenLocal()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://teavm.org/maven/repository/' }
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://s01.oss.sonatype.org' }
|
||||
// You may want to remove the following line if you have errors downloading dependencies.
|
||||
mavenLocal()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://teavm.org/maven/repository/' }
|
||||
|
||||
maven { url 'https://repo.openeggbert.com' }
|
||||
maven { url 'https://repo.openeggbert.com/releases/' }
|
||||
maven { url 'https://repo.openeggbert.com/snapshots/' }
|
||||
maven { url 'https://repo.openeggbert.com' }
|
||||
maven { url 'https://repo.openeggbert.com/releases/' }
|
||||
maven { url 'https://repo.openeggbert.com/snapshots/' }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eclipse.project.name = 'open-eggbert' + '-parent'
|
||||
|
@ -23,7 +23,10 @@ dependencies {
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.3"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.3"
|
||||
api "com.pixelgamelibrary:pixel:$pixelVersion"
|
||||
|
||||
|
||||
if(enableGraalNative == 'true') {
|
||||
implementation "io.github.berstanio:gdx-svmhelper-annotations:$graalHelperVersion"
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.openeggbert.core.main;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Camera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
@ -112,7 +113,11 @@ public class OpenEggbertGame extends GameAdapter {
|
||||
//batch.setProjectionMatrix(viewport.getCamera().combined);
|
||||
image = new Texture("libgdx.png");
|
||||
shapeRenderer = new ShapeRenderer();
|
||||
font = new BitmapFont();
|
||||
font = new BitmapFont(
|
||||
Gdx.files.internal("com/badlogic/gdx/utils/lsans-15.fnt"), Gdx.files.internal("com/badlogic/gdx/utils/lsans-15.png"),
|
||||
false, true
|
||||
);
|
||||
|
||||
System.out.println("Going to set screen");
|
||||
setScreen(gameSpace == null ? new GameSpaceListScreen(this) : new InitScreen(this));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class AbstractGameScreen extends OpenEggbertScreen {
|
||||
drawBackgroundIfAvailable();
|
||||
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class DemoScreen extends OpenEggbertScreen {
|
||||
drawBackgroundIfAvailable();
|
||||
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class GameScreen extends AbstractGameScreen {
|
||||
drawBackgroundIfAvailable();
|
||||
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
|
@ -202,7 +202,7 @@ throw new RuntimeException();
|
||||
batch.begin();
|
||||
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.getData().setScale(4.0f);
|
||||
font.setColor(Color.BLACK);
|
||||
int x = (int) (game.getWidthInPixels() * 0.1875f);
|
||||
|
@ -65,7 +65,7 @@ public class MainHubScreen extends AbstractGameScreen {
|
||||
drawBackgroundIfAvailable();
|
||||
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class SubHubScreen extends AbstractGameScreen {
|
||||
drawBackgroundIfAvailable();
|
||||
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.getData().setScale(2.0f);
|
||||
font.setColor(Color.RED);
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class TestScreen extends OpenEggbertScreen {
|
||||
Function<String, String> removeCurrentDir = i -> i == null ? null : i.replace(game.getAbsolutePathOfRootDirectory()+ "/", "");
|
||||
if (Gdx.app.getType() == Application.ApplicationType.Desktop && game.getGameSpace() != null) {
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
int x = 140;
|
||||
font.draw(game.getBatch(), "getFeatureLevel=" + game.getGameSpace().getFeatureLevel(), 40, x);
|
||||
x += 25;
|
||||
@ -77,7 +77,7 @@ public class TestScreen extends OpenEggbertScreen {
|
||||
|
||||
if (game.getAbsolutePathOfRootDirectory()!= null) {
|
||||
BitmapFont font;
|
||||
font = new BitmapFont();
|
||||
font = game.getFont();
|
||||
font.draw(game.getBatch(), game.getAbsolutePathOfRootDirectory(), 40, 340);
|
||||
}
|
||||
batch.draw(game.getImage(), 40, 400);
|
||||
|
1
html/src/test/java/.gitkeep
Normal file
1
html/src/test/java/.gitkeep
Normal file
@ -0,0 +1 @@
|
||||
|
@ -9,7 +9,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id "io.github.fourlastor.construo" version "1.2.0"
|
||||
id "io.github.fourlastor.construo" version "1.4.1"
|
||||
id "application"
|
||||
}
|
||||
|
||||
@ -23,6 +23,10 @@ eclipse.project.name = appName + '-lwjgl3'
|
||||
java.sourceCompatibility = 11
|
||||
java.targetCompatibility = 11
|
||||
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
compileJava.options.release.set(11)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"
|
||||
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
||||
@ -35,6 +39,10 @@ dependencies {
|
||||
implementation project(':core')
|
||||
implementation "com.pixelgamelibrary:pixel:$pixelVersion"
|
||||
implementation "com.pixelgamelibrary:pixel-backend-libgdx:$pixelVersion"
|
||||
|
||||
if(enableGraalNative == 'true') {
|
||||
implementation "io.github.berstanio:gdx-svmhelper-backend-lwjgl3:$graalHelperVersion"
|
||||
}
|
||||
}
|
||||
|
||||
def jarName = "${appName}-${version}.jar"
|
||||
@ -82,19 +90,19 @@ construo {
|
||||
targets.configure {
|
||||
create("linuxX64", Target.Linux) {
|
||||
architecture.set(Target.Architecture.X86_64)
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jdk_x64_linux_hotspot_17.0.11_9.tar.gz")
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.12_7.tar.gz")
|
||||
}
|
||||
create("macM1", Target.MacOs) {
|
||||
architecture.set(Target.Architecture.AARCH64)
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.11_9.tar.gz")
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.12_7.tar.gz")
|
||||
// macOS needs an identifier
|
||||
identifier.set("i.should.be.changed.before.merge." + appName)
|
||||
identifier.set("com.openeggbert." + appName)
|
||||
// Optional: icon for macOS
|
||||
macIcon.set(project.file("icons/logo.icns"))
|
||||
}
|
||||
create("macX64", Target.MacOs) {
|
||||
architecture.set(Target.Architecture.X86_64)
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jdk_x64_mac_hotspot_17.0.11_9.tar.gz")
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_mac_hotspot_17.0.12_7.tar.gz")
|
||||
// macOS needs an identifier
|
||||
identifier.set("i.should.be.changed.before.merge." + appName)
|
||||
// Optional: icon for macOS
|
||||
@ -102,7 +110,7 @@ construo {
|
||||
}
|
||||
create("winX64", Target.Windows) {
|
||||
architecture.set(Target.Architecture.X86_64)
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jdk_x64_windows_hotspot_17.0.11_9.zip")
|
||||
jdkUrl.set("https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_windows_hotspot_17.0.12_7.zip")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,6 +120,23 @@ tasks.register('dist') {
|
||||
dependsOn 'jar'
|
||||
}
|
||||
|
||||
distributions {
|
||||
main {
|
||||
contents {
|
||||
into('libs') {
|
||||
project.configurations.runtimeClasspath.files.findAll { file ->
|
||||
file.getName() != project.tasks.jar.outputs.files.singleFile.name
|
||||
}.each { file ->
|
||||
exclude file.name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startScripts.dependsOn(':lwjgl3:jar')
|
||||
startScripts.classpath = project.tasks.jar.outputs.files
|
||||
|
||||
if(enableGraalNative == 'true') {
|
||||
apply from: file("nativeimage.gradle")
|
||||
}
|
||||
|
@ -2,10 +2,6 @@
|
||||
project(":lwjgl3") {
|
||||
apply plugin: "org.graalvm.buildtools.native"
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.berstanio:gdx-svmhelper-backend-lwjgl3:$graalHelperVersion"
|
||||
implementation "io.github.berstanio:gdx-svmhelper-extension-box2d:$graalHelperVersion"
|
||||
}
|
||||
graalvmNative {
|
||||
binaries {
|
||||
main {
|
||||
@ -15,6 +11,7 @@ project(":lwjgl3") {
|
||||
buildArgs.add("-march=compatibility")
|
||||
jvmArgs.addAll("-Dfile.encoding=UTF8")
|
||||
sharedLibrary = false
|
||||
resources.autodetect()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,9 +52,3 @@ project(":lwjgl3") {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
project(":core") {
|
||||
dependencies {
|
||||
implementation "io.github.berstanio:gdx-svmhelper-annotations:$graalHelperVersion"
|
||||
}
|
||||
}
|
||||
|
@ -43,5 +43,5 @@ build.dependsOn buildJavaScript
|
||||
|
||||
tasks.register("run") {
|
||||
description = "Run the JavaScript application hosted via a local Jetty server at http://localhost:8080/"
|
||||
dependsOn(buildJavaScript, tasks.named("jettyRun"))
|
||||
dependsOn(buildJavaScript/*, tasks.named("jettyRun")*/)//todo
|
||||
}
|
||||
|
Reference in New Issue
Block a user