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

Checkstyle plugin does not include modules from buildSrc #7425

Closed
barnabycourt opened this issue Oct 17, 2018 · 4 comments
Closed

Checkstyle plugin does not include modules from buildSrc #7425

barnabycourt opened this issue Oct 17, 2018 · 4 comments

Comments

@barnabycourt
Copy link

Expected Behavior

When using the checkstyle plugin I would expect that modules from buildSrc are available when checkstyle is executed. Because they are not included any custom checkstyle modules that are compiled via buildSrc are not on the classpath when the checkstyle module executes. This causes the checkstyle module to fail on initialization of the custom module. I would expect that any custom modules from buildSrc are available on the classpath so that they can be referenced via a custom checkstyle configuration.

Current Behavior

The checkstyle module does not include classpath entries for buildSrc jar file.

Context

I am trying to use a custom checkstyle module that is part of my project without including it in the output of the project. I could do this by using a sub project or putting the custom module in the main path but then I would have to manually filter the custom classes out of the generated artifacts. This becomes even more cumbersome in a multi-project build.

Steps to Reproduce (for bugs)

  1. Check out https://github.com/barnabycourt/gradle_checkstyle
  2. Run ./gradlew check
  3. Observe that the check run failed initializing the custom module & buildSrc is not included on the classpath that checkstyle is using.

Your Environment

@oehme
Copy link
Contributor

oehme commented Oct 17, 2018

This is working as intended, checkstyle is run in an isolated classloader with only the rules that were specified on its own classpath - You can create a subproject for your custom checkstyle rules and add that to the checkstyle classpath.

@oehme oehme closed this as completed Oct 17, 2018
@barnabycourt
Copy link
Author

@oehme If checkstyle is intended to be running with an isolated classloader why are the build/classes/java/main & build/resources/main directories included by default? Should that be opened as a bug?

@oehme
Copy link
Contributor

oehme commented Oct 17, 2018

Because Checkstyle needs them to run some of its checks on your code. It's not entirely source code based.

If it also looks for rules in there then that would be an odd implementation detail of Checkstyle, but not much we can do about. Checkstyle extensions are supposed to go into the checkstyle Configuration, as shown in the documentation.

@barnabycourt
Copy link
Author

@oehme Thanks for the background, I appreciate you taking the time.

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

No branches or pull requests

2 participants