Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343818

Summary: File encoding for resources
Product: z_Archived Reporter: Anders Hammar <anders.g.hammar>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: fbricon, igor, mkleint
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch in git format
none
Updated patch
fbricon: iplog+
integration tests none

Description Anders Hammar CLA 2011-04-26 06:58:39 EDT
Build Identifier: 

Similar to how encoding is set for Java sources (issue #340507) folder, I think that the encoding should be automatically set for resources folders.

I suggest that the encoding configured for resources:resources and resources:testResources should be used. It is highly unlikely that different encoding is configured for those two goals, but it is possible configuration wise.

Reproducible: Always

Steps to Reproduce:
1. Create a Maven project
2. Right-click on src/main/resources folder and select 'Properties'
3. For Text file encoding it states "Inherited from container" which most likely will be the wrong encoding for your Maven project
Comment 1 Anders Hammar CLA 2011-04-26 07:03:08 EDT
There is one slight difference between encoding configured for maven-compiler-plugin and maven-resources-plugin. For the resources plugin, the encoding is only used when doing filtering.
But I still think that the configured encoding is a safe guess for any created file in that folder, even though filtering isn't configured for it. Do you agree?
Comment 2 Milos Kleint CLA 2011-04-26 07:16:01 EDT
slightly unrelated but as far as I remember, netbeans is using the the maven encoding for resources  as well. The encoding property (project.build.sourceEncoding) is even used from the project customizer UI to change the "project" encoding. if the maven definition is not present, it falls back to OS platform specific default.
Comment 3 Anders Hammar CLA 2011-04-27 02:39:01 EDT
(In reply to comment #2)
> slightly unrelated but as far as I remember, netbeans is using the the maven
> encoding for resources  as well. The encoding property
> (project.build.sourceEncoding) is even used from the project customizer UI to
> change the "project" encoding. if the maven definition is not present, it falls
> back to OS platform specific default.

Filed bug 343927 for this enhancement.
Comment 4 Anders Hammar CLA 2011-04-28 03:11:39 EDT
Created attachment 194233 [details]
Patch in git format

I've attached a patch for this, heavily influence by the patch for bug 340507. I have tested it manually and will continue to work on integration tests for it.
Comment 5 Anders Hammar CLA 2011-04-28 08:21:43 EDT
Created attachment 194256 [details]
Updated patch

Retry: attached an updated patch which should be in correct git format
Comment 6 Anders Hammar CLA 2011-04-28 08:23:24 EDT
I sent a pull request in Github for the integration tests.
Comment 7 Anders Hammar CLA 2011-04-28 10:11:24 EDT
Created attachment 194272 [details]
integration tests

Patch file for integration tests added, replacing the pull request sent in Github.
Comment 8 Igor Fedorenko CLA 2011-04-29 23:30:52 EDT
Applied the patch with minor fixes to one of test projects (was missing extra resource folders). Thank you.
Comment 9 Fred Bricon CLA 2013-02-11 19:16:25 EST
Comment on attachment 194256 [details]
Updated patch

cleaning IP Log up
Comment 10 Denis Roy CLA 2021-04-19 13:27:04 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/