gpt4 book ai didi

maven - 禁用 checkstyle maven 插件生成的源目录

转载 作者:行者123 更新时间:2023-12-02 20:31:26 26 4
gpt4 key购买 nike

在一个多模块项目中,有一个在目录 target/generated-sources/xjc3/com/... 中生成一些源代码我正在尝试使 Maven checkstyle 插件跳过此生成的源目录。尽管尝试了 <excludes> 的多种语法tag,它会不断扫描这个源目录。 有人知道如何从审核中删除这个生成的源目录吗?

Maven插件配置

    <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>checkstyle</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.7</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>cloudstack-checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>cloud-style.xml</configLocation>
<consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<includes>**\/*.java</includes>
<excludes>**\/deps\/,**\/test\/,**\/target\/,**\/bin\/,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/apidoc\/,**\/generated-sources\/,**\/generated-sources\/*,**\/generated-sources\/**,**\/generated-sources\/**\/*.*,**/generated-sources/**/*.*,**/generated-sources/**/*,**/generated-sources/**,**/generated-sources/*,**/generated-sources/*.*</excludes>
</configuration>
</plugin>

Maven 运行调试输出

这是插件调试输出,它显示它不断包含生成的源目录:

[INFO] --- maven-checkstyle-plugin:3.0.0:check (cloudstack-checkstyle) @ cloud-plugin-network-vcs ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0, parent: sun.misc.Launcher$AppClassLoader@74a14482]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check' with basic configurator -->
[DEBUG] (f) cacheFile = /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/checkstyle-cachefile
[DEBUG] (f) configLocation = cloud-style.xml
[DEBUG] (f) consoleOutput = true
[DEBUG] (f) encoding = UTF-8
[DEBUG] (f) excludes = **\/deps\/,**\/test\/,**\/target\/,**\/bin\/,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/apidoc\/,**\/generated-sources\/,**\/generated-sources\/*,**\/generated-sources\/**,**\/generated-sources\/**\/*.*,**/generated-sources/**/*.*,**/generated-sources/**/*,**/generated-sources/**,**/generated-sources/*,**/generated-sources/*.*
[DEBUG] (f) failOnViolation = true
[DEBUG] (f) failsOnError = true
[DEBUG] (f) headerLocation = LICENSE.txt
[DEBUG] (f) includeResources = true
[DEBUG] (f) includeTestResources = true
[DEBUG] (f) includeTestSourceDirectory = true
[DEBUG] (f) includes = **\/*.java
[DEBUG] (f) logViolationsToConsole = true
[DEBUG] (f) maxAllowedViolations = 0
[DEBUG] (f) omitIgnoredModules = false
[DEBUG] (f) outputFile = /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/checkstyle-result.xml
[DEBUG] (f) outputFileFormat = xml
[DEBUG] (f) plugin = Component Descriptor: role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo', role hint: 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugins.checkstyle.CheckstyleReport', role hint: 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:checkstyle'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugins.checkstyle.CheckstyleAggregateReport', role hint: 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:checkstyle-aggregate'
role: 'org.apache.maven.plugin.Mojo', implementation: 'org.apache.maven.plugins.checkstyle.HelpMojo', role hint: 'org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:help'
---
[DEBUG] (f) project = MavenProject: org.apache.cloudstack:cloud-plugin-network-vcs:4.12.0.0-SNAPSHOT @ /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/pom.xml
[DEBUG] (f) resourceIncludes = **/*.properties
[DEBUG] (f) resources = [Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/main/resources, PatternSet [includes: {}, excludes: {}]}}, Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc1, PatternSet [includes: {**/jaxb.properties, **/bgm.ser}, excludes: {}]}}, Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc2, PatternSet [includes: {**/jaxb.properties, **/bgm.ser}, excludes: {}]}}, Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc3, PatternSet [includes: {**/jaxb.properties, **/bgm.ser}, excludes: {}]}}, Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/maven-shared-archive-resources, PatternSet [includes: {}, excludes: {}]}}]
[DEBUG] (f) rulesFiles = /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/checkstyle-rules.xml
[DEBUG] (f) skip = false
[DEBUG] (f) skipExec = false
[DEBUG] (f) suppressionsFileExpression = checkstyle.suppressions.file
[DEBUG] (f) testResources = [Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/test/resources, PatternSet [includes: {}, excludes: {}]}}, Resource {targetPath: null, filtering: false, FileSet {directory: /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/maven-shared-archive-resources, PatternSet [includes: {}, excludes: {}]}}]
[DEBUG] (f) violationSeverity = error
[DEBUG] -- end configuration --
[DEBUG] executeCheckstyle start headerLocation : LICENSE.txt
[DEBUG] Added 27 source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/main/java'.
[DEBUG] Added 5 source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc1'.
[DEBUG] Added 5 source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc2'.
[DEBUG] Added 7 source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc3'.
[DEBUG] Added 0 source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/annotations'.
[DEBUG] Added 3 test source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/test/java'.
[DEBUG] Added 0 test source files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-test-sources/test-annotations'.
[DEBUG] Added 1 resource files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/main/resources'.
[DEBUG] Added 0 resource files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc1'.
[DEBUG] Added 0 resource files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc2'.
[DEBUG] Added 0 resource files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc3'.
[DEBUG] Added 0 resource files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/maven-shared-archive-resources'.
[DEBUG] The resources directory '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/test/resources' does not exist or is not a directory.
[DEBUG] Added 0 resource files found in '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/maven-shared-archive-resources'.
[DEBUG] Added 48 files to process.
[DEBUG] Adding the outputDirectory file:/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/classes/ to the Checkstyle class path
[DEBUG] Adding the outputDirectory file:/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/test-classes/ to the Checkstyle class path
[DEBUG] request.getConfigLocation() cloud-style.xml
[DEBUG] The resource 'cloud-style.xml' was not found with resourceLoader org.codehaus.plexus.resource.loader.FileResourceLoader.
[DEBUG] The resource 'cloud-style.xml' was not found with resourceLoader org.codehaus.plexus.resource.loader.JarResourceLoader.
[DEBUG] URLResourceLoader: No valid URL 'cloud-style.xml'
[DEBUG] URLResourceLoader: No valid URL 'cloud-style.xml'
[DEBUG] The resource 'cloud-style.xml' was not found with resourceLoader org.codehaus.plexus.resource.loader.URLResourceLoader.
[DEBUG] The resource 'cloud-style.xml' was found as jar:file:/home/marco/.m2/repository/org/apache/cloudstack/checkstyle/4.12.0.0-SNAPSHOT/checkstyle-4.12.0.0-SNAPSHOT.jar!/cloud-style.xml.
[DEBUG] headerLocation LICENSE.txt
[DEBUG] The resource 'LICENSE.txt' was not found with resourceLoader org.codehaus.plexus.resource.loader.FileResourceLoader.
[DEBUG] JarResourceLoader : trying to load "jar:file:/home/marco/.m2/repository/org/apache/cloudstack/checkstyle/4.12.0.0-SNAPSHOT/checkstyle-4.12.0.0-SNAPSHOT.jar"
[DEBUG] JarResourceLoader : trying to load "jar:file:/home/marco/.m2/repository/com/puppycrawl/tools/checkstyle/8.7/checkstyle-8.7.jar"
[DEBUG] The resource 'LICENSE.txt' was not found with resourceLoader org.codehaus.plexus.resource.loader.JarResourceLoader.
[DEBUG] URLResourceLoader: No valid URL 'LICENSE.txt'
[DEBUG] URLResourceLoader: No valid URL 'LICENSE.txt'
[DEBUG] The resource 'LICENSE.txt' was not found with resourceLoader org.codehaus.plexus.resource.loader.URLResourceLoader.
[DEBUG] Unable to process header location: LICENSE.txt
[DEBUG] Checkstyle will throw exception if ${checkstyle.header.file} is used
[DEBUG] Added '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/src/main/resources' as a source directory.
[DEBUG] Added '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc1' as a source directory.
[DEBUG] Added '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc2' as a source directory.
[DEBUG] Added '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc3' as a source directory.
[DEBUG] Added '/home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/maven-shared-archive-resources' as a source directory.
[INFO] Starting audit...
[ERROR] /home/marco/code/cloudstack-public/plugins/network-elements/brocade-vcs/target/generated-sources/xjc1/com/cloud/network/schema/interfacevlan/ObjectFactory.java:2: Line has trailing spaces. [RegexpSingleline]

最佳答案

如果您的所有模块都有一致的源文件夹位置,您可以将源文件夹锁定到“真实”源

<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<sourceDirectories>
<sourceDirectory>src/main/java</sourceDirectory>
</sourceDirectories>
</configuration>
</plugin>

或者(最好)包括来源和测试

<sourceDirectories>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>

关于maven - 禁用 checkstyle maven 插件生成的源目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48618140/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com