How to write to configLocation a checkstyle.xml file in a library?

47 Views Asked by At

We have 10+ microservices and we are slowly getting to the point where their general settings are spread across libraries. One suggested idea is to put checkstyle.xml into a separate library and add this library to each microservice, and in <configLocation></configLocation> specify the configuration file from the library. Howerver there are some issues about specifying the path of <configLocation></configLocation>. It just cannot find the file.

My library scheme:

A microservice pom.xml

checkstyle-lib/src/main/resources/checkstyle.xml

             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven-checkstyle-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.veon.eurasia.marketplace.common</groupId>
                        <artifactId>beeline-checkstyle-common</artifactId>
                        <version>0.1.0</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <configLocation>***I need to put here xml file from the library***</configLocation>
                    <violationSeverity>warning</violationSeverity>
                    <sourceDirectories>
                        <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
                    </sourceDirectories>
                </configuration>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

I have tried dosens of varants like these:

<configLocation>${user.home}\.m2\repository\com\example\checkstyle-lib\0.1.0\checkstyle-lib-0.1.0.jar!\checkstyle.xml</configLocation>
<configLocation>checkstyle-lib-0.1.0.jar!\checkstyle.xml</configLocation>
<configLocation>checkstyle-lib\checkstyle.xml</configLocation>
<configLocation>checkstyle-lib\src\main\resources\checkstyle.xml</configLocation>
and a lot of combinations and having a  Failed during checkstyle execution: Unable to find configu
ration file at location:
0

There are 0 best solutions below