Skip to content

[MCHECKSTYLE-412] - Exclude generated sources / test-sources from defau… #76

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

Merged
merged 1 commit into from
May 24, 2023

Conversation

gmshake
Copy link
Contributor

@gmshake gmshake commented May 13, 2022

…lt source / test-source directories

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MCHECKSTYLE-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MCHECKSTYLE-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@slawekjaranowski slawekjaranowski self-requested a review May 14, 2022 09:33
@slawekjaranowski
Copy link
Member

Does the effect not will be the same as we will use for default:

project.build.sourceDirectory
project.build.testSourceDirectory

without special filtering ...

@gmshake
Copy link
Contributor Author

gmshake commented May 16, 2022

Does the effect not will be the same as we will use for default:

project.build.sourceDirectory
project.build.testSourceDirectory

without special filtering ...

Not exactly.

In my team we have many projects specify the sourceDirectories as we have JPA annotation processors and OpenAPI tools to generate REST API stubs. It is a burden we specify it now and then, so it will be perfectly that the default setting works OOB.
I had tried to change sourceDirectories default to project.build.sourceDirectory but it breaks https://issues.apache.org/jira/browse/MCHECKSTYLE-70 as some users use build-helper-maven-plugin to inject source directories to the build. It looks that the best solution is excluding generated sources / test-sources from the build (project.compileSourceRoots / project.testCompileSourceRoots) before sending them to checkstyle.

It will be perfect that Maven core provide some API like getGeneratedCompileSourceRoots / getGeneratedTestCompileSourceRoots but apparently it will not go for 3.6.x and earlier versions (3.0.x, 3.3.x) . Since the generated sources / test-sources should be in build target directory we can bravely exclude the entire build target directory.

@michael-o
Copy link
Member

What if I want to invert this and do check generated source?

@gmshake
Copy link
Contributor Author

gmshake commented Apr 18, 2023

What if I want to invert this and do check generated source?

Well, this PR changes the default settings. You can still specify the sourceDirectories and testSourceDirectories, then checkstyle will check those directories.

@elharo
Copy link
Contributor

elharo commented May 13, 2023

Anyone want to resolve conflicts and merge? This would be useful.

@gmshake
Copy link
Contributor Author

gmshake commented May 19, 2023

Anyone want to resolve conflicts and merge? This would be useful.

I'll rebase it at this weekend.

I do not have write access to the Apache repository so I'll leave the merge to someone who's capable to do.

@gmshake gmshake force-pushed the feature/MCHECKSTYLE-412 branch from 0bcabd4 to 471ecd2 Compare May 22, 2023 10:24
@gmshake
Copy link
Contributor Author

gmshake commented May 22, 2023

  1. Rebased onto latest master
  2. Added a knob excludeGeneratedSources to not break existing setups, it is false by default

Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this would have an IT showning the benefit.

@gmshake
Copy link
Contributor Author

gmshake commented May 24, 2023

@michael-o

Would be nice if this would have an IT showning the benefit.

Done !

@michael-o
Copy link
Member

@michael-o

Would be nice if this would have an IT showning the benefit.

Done !

Testing...

…s from default source/test-source directories

This closes apache#76
@michael-o michael-o force-pushed the feature/MCHECKSTYLE-412 branch from 73bfe51 to 1c271f1 Compare May 24, 2023 11:17
@asfgit asfgit closed this in 1c271f1 May 24, 2023
@asfgit asfgit merged commit 1c271f1 into apache:master May 24, 2023
@gmshake
Copy link
Contributor Author

gmshake commented May 24, 2023

Thanks!

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 this pull request may close these issues.

6 participants