-
Notifications
You must be signed in to change notification settings - Fork 45
UnmappableCharacterException / MalformedInputException (problems with encoding) #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, How are you passing the file.encoding system property please? You may find that exporting an environment variable before launching Gradle makes this work transparently. export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 Thanks, |
It worked, but IMHO this is only a workaround, and not a very good one. Making sure this variable is set on every environment (devs and CI) would result in build inconsistencies for sure. I couldn't find a way to define these variables on a per-project basis other than placing the The Note that the following configuration didn't work either:
That makes sense since the |
Yes, this was just a way to test that the default JVM encoding was to blame. I seem to recall Gradle washing their hands of this a long time ago; Maven does support a project level encoding. I suspect the reporting task is not respecting the configured system properties; I will take a look tomorrow. |
That said - are you not using the gradle wrapper scripts everywhere? This gives you a convenient location to configure the build environment consistently. |
It seems so. Perhaps this only happens while using the gradle daemon (child JVMs spawned from within the daemon will not "inherit" its arguments). There could be a relatively easy workaround here by adjusting
Well, I make sure to use |
I added a PR which allows to configure the plugin with a custom encoding, thus preventing the exceptions. |
Hi guys. Gradle plugin should call this ScoverageWriter constructor (with |
@gslowikowski Thanks for joining in. That is true, but it would hardly solve the problem. Take a look at the PR I created (#70) for further details on this. |
we have seen this behavior as well - however they seem to happen very inconsistently - only happens on some ci workers but works in some. Any reason why? |
I've gotten back to investigating this issue and I believe I have the full picture in mind. There are basically three steps to Scoverage:
First off, there is an encoding problem in the scalac plugin with the creation of the "mapping" file in step 1. The scalac plugin relies on the JVM encoding instead of the The problem that the Gradle plugin is responsible for is failing to generate an HTML report file. The What then happened in my original cas, and how come some Unicode characters work and some don't? Well, my default OS encoding -- and therefore my default JVM encoding -- is What the Gradle plugin should do then is to invoke the |
I have a hybrid scala/java gradle project with multiple sub-projects and I'm trying to make scoverage work for me.
reportScoverage
fails to execute on one of my sub-projects with the following exception:I found an issue on the SBT plugin issue tracker (sbt-scoverage#204) with the same exception, and it implied using the proper encoding setting when invoking the scala compiler. Well then, I added this to my project:
This code is an overkill to make sure Scala compiles with
UTF-8
. But it didn't change a thing.I looked at source code of where the exception is thrown at CodeGrid.source(), and I saw that it's using a custom encoding propagated by ScoverageHtmlWriter. The problem here though is that
ScoverageHtmlWriter
is never initialized with any custom encoding; not in the original SBT plugin code nor in this project'sScoverageWriter
.This obviously should be fixed. But anyway I thought "let's just try overriding the default encoding with a simple
-Dfile.encoding=utf-8
". Well, this caused an exception in an even earlier stage:Again, problems with encoding. I'm assuming this is a problem with the original SBT plugin and not with the gradle plugin, but I thought I'd file the issue here since I'm using the gradle plugin (well, I'm trying to use it, but it seems it needs to be fixed in order for it to be relevant to me).
The text was updated successfully, but these errors were encountered: