Skip to content

Commit

Permalink
Find the optimized jar with pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
sink772 committed Dec 21, 2023
1 parent 57b7891 commit c3d60b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions e2edemo/scripts/icon/jar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import fs from 'fs';
import path from 'path';

export class Jar {
public static readFromFile(base: string | undefined, project: string, version: string = '0.1.0') {
public static readFromFile(base: string | undefined, project: string, version?: string) {
if (!base) {
base = "../javascore";
}
const build = "build/libs";
const basedir = path.join(base, project, build);
const name = project.replace("/", "-");
const optJar = `${name}-${version}-optimized.jar`;
const fullPath = path.join(base, project, build, optJar);
let optJar;
if (version) {
optJar = `${name}-${version}-optimized.jar`;
} else {
const files = fs.readdirSync(basedir);
optJar = files.filter(f => f.match(`${name}\\-[\\d.]+\\-optimized.jar`))[0];
}
const fullPath = path.join(basedir, optJar);
return fs.readFileSync(fullPath).toString('hex')
}
}
2 changes: 1 addition & 1 deletion e2edemo/scripts/setup/deploy_xcall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const deployments = Deployments.getDefault();

async function deploy_xcall_java(target: string, chain: any) {
const iconNetwork = IconNetwork.getNetwork(target);
const content = Jar.readFromFile(JAVASCORE_PATH, "xcall", "0.6.2");
const content = Jar.readFromFile(JAVASCORE_PATH, "xcall");
const xcall = new Contract(iconNetwork)
const deployTxHash = await xcall.deploy({
content: content,
Expand Down

0 comments on commit c3d60b2

Please sign in to comment.