Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343927 - [patch] Set project file encoding based on project.build.sourceEncoding property
Summary: [patch] Set project file encoding based on project.build.sourceEncoding property
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-27 02:37 EDT by Anders Hammar CLA
Modified: 2021-04-19 13:24 EDT (History)
2 users (show)

See Also:


Attachments
Patch to set file encoding on imported project (1.30 KB, patch)
2011-05-24 06:46 EDT, Lóránt Pintér CLA
no flags Details | Diff
Plugin code patch (1.52 KB, patch)
2011-08-01 17:14 EDT, Anders Hammar CLA
igor: iplog+
Details | Diff
Integration tests for the implementation (11.86 KB, patch)
2011-08-01 17:34 EDT, Anders Hammar CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Hammar CLA 2011-04-27 02:37:29 EDT
Build Identifier: 

For a Maven project, if the project.build.sourceEncoding property is configured I think that the text file encoding should be configured accordingly for the Eclipse project.
This is similar to issue #340507 and #343818, but configuration for the entire Eclipse project. Any configuring for a specific Maven plugin (like these issues mentioned) would override this but just for some specific folders.

Reproducible: Always
Comment 1 Anders Hammar CLA 2011-05-01 03:24:55 EDT
Does this sound as a good idea? I'll look into creating a patch and ITs if you thinks so.
Comment 2 Igor Fedorenko CLA 2011-05-01 08:42:30 EDT
yes, this does sound like a good idea, but I am not sure if we'll be able to merge your patch for this release.
Comment 3 Lóránt Pintér CLA 2011-05-24 06:46:18 EDT
Created attachment 196421 [details]
Patch to set file encoding on imported project

At work we've been using this piece of code for quite some time, and it works great. It would be nice to see this solved in M2E internally, though.
Comment 4 Anders Hammar CLA 2011-05-24 07:15:19 EDT
We need to get some ITs for this. If no one beats me to it, I'll do that.
Comment 5 Anders Hammar CLA 2011-06-04 16:20:27 EDT
Ok, so we set the file encoding for the project based on the 'project.build.sourceEncoding' Maven property. But what about file encoding manually set on any file or folder by the user, should we reset that to the project defined file encoding?
I believe we should as that's the only way to ensure that all users have the same setting. Any manually set setting will differ between different users.
Comment 6 Igor Fedorenko CLA 2011-06-05 08:20:49 EDT
Our approach so far was to preserve explicit user configuration. This is what we do for project classpath, for example, and this is what we should do for file encoding imho. IDE configuration can be shared via version control system, so inconsistent encoding among project members is not an issue. Inconsistent behaviour between IDE and command line build is an issue, but lets assume the user knows what they are doing.
Comment 7 Anders Hammar CLA 2011-08-01 14:54:14 EDT
I'm working on a patch (update of Lorant's patch) and a set of ITs. The code should be done already, but I need to review it before submitting it.
Comment 8 Anders Hammar CLA 2011-08-01 17:14:09 EDT
Created attachment 200681 [details]
Plugin code patch
Comment 9 Anders Hammar CLA 2011-08-01 17:34:31 EDT
Created attachment 200682 [details]
Integration tests for the implementation
Comment 10 Anders Hammar CLA 2011-08-01 17:36:16 EDT
OK, I'm done. Please note that my patch replaces the one by Lóránt.
Comment 11 Anders Hammar CLA 2011-08-01 17:41:10 EDT
(In reply to comment #6)
> Our approach so far was to preserve explicit user configuration. This is what
> we do for project classpath, for example, and this is what we should do for
> file encoding imho. IDE configuration can be shared via version control system,
> so inconsistent encoding among project members is not an issue. Inconsistent
> behaviour between IDE and command line build is an issue, but lets assume the
> user knows what they are doing.

I'd just like to clarify that the implementation preserves explicit user configuration of encoding on folders and files. However, any user configuration of the Project encoding is replaced by the one specified by the pom property. The reason for this is that I haven't found a way of knowing if the Project encoding is set by the user or by m2e (and if the pom property value changes the project encoding set by m2e needs to be changed).
Comment 12 Igor Fedorenko CLA 2011-08-03 08:44:44 EDT
Applied the patches. Thank you.
Comment 13 Denis Roy CLA 2021-04-19 13:24:42 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/