From 46136e77e21dd10529101f06eec46fbfbd069539 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:47:41 +0200 Subject: [PATCH] build: improve build scripts --- .gitignore | 4 ++- build.gradle | 33 ++++++++++--------- gradle.properties | 3 ++ settings.gradle | 1 - src/assets/metadata.json | 5 +++ .../topchetoeu/jscript/common/Metadata.java | 15 +++++++-- 6 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 gradle.properties create mode 100644 src/assets/metadata.json diff --git a/.gitignore b/.gitignore index f76b289..b21c5e4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ !/build.js !/LICENSE !/README.md -!/?*.gradle \ No newline at end of file +!/settings.gradle +!/build.gradle +!/gradle.properties diff --git a/build.gradle b/build.gradle index cd5c3cc..fa25520 100644 --- a/build.gradle +++ b/build.gradle @@ -1,26 +1,29 @@ - - -java { - // toolchain { - // languageVersion = JavaLanguageVersion.of(11) - // } -} - plugins { id 'application' } -repositories { - mavenCentral() +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } -dependencies { - sourceSets { - main.java.srcDirs = [ 'src/java' ] - main.resources.srcDirs = [ 'src/assets' ] +sourceSets { + main.java.srcDirs = [ 'src/java' ] + main.resources.srcDirs = [ 'src/assets' ] +} + +processResources { + filesMatching('metadata.json') { + expand ( + 'version': project.project_version, + 'name': project.project_name + ) } } application { - mainClass = 'me.topchetoeu.jscript.utils.JScriptRepl' + mainClass = project.main_class } + +archivesBaseName = project.project_name +version = project.project_version \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..c152a45 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +project_name = jscript +project_version = 0.8.4-beta +main_class = me.topchetoeu.jscript.utils.JScriptRepl diff --git a/settings.gradle b/settings.gradle index 8db4951..e69de29 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +0,0 @@ -rootProject.name = 'jscript' \ No newline at end of file diff --git a/src/assets/metadata.json b/src/assets/metadata.json new file mode 100644 index 0000000..42ba55f --- /dev/null +++ b/src/assets/metadata.json @@ -0,0 +1,5 @@ +{ + "version": "${version}", + "name": "${name}", + "author": "TopchetoEU" +} \ No newline at end of file diff --git a/src/java/me/topchetoeu/jscript/common/Metadata.java b/src/java/me/topchetoeu/jscript/common/Metadata.java index 91c6435..efc33dd 100644 --- a/src/java/me/topchetoeu/jscript/common/Metadata.java +++ b/src/java/me/topchetoeu/jscript/common/Metadata.java @@ -1,9 +1,18 @@ package me.topchetoeu.jscript.common; +import me.topchetoeu.jscript.common.json.JSON; + public class Metadata { - private static final String VERSION = "${VERSION}"; - private static final String AUTHOR = "${AUTHOR}"; - private static final String NAME = "${NAME}"; + private static final String VERSION; + private static final String AUTHOR; + private static final String NAME; + + static { + var data = JSON.parse(null, Reading.resourceToString("metadata.json")).map(); + VERSION = data.string("version"); + AUTHOR = data.string("author"); + NAME = data.string("name"); + } public static String version() { if (VERSION.equals("$" + "{VERSION}")) return "1337-devel";