From 78b192babe4b175ef3853baff28b23aa3e9185d2 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:36:09 +0300 Subject: [PATCH] fix: some build scripts --- Metadata.java | 7 ------- build.js | 28 +++++++++++++++++----------- meta.json | 3 +-- 3 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 Metadata.java diff --git a/Metadata.java b/Metadata.java deleted file mode 100644 index 128bfaf..0000000 --- a/Metadata.java +++ /dev/null @@ -1,7 +0,0 @@ -package me.topchetoeu.jscript; - -public class Metadata { - public static final String VERSION = "0.0.1-alpha"; - public static final String AUTHOR = "TopchetoEU"; - public static final String NAME = "java-jscript"; -} diff --git a/build.js b/build.js index b6e9609..f4f3b5f 100644 --- a/build.js +++ b/build.js @@ -38,16 +38,22 @@ function run(cmd, ...args) { } async function compileJava() { - await fs.writeFile('Metadata.java', (await fs.readFile('src/me/topchetoeu/jscript/Metadata.java')).toString() - .replace('${VERSION}', conf.version) - .replace('${NAME}', conf.name) - .replace('${AUTHOR}', conf.author) - ); - - const args = ['-d', 'dst/classes', 'Metadata.java']; - for await (const path of find('src', undefined, v => v.endsWith('.java') && !v.endsWith('Metadata.java'))) args.push(path); - await run(conf.javahome + '/javac', ...args); - await fs.rm('Metadata.java'); + try { + await fs.writeFile('Metadata.java', (await fs.readFile('src/me/topchetoeu/jscript/Metadata.java')).toString() + .replace('${VERSION}', conf.version) + .replace('${NAME}', conf.name) + .replace('${AUTHOR}', conf.author) + ); + const args = ['--release', '10', ]; + if (argv[1] === 'debug') args.push('-g'); + args.push('-d', 'dst/classes', 'Metadata.java'); + + for await (const path of find('src', undefined, v => v.endsWith('.java') && !v.endsWith('Metadata.java'))) args.push(path); + await run(conf.javahome + 'javac', ...args); + } + finally { + await fs.rm('Metadata.java'); + } } (async () => { @@ -59,7 +65,7 @@ async function compileJava() { await run('jar', '-c', '-f', 'dst/jscript.jar', '-e', 'me.topchetoeu.jscript.Main', '-C', 'dst/classes', '.'); } catch (e) { - if (argv.includes('debug')) throw e; + if (argv[1] === 'debug') throw e; else console.log(e.toString()); } })(); diff --git a/meta.json b/meta.json index c573484..fb3c57f 100644 --- a/meta.json +++ b/meta.json @@ -1,6 +1,5 @@ { - "version": "0.0.1-alpha", "name": "java-jscript", "author": "TopchetoEU", - "javahome": "/usr/lib/jvm/java-8-openjdk-amd64/bin" + "javahome": "" } \ No newline at end of file