From 439d89cfdb49de11de73e31b2604672edcc5a45d Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 21 Apr 2020 01:11:04 +0100 Subject: [PATCH] JAL-3602 Added configuration for enforced use of UTF-8 for creating the core js files and also in the closure-compiler. --- build.gradle | 31 ++++++++++++++++++++----------- gradle.properties | 4 +++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index d955de3..985cc87 100644 --- a/build.gradle +++ b/build.gradle @@ -804,11 +804,12 @@ task cleanClover { compileJava { - + + sourceCompatibility = compile_source_compatibility + targetCompatibility = compile_target_compatibility + options.compilerArgs = additional_compiler_args + options.encoding = "UTF-8" doFirst { - sourceCompatibility = compile_source_compatibility - targetCompatibility = compile_target_compatibility - options.compilerArgs = additional_compiler_args print ("Setting target compatibility to "+targetCompatibility+"\n") } @@ -1423,6 +1424,11 @@ task getdown() { } +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + + clean { doFirst { delete getdownWebsiteDir @@ -1818,13 +1824,14 @@ task jalviewjsEclipsePaths { eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct" } else if (OperatingSystem.current().isWindows()) { // check these paths!! if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) { - eclipseRoot += "/eclipse.exe" + eclipseRoot += "/eclipse" } - eclipseBinary = "${eclipseRoot}/eclipse" + eclipseBinary = "${eclipseRoot}/eclipse.exe" eclipseProduct = "${eclipseRoot}/.eclipseproduct" } else { // linux or unix if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) { eclipseRoot += "/eclipse" +println("eclipseDir exists") } eclipseBinary = "${eclipseRoot}/eclipse" eclipseProduct = "${eclipseRoot}/.eclipseproduct" @@ -2203,11 +2210,11 @@ def jalviewjsCallCore(String name, FileCollection list, String prefixFile, Strin def coreBottom = file(suffixFile) coreFile.getParentFile().mkdirs() coreFile.createNewFile() - coreFile.write( coreTop.text ) + coreFile.write( coreTop.getText("UTF-8") ) list.each { f -> if (f.exists()) { - def t = f.text + def t = f.getText("UTF-8") t.replaceAll("Clazz\\.([^_])","Clazz_${1}") coreFile.append( t ) } else { @@ -2216,7 +2223,7 @@ def jalviewjsCallCore(String name, FileCollection list, String prefixFile, Strin logOutFile.append(msg+"\n") } } - coreFile.append( coreBottom.text ) + coreFile.append( coreBottom.getText("UTF-8") ) msg = "Generating ${zjsfile}" println(msg) @@ -2225,8 +2232,10 @@ def jalviewjsCallCore(String name, FileCollection list, String prefixFile, Strin def logErrFOS = logOutFOS javaexec { - classpath = files(["${jalviewDir}/tools/closure_compiler.jar"]) - args = [ "--js", jsfile, "--js_output_file", zjsfile ] + classpath = files(["${jalviewDir}/${jalviewjs_closure_compiler}"]) + main = "com.google.javascript.jscomp.CommandLineRunner" + jvmArgs = [ "-Dfile.encoding=UTF-8" ] + args = [ "--compilation_level", "SIMPLE_OPTIMIZATIONS", "--warning_level", "QUIET", "--charset", "UTF-8", "--js", jsfile, "--js_output_file", zjsfile ] maxHeapSize = "2g" msg = "\nRunning '"+commandLine.join(' ')+"'\n" diff --git a/gradle.properties b/gradle.properties index 1507117..59699e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ -org.gradle.jvmargs=-Xmx1536m -Xms512m +org.gradle.jvmargs=-Xmx1536m -Xms512m -Dfile.encoding=UTF-8 +#systemProp.file.encoding=UTF-8 jalviewDir = . @@ -213,6 +214,7 @@ j2s_coretemplate_html = utils/jalviewjs/coretemplate.html jalviewjs_j2s_transpile_stdout = j2s-transpile.out #jalviewjs_j2s_stderr = j2s-transpile.err # all going into out jalviewjs_j2s_to_console = true +jalviewjs_closure_compiler = tools/closure_compiler.jar jalviewjs_j2s_closure_stdout = j2s-closure.out -- 1.7.10.2