Created :core:createVersionSource gradle task

Gradle build info is now output to a generated source RiiabloVersion.java
Renamed generatedSourceDirs to vcsGeneratedSourceDir for version controlled generated sources
Created generatedSourceDir for build generated sources
Integrated RiiabloVersion into Client and MenuScreen
Changed Client.properties diablo->riiablo=Riiablo (e.g., Riiablo)
Changed Client.properties version->V {0} (e.g., V 0.0.3-SNAPSHOT)
This commit is contained in:
Collin Smith 2020-12-11 20:18:55 -08:00
parent f00dd70023
commit f3a1cbd4be
4 changed files with 41 additions and 8 deletions

View File

@ -1,5 +1,5 @@
diablo=Diablo II
version=V 1.0
riiablo=Riiablo
version=V {0}
press_any_key=Press any Key
press_any_button=Press any Button
@ -7,4 +7,4 @@ touch_the_screen=Touch the Screen
unpacking_audio_files=Unpacking audio files...
unpacking_description=This should only take a few minutes
unpacking_file={0}
unpacking_file={0}

View File

@ -5,14 +5,20 @@ apply plugin: 'io.netifi.flatbuffers'
import io.netifi.flatbuffers.plugin.tasks.FlatBuffers
import org.gradle.internal.os.OperatingSystem
import java.text.SimpleDateFormat
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.resources.srcDirs += rootProject.file('assets')
idea.module.resourceDirs += rootProject.file('assets')
project.ext.generatedSourceDirs = file('gen/main/java/')
sourceSets.main.java.srcDirs += generatedSourceDirs
idea.module.generatedSourceDirs += generatedSourceDirs
project.ext.generatedSourceDir = file("$buildDir/generated-src/main/java/")
sourceSets.main.java.srcDirs += generatedSourceDir
idea.module.generatedSourceDirs += generatedSourceDir
project.ext.vcsGeneratedSourceDir = file('gen/main/java/')
sourceSets.main.java.srcDirs += vcsGeneratedSourceDir
idea.module.generatedSourceDirs += vcsGeneratedSourceDir
project.ext.flatbuffersSourceDirs = file('src/main/flatbuffers/')
@ -105,7 +111,7 @@ task createFlatBuffers(type: FlatBuffers) {
}
inputDir = flatbuffersSourceDirs
outputDir = generatedSourceDirs
outputDir = vcsGeneratedSourceDir
}
task generateSources {
@ -118,8 +124,32 @@ if (OperatingSystem.current() != OperatingSystem.WINDOWS) {
}
generateSources.dependsOn 'createFlatBuffers'
generateSources.dependsOn 'createVersionSource'
compileJava.dependsOn 'generateSources'
task createVersionSource {
def versionClassName = 'RiiabloVersion'
def timeZone = TimeZone.getTimeZone("UTC")
def dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
dateFormat.setTimeZone(timeZone)
def buildDate = dateFormat.format(new Date())
def versionFile = file("${generatedSourceDir}/com/riiablo/${versionClassName}.java")
outputs.file(versionFile)
doLast {
versionFile.text =
"""// Generated by ${path} on ${buildDate}
package com.riiablo;
public final class ${versionClassName} {
public static final String VERSION = "${version}";
public static final String BUILD_DATE = "${buildDate}";
}
"""
}
}
//tasks.withType(JavaCompile) {
// options.compilerArgs << '-Xlint:unchecked'
// options.deprecation = true

View File

@ -258,6 +258,7 @@ public class Client extends Game {
Calendar calendar = Calendar.getInstance();
DateFormat format = DateFormat.getDateTimeInstance();
console.out.println(format.format(calendar.getTime()));
console.out.println(RiiabloVersion.VERSION + " - " + RiiabloVersion.BUILD_DATE);
console.out.println(home.path());
console.out.println(saves.path());
}

View File

@ -20,7 +20,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align;
import com.riiablo.Riiablo;
import com.riiablo.RiiabloVersion;
import com.riiablo.codec.Animation;
import com.riiablo.codec.DC6;
import com.riiablo.graphics.BlendMode;
@ -147,7 +149,7 @@ public class MenuScreen extends ScreenAdapter {
//btnExit.setVisible(Gdx.app.getType() == Application.ApplicationType.Android);
stage.addActor(btnExit);
lbVersion = new Label(Riiablo.bundle.get("version"), Riiablo.fonts.font16);
lbVersion = new Label(Riiablo.bundle.format("version", RiiabloVersion.VERSION), Riiablo.fonts.font16);
lbVersion.setPosition(stage.getWidth() - 20, 20, Align.bottomRight);
stage.addActor(lbVersion);
}