Skip to content
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

Ignore generated-sources #33

Closed
1 of 3 tasks
daniel-shuy opened this issue Dec 17, 2019 · 9 comments · Fixed by societe-generale/arch-unit-build-plugin-core#14
Closed
1 of 3 tasks

Ignore generated-sources #33

daniel-shuy opened this issue Dec 17, 2019 · 9 comments · Fixed by societe-generale/arch-unit-build-plugin-core#14

Comments

@daniel-shuy
Copy link

Summary

Currently the predefined rules are also scanning class files in generated-sources, which I have no control over. Is there a way to configure the plugin to ignore generated-sources?

Type of Issue

It is a :

  • bug
  • request
  • question regarding the documentation

Motivation

I don't have any control over the class files generated in generated-sources, thus have no way to resolve violations in the generated class files.

@vincent-fuchs
Copy link
Contributor

Thanks for this request !

Indeed, it could be interesting to set have an optional parameter in the config, to give a list of folders to ignore. We would have to implement it in https://github.com/societe-generale/arch-unit-build-plugin-core though.

I faced the exact same issue, but found a workaround. Maybe it's not the same issue, but I'll mention the workaround anyway :

By default, Lombok will generate getters on collections that don't have the javax.annotation.Nonnull annotation. And I had DontReturnNullCollectionTest rule raising violations.

To avoid this, I found 2 solutions :

  • write the getter yourself for these fields : in that case you can make sure that null is never returned by testing it before returning the value, and returning an empty list if it is.

  • tweak the Lombok annotation, as described here : https://projectlombok.org/features/experimental/onX

     @Getter(onMethod_={@Nonnull})

But in that case, I am quite sure it's still possible that null is returned, even though the annotation says otherwise - so it may be misleading.

@daniel-shuy
Copy link
Author

Thanks. Unfortunately my issue is not with Lombok, but MapStruct, which has no way of configuring the generated methods.

@vincent-fuchs
Copy link
Contributor

fixed in v2.4.0

@daniel-shuy
Copy link
Author

Still having this issue with arch-unit-maven-plugin 2.4.0 and arch-unit-build-plugin-core 2.5.2. Is there anything that I have to configure specifically?

@vincent-fuchs
Copy link
Contributor

yes, I've added a new config parameter (see the documentation) :

<excludedPaths>
    <excludedPath>generated-sources</excludedPath>
</excludedPaths>

@daniel-shuy
Copy link
Author

Just tried with that, seems like it doesn't work either. It only seems to match the package name or class name, not the full path.

@vincent-fuchs
Copy link
Contributor

Just tried with that, seems like it doesn't work either. It only seems to match the package name or class name, not the full path.

archUnit looks at the compiled code, not the source code. Do you know in which folder your generated-sources code gets compiled ? you could try to configure this directory instead

@daniel-shuy
Copy link
Author

daniel-shuy commented Mar 24, 2020

archUnit looks at the compiled code, not the source code

Oh right, I forgot about that. Looks like there's no way I can just ignore all classes in generated-sources, as they are all compiled in their respective packages under target. The most I can do is to group all the MapStruct classes in the same package and ignore the package. Thanks.

@vincent-fuchs
Copy link
Contributor

maybe you can change that behavior by tweaking the maven-compile plugin... but not sure !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants