Community
Participate
Working Groups
The long awaited feature to hide warnings in individual source folders (new feature in Eclipse 4.2) does not work with m2e. When I activate that feature for a source folder, and call "Maven->Update Projects..." then the ignore_option_problems line is removed my m2e. Steps to reproduce: 1. Select a source folder of a maven project 2. Open Properties (ALT-RETURN) 3. Navigate to Java Compiler 4. Enable 'Ignore optional compile problems' 5. Press ok. => Class path has a similar element <classpathentry kind="src" output="target/classes" path="target/generated-sources/localizer"> <attributes> <attribute name="ignore_optional_problems" value="true"/> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> 6. Start Maven->Update Projects..., select the project and press OK => Class path is re-created, but the attribute ignore_optional_problems is removed (or not re-created) Actual: <classpathentry kind="src" output="target/classes" path="target/generated-sources/localizer"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> Expected would be no change in the class path file.
There are no immediate plans to work on this issue, somebody will have to investigate the problem and provide a quality patch.
I'm also experiencing this problem. Seems like the issue may be more general, that m2e is losing any <attribute> elements set on <classpathentry> elements. Could you at least point us to where in the code "Maven->Update Projects..." is setting the classpath entry attributes?
You might want to take a look at addSourceDirs and addResourceDirs in http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java#n327
Created attachment 222486 [details] Patch to retain "ignore_optional_problems" attribute The attached patch preserves the "ignore_optional_problems" attribute when altering the classpath. It is not a general purpose solution to preserve any non-pom derived attributes, but it solves the problem listed in the original bug report in just a few lines of code.
The patch does not look right, but before I can know sure I would like to see a regression test that fails without the patch and passes with the patch applied. m2e tests live in a separate git repository, you can find more info in http://wiki.eclipse.org/M2E_Development_Environment
Created attachment 222547 [details] Test for previous patch
The proposed patch effectively blocks m2e core and project configurators from disabling "ignore_optional_problems", i.e. once the attribute is set to true manually or using m2e APIs, there is no way to remove the attribute using m2e APIs any more. I am also not thrilled about special handling of this specific attribute, ideally it would be nice to preserve all classpath entry attributes, provided the entry did not change otherwise and provided there is a way for project configurators to explicitly add/remove attributes programmatically. I do not plan to apply this patch until at least the first concern is addressed.
This is really annoying because there are lots of warnings popping up because of generated sources. Is there any workaround?
So annoying. Also, nobody seems to have the time to fix this. Could we please accept the proposed patch to quickly fix the original issue that bothers so many of us and file a follow-up bug to track it further and possibly fix it properly once somebody finds the time?
I will release a plugin shortly that fixes that problem.
(In reply to Igor Fedorenko from comment #7) > I do not plan to apply this patch until at least the first concern is > addressed. So you are saying that you don't want to fix an _actual_ problem of many Eclipse users (most people using xtext or xtend have this property set for the generated code), because that fix might lead to a _hypothetical_ problem at another place? In the sense of agile development I'd like you to reconsider this, as applying the original patch will surely improve the user experience for many m2e users.
@Michael Keppler what code generation maven plugin do you use?
I am using JPA to generate metamodels so I can create criteria queries. This generated code makes use of raw types which result in a warning in Eclipse. Not being to remove these warnings is a real problem as it violates our best practices. Does anybody have a work-around to this three year old bug?
Fix applied to retain all existing classpath attributes : in master: http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=bb846493bc82785025bdc5f2cc37a75fe6459ee4 in m2e-1.6.x: http://git.eclipse.org/c/m2e/m2e-core.git/commit/?h=m2e-1.6.x&id=bb1a4dd26b66d9840a36ef337661188b99f17e7b Test in master: https://github.com/tesla/m2e-core-tests/commit/c839c1a6a49888c3cf846bf574f7ca9c9a77a646 Test in m2e-1.6.x: https://github.com/tesla/m2e-core-tests/commit/ed81dc8b6096ad2a29a4fac4307b5cb1c07640a1 Test showing attributes can be removed programmatically using m2e API: https://github.com/tesla/m2e-core-tests/commit/f1630cd5c052f7f587804ba7863693d21651168f Technically, this is a change in m2e behavior (=API change), since m2e used to delete all stale attributes before configurators could add new values. With this change, the responsibility shifted to configurators, to keep track/deal with stale attributes accordingly, on project update. But, until we find a real world example of catastrophic regression, I think the pros for this fix largely outweigh the cons.
THANK YOU! Very much appreciated. Were you ever in Prague in the future, I'd buy you a beer.
Moved to https://github.com/eclipse-m2e/m2e-core/issues/