Class CheckstyleChecker
java.lang.Object
org.jdrupes.builder.core.AbstractProvider
org.jdrupes.builder.core.AbstractGenerator
org.jdrupes.builder.ext.checkstyle.CheckstyleChecker
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
A Generator that runs checkstyle on the project's Java sources.
The checkstyle configuration is loaded from a file named
checkstyle.xml. First, the project's directory is searched. If
not found, the search continues in the parent project's directory
and so on, up to the root project. The configuration path can also
be set explicitly with config(java.nio.file.Path).
Each style violation is printed to [context().error()]. The resulting
CheckstyleResult contains summary counts. When errors are found,
the result is flagged as faulty unless ignoreFailed was invoked.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal CheckstyleCheckeraddSources(Path directory, String pattern) Adds the files from the given directory matching the given pattern.final CheckstyleCheckeraddSources(FileTree<JavaSourceFile> sources) Adds the source tree.Sets the path to the checkstyle configuration file.protected <T extends Resource>
Collection<T> doProvide(ResourceRequest<T> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.Ignore errors.sources()Returns the source trees configured for the checker.Methods inherited from class AbstractGenerator
cleanup, name, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
context, name, of, resources
-
Constructor Details
-
CheckstyleChecker
Initializes a new style checker.- Parameters:
project- the project
-
-
Method Details
-
ignoreFailed
Ignore errors. If invoked, the checker does not set the faulty flag of the checkstyle result when errors have been found.- Returns:
- the checkstyle checker
-
config
Sets the path to the checkstyle configuration file. ThePathis resolved against the project's directory when left relative.- Parameters:
configPath- the configuration file path- Returns:
- the style checker
-
addSources
Adds the source tree.- Parameters:
sources- the sources- Returns:
- the style checker
-
addSources
Adds the files from the given directory matching the given pattern. Short foraddSources(FileTree.of(project(), directory, JavaSourceFile.class, pattern)).- Parameters:
directory- the directorypattern- the pattern- Returns:
- the style checker
-
sources
Returns the source trees configured for the checker.- Returns:
- the resources
-
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the request for resources- Returns:
- the stream
-