Closed ForNeVeR closed 9 years ago
Note: as suggested by https://issues.gradle.org/browse/GRADLE-1506 bugreport, the issue can be fixed by adding the following line to the root build.gradle
:
System.setProperty("file.encoding", "UTF-8")
Hi Friedrich,
Thanks for the detailed feedback!
Yes, you are right. We need to enforce the encoding and use UTF-8 as default. It looks like atm the environmental JAVA_OPTS are picked up. As a quick workaround, you may want to change those.
Thanks for posting Dierk
sent from:mobile
Am 10.03.2015 um 06:56 schrieb Friedrich von Never notifications@github.com:
I'm trying the following under Windows 7 x64, JDK 8u31:
Clone this repository. Install it locally with ./gradlew clean install. Clone the gradle-frege-example. Change the build.gradle so that it uses classpath 'org.frege-lang:frege-gradle-plugin:0.2-SNAPSHOT' instead of 0.1. Execute ./gradlew build. Examine the file frege-java\build\libs\frege-java.jar. It should have class files such as com\github\mperry\frege\External$IJ.class, External$IJ$mainƒ92257c7e.class according to the content of frege-java\build\classes\main\com\github\mperry\frege\ directory. But in reality it have com\github\mperry\frege\External$.class, External$_$_main92257c7e.class (Unicode characters were replaced by ). Finally, try ./gradlew run. It fails with the following log:
./gradlew run :frege-java:compileJava UP-TO-DATE :frege-java:compileFrege UP-TO-DATE :frege-java:processResources UP-TO-DATE :frege-java:classes UP-TO-DATE :frege-java:run starting main... in fregeJava2 in fregeJavaruntime 0.077 wallclock seconds.
main done :frege-java:jar UP-TO-DATE :java-frege:compileFrege UP-TO-DATE :java-frege:compileJava UP-TO-DATE :java-frege:processResources UP-TO-DATE :java-frege:classes UP-TO-DATE :java-frege:run Facade.main Exception in thread "main" java.lang.NoClassDefFoundError: com/github/mperry/frege/External$? at com.github.mperry.frege.External.
(External.java:177) at com.github.mperry.frege.Facade.main(Facade.java:18) Caused by: java.lang.ClassNotFoundException: com.github.mperry.frege.External$? at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 2 more :java-frege:run FAILED FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':java-frege:run'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 1
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.608 secs It seems that it cannot find the proper classes in jar. When I manually run it with classpath set to filesystem, it runs fine:
java -classpath ".\frege-java\build\classes\main;.\java-frege\build\classes\main;c:\Users\ForNeVeR.gradle\caches\modules-2\files-2.1\com.theoryinpractise.frege\frege\3.22.367-g2737683\9cf61284838ff9def8384d63a0a844f1a6c78d56\frege-3.22.367-g2737683.jar" com.github.mperry.frege.Facade Facade.main java2Frege: Hi from Frege While debugging ./gradlew run I've noticed that it invokes Java with some weird parameters such as java -Dfile.encoding=windows-1251 -Duser.country=RU -Duser.language=ru -Duser.variant -classpath [...]. Unicode characters used by Frege (such as IJ or ƒ) cannot be represented in windows-1251 encoding (and I'm suspecting that's the case of any single-byte encoding), so if java tries to use windows-1251 when packing the jar that will cause all sorts of problems.
Is there any way to change file system encoding when building the jar? Can we force it within Gradle plugin (because we do know that any encoding except unicode will cause problems)? Even if we choose to not force it, there should be a recommendation somewhere in documentation or even a warning about troublesome encoding selection.
— Reply to this email directly or view it on GitHub.
Even better :-)
But I'd say we better provide a setting anyway.
Dierk
sent from:mobile
Am 10.03.2015 um 07:10 schrieb Friedrich von Never notifications@github.com:
Note: as suggested by https://issues.gradle.org/browse/GRADLE-1506 bugreport, the issue can be fixed by adding the following line to the root build.gradle:
System.setProperty("file.encoding", "UTF-8")
— Reply to this email directly or view it on GitHub.
I have applied the system property directly in the plugin, so that it is not needed in frege plugin clients. See https://github.com/Frege/frege-gradle-plugin/commit/433010ed9ac436a8d2326ec76f867722c52a4af8. The example was then change to remove this, https://github.com/mperry/gradle-frege-example/commit/f1bf3bb805520acc420059062bca2d01dd887df0. Many thanks for @ForNeVeR for figuring this out.
I'm trying the following under Windows 7 x64, JDK 8u31:
./gradlew clean install
.build.gradle
so that it usesclasspath 'org.frege-lang:frege-gradle-plugin:0.2-SNAPSHOT'
instead of0.1
../gradlew build
.frege-java\build\libs\frege-java.jar
. It should have class files such ascom\github\mperry\frege\External$IJ.class
,External$IJ$_mainƒ92257c7e.class
according to the content offrege-java\build\classes\main\com\github\mperry\frege\
directory. But in reality it havecom\github\mperry\frege\External$_.class
,External$_$_main_92257c7e.class
(Unicode characters were replaced by_
).Finally, try
./gradlew run
. It fails with the following log:It seems that it cannot find the proper classes in jar because of mentioned encoding issue. When I manually run it with classpath set to filesystem, it runs fine:
While debugging
./gradlew run
I've noticed that it invokes Java with some weird parameters such asjava -Dfile.encoding=windows-1251 -Duser.country=RU -Duser.language=ru -Duser.variant -classpath [...]
. Unicode characters used by Frege (such asIJ
orƒ
) cannot be represented inwindows-1251
encoding (and I'm suspecting that's the case of any single-byte encoding), so if java tries to usewindows-1251
when packing the jar that will cause all sorts of problems.Is there any way to change file system encoding when building the jar? Can we force it within Gradle plugin (because we do know that any encoding except unicode will cause problems)? Even if we choose to not force it, there should be a recommendation somewhere in documentation or even a warning about troublesome encoding selection.