Giter VIP home page Giter VIP logo

Comments (16)

mfuerstenau avatar mfuerstenau commented on August 14, 2024 1

Setting -Dfile.encoding=UTF-8 works. Adding

[compileJava, compileTestJava, compileGroovy, compileTestGroovy]*.options*.encoding = 'UTF-8'

does not work. I'm still a bit unsatisfied as this is something I cannot package witjh the build script and check into our repository easily. Some people use netbeans internal gradle version and not the wrapper and they end up with wrong encoding. I have to package a README and hope that it is read.

Update: I may have found a clue. It seems netbeans/gradle sets the -Dfile.encoding=windows-1252 option if not set manually.

screenshot from taskmanager with cli arguments

Update 2: It's a gradle thing, gradle sets -Dfile.encoding=windows-1252.

Update 3: Last question remaining would be: Is

[compileJava, compileTestJava, compileGroovy, compileTestGroovy]*.options*.encoding = 'UTF-8'

useless because of -Dfile.encoding set either manually or by gradle to system default? It always seems to override.

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

Why do you encode your tests as iso-8859-1? It should just work if you switch your tests to utf-8...

But I'll also check if I can find another solution. Stay tuned...

from spock-reports.

mfuerstenau avatar mfuerstenau commented on August 14, 2024

The source files are UTF-8, the templates are UTF-8, still the descriptions from the tests still get encoded in ISO-8859-1 which is the system default. Other text from the templates ends up correctly as UTF-8. Therefore the result is a mix-up of UTF-8 and some ISO-8859-1, if interpreted as UTF-8 resulting in ? characters as placeholders (depending on the editor or interpreter).

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

so, as you use the template report creator, I will use the code from https://github.com/rdmueller/etka15 and try to reproduce the problem...

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

ok. problem reproduced....

from spock-reports.

mfuerstenau avatar mfuerstenau commented on August 14, 2024

This is my template (extract), a JIRA template. It's encoded in UTF-8. The line Übersicht is encoded correct in the result, but the block.text (block results from Feature.eachFeature(Closure)) is not correctly encoded in the result. Block text in the source code (UTF-8 encoded) is:

expect: "Tatsächlicher HTTP-Status-Code entspricht Erwartung"

I could work around if I used: new String(block.text.getBytes('UTF-8'), 'ISO-8859-1')

<%
    def stats = utils.stats( data )
 %>h2. Bericht für ${data.info.description.className}

h2. Übersicht
...
<%
   for ( block in blocks ) {
 %>* ${block.kind} ${block.text}
<%
   }
%>
...

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

yes, but the workaround is ugly. But I guess, I have a solution. Give me just a moment to verify it. It seems that - alt least in my case - the problem was caused by the encoding of the template file...

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

I am a little puzzled about the workaround: it doesn't work for me with "ß" and "Ü" but with "ä" and "ü"...
and I couldn't verify my solution :-(

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

so, the workaround is OS dependent - for windows it is new String(block.text.getBytes('UTF-8'), 'CP1252')

from spock-reports.

renatoathaydes avatar renatoathaydes commented on August 14, 2024

The text you get when you do block.text comes from Spock's org.spockframework.runtime.model.BlockMetadata#texts(). I suppose that itself comes from the compiler or Groovy AST Transformer... to enforce UTF-8 and avoid issues, you could try to set the java compiler -encoding option as explained in the javac documentation or using Gradle, because source code is expected to be in the platform default encoding by default, which in Windows happens to be ISO-8859-1.

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

thanx. I will give it a try...

from spock-reports.

mfuerstenau avatar mfuerstenau commented on August 14, 2024

I'll report my results tomorrow. Right now I'am at home and the project in question is out of reach.

from spock-reports.

rdmueller avatar rdmueller commented on August 14, 2024

Renato is right - it's a "problem" with gradle and the os specific file encoding. It can be resolved by setting the environment variable GRADLE_OPTS to "-Dfile.encoding=UTF-8" . If you use the windows powershell, this can be done through
$env:GRADLE_OPTS="-Dfile.encoding=UTF-8"

unfortunately, it seems that it can't be set as gradle option, e.g. gradle "-Dfile.encoding=UTF-8" test

verified on my test project

from spock-reports.

mfuerstenau avatar mfuerstenau commented on August 14, 2024

I think we can close this Issue now, I posted the last question at the gradle.org forum as it is a more general gradle question.

from spock-reports.

mfuerstenau avatar mfuerstenau commented on August 14, 2024

A solution I found: gradle.properties in the project dir with:

org.gradle.jvmargs='-Dfile.encoding=UTF-8'

works even with daemon, as a new instance is created if the existing one(s) differ from JVM args. That way I can check that file into our subversion/git repository and my collegues don't have to fiddle with the build file.

from spock-reports.

renatoathaydes avatar renatoathaydes commented on August 14, 2024

@mfuerstenau glad it works now. Thanks for posting back the solution!

from spock-reports.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.