diff --git a/cli/src/main/java/ca/weblite/jdeploy/cheerpj/services/BuildCheerpjAppService.java b/cli/src/main/java/ca/weblite/jdeploy/cheerpj/services/BuildCheerpjAppService.java index 7ad94b3..836eeef 100644 --- a/cli/src/main/java/ca/weblite/jdeploy/cheerpj/services/BuildCheerpjAppService.java +++ b/cli/src/main/java/ca/weblite/jdeploy/cheerpj/services/BuildCheerpjAppService.java @@ -24,6 +24,8 @@ public static class Params { private File appJar; private File outputDir; + private String cheerpjLoader = "https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"; + public File getOutputDir() { return outputDir; } @@ -59,6 +61,15 @@ public Params setIconFile(File iconFile) { this.iconFile = iconFile; return this; } + + public Params setCheerpjLoader(String cheerpjLoader) { + this.cheerpjLoader = cheerpjLoader; + return this; + } + + public String getCheerpjLoader() { + return cheerpjLoader; + } } public void build(Params params) throws IOException { String mainClass = extractMainClass(params.getAppJar()); @@ -67,6 +78,7 @@ public void build(Params params) throws IOException { this.getClass().getResourceAsStream("/ca/weblite/jdeploy/cheerpj/index.html") ); + indexHtml = indexHtml.replace("{{ cheerpjLoader }}", params.getCheerpjLoader()); indexHtml = indexHtml.replace("{{ mainClass }}", mainClass); indexHtml = indexHtml.replace("{{ classPath }}", classPath); indexHtml = indexHtml.replace("{{ appName }}", params.getAppName()); diff --git a/cli/src/main/java/ca/weblite/jdeploy/services/CheerpjService.java b/cli/src/main/java/ca/weblite/jdeploy/services/CheerpjService.java index 2a2f247..c53f71f 100644 --- a/cli/src/main/java/ca/weblite/jdeploy/services/CheerpjService.java +++ b/cli/src/main/java/ca/weblite/jdeploy/services/CheerpjService.java @@ -14,6 +14,8 @@ public class CheerpjService extends BaseService { private BuildCheerpjAppService buildCheerpjAppService; + private static final String DEFAULT_CHEERPJ_LOADER = "https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"; + public CheerpjService(File packageJSONFile, JSONObject packageJSON) throws IOException { super(packageJSONFile, packageJSON); buildCheerpjAppService = new BuildCheerpjAppService(); @@ -34,6 +36,7 @@ private void run() throws IOException { File dest = this.getDestDirectory(); buildCheerpjAppService.build( new BuildCheerpjAppService.Params() + .setCheerpjLoader(getCheerpjLoader(DEFAULT_CHEERPJ_LOADER)) .setAppName(getAppName()) .setAppJar(mainJar) .setOutputDir(dest) @@ -108,6 +111,20 @@ private JSONObject getGithubPagesConfig() { return config; } + private JSONObject getCheerpjObject() { + if (!isEnabled()) { + return new JSONObject(); + } + return getJDeployObject().getJSONObject("cheerpj"); + } + + private String getCheerpjLoader(String defaultValue) { + if (!getCheerpjObject().has("loader")) { + return defaultValue; + } + return getCheerpjObject().getString("loader"); + } + private String getCurrentTag() throws IOException, InterruptedException { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command("git", "describe", "--tags", "--exact-match"); diff --git a/cli/src/main/resources/ca/weblite/jdeploy/cheerpj/index.html b/cli/src/main/resources/ca/weblite/jdeploy/cheerpj/index.html index cad079e..85ff67a 100644 --- a/cli/src/main/resources/ca/weblite/jdeploy/cheerpj/index.html +++ b/cli/src/main/resources/ca/weblite/jdeploy/cheerpj/index.html @@ -7,11 +7,11 @@ {{ title }} - +