fix: some build scripts

This commit is contained in:
2023-09-08 02:36:09 +03:00
parent 38656bd654
commit 78b192babe
3 changed files with 18 additions and 20 deletions

View File

@@ -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";
}

View File

@@ -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());
}
})();

View File

@@ -1,6 +1,5 @@
{
"version": "0.0.1-alpha",
"name": "java-jscript",
"author": "TopchetoEU",
"javahome": "/usr/lib/jvm/java-8-openjdk-amd64/bin"
"javahome": ""
}