-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improve combability with cobertura #1014
Comments
Another solution idea: At the end, for every |
As a workaround I did a few modifications to the lombok code to write the lombok.Generated annotation in addition. Changes:
Result:
|
It is possible to add an extra option to FormatPreferences either generate or not generate source code using the lombok.Generated annotation. I think by default the lombok.Generated should not be generated in delomboked code. Regarding the forked library: we do accept pull requests... |
Yes please, @halmafest. As the person who reported the dupe issue #1102, I'd love to see this pulled in to mainline lombok. Thank you very much. |
I will see if I can find some time the next weeks o make a clean pull request.
|
Thanks for offering to implement it. I prefer to have an on/off toggle in the FormatPreferences, defaulting to not generate it when delombokking. |
I started to implement this and I stuck a bit in the JavacHandlerUtil class. Maybe its only an understanding issue. As I understand there are two ways to configure lombok.
The FormatPreferences are checked first, ConfigurationKeys second. public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) return;
if (!Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_GENERATED_ANNOTATIONS))) {
addAnnotation(mods, node, pos, source, context, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok"));
}
} This works fine as long the default value for an option in the FormatPreferences is set to true. For the new feature I like to set the default to false. This will lead to situation that for a normal javac run the FormatPreferences will be set to the defaults and the ConfigurationKeys are ignored. I'm not sure how to solve this issue in the best way. Maybe there is a way to merge both configuration worlds. |
I was wondering if there was any motion on this. Or if there was any way that I could help with it. I'd love to have this, and I'm willing to at least try to help. Thank you very much. |
I forked Lombok, added a config key to specify the name of the annotation (like "lombok.generatedAnnotationName = com.whatever.test.LombokGenerated") which can then have a retain value of 'class', tested it with Cobertura and it worked perfectly fine. Since the ignore features in Jacoco are still in development I didn't bother testing them, but I see no reason it wouldn't work with that as well. I could make a PR, it's only like five lines of code changes, but I don't know how the Lombok team feels about adding config keys. @rspilker ? |
From now on, whenever To turn them both on or off, use the (original) configuration key To override this general setting, use the keys For |
We've just created an edge release. Can someone try this out on cobertura and/or Jacoco? |
I can confirm it working with Cobertura and:
I have no Jacoco test environment set up since their filtering stuff is still in a dev branch as far as I can tell. Thanks for fixing/implementing this! |
This looks very promising! Thanks for your efforts. |
Slight change of plans. The (original) configuration key To generate We expect the release a new version of lombok within a few days. |
I use lombok to generate a lot of code and I really like it!
To measure the code coverage we use cobertura
We like to use the cobertura option ignoreAnnotations. Basically the feature allows to disable code coverage checks of methods annotated with a defined annotation. Unfortunately the annotation added by lombok javax.annotation.Generated does not work.
Reasons:
Possible solutions:
The text was updated successfully, but these errors were encountered: