maven-pmd-plugin禁用一个模块

问题描述 投票:2回答:2

我正在尝试为maven项目模块之一禁用maven-pmd-plugin的执行,但找不到可行的解决方案。 现在我在模块中有下一个:

    <properties>
      <cpd.skip>true</cpd.skip>
      <pmd.skip>true</pmd.skip>
      <maven.pmd.enable>false</maven.pmd.enable>
      <maven.pmd.cpd.enable>false</maven.pmd.cpd.enable>
    </properties>

并在调试输出中有下一个:

[INFO] --- maven-pmd-plugin:3.2:cpd (pmd-cpd) @ module ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-pmd-plugin:3.2:cpd from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-pmd-plugin:3.2, parent: sun.misc.Launcher$AppClassLoader@6e70c242]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-pmd-plugin:3.2:cpd' with basic configurator -->
[DEBUG]   (f) aggregate = false
[DEBUG]   (f) compileSourceRoots = [/cicd/module/src/main/java]
[DEBUG]   (f) format = xml
[DEBUG]   (f) ignoreIdentifiers = false
[DEBUG]   (f) ignoreLiterals = false
[DEBUG]   (f) includeTests = false
[DEBUG]   (f) includeXmlInSite = false
[DEBUG]   (f) linkXRef = true
[DEBUG]   (f) minimumTokens = 100
[DEBUG]   (f) outputDirectory = /cicd/module/target/site
[DEBUG]   (f) skip = true
[DEBUG]   (f) skipEmptyReport = true
[DEBUG]   (f) targetDirectory = /cicd/module/target
[DEBUG]   (f) testSourceRoots = [/cicd/module/src/test/java]
[DEBUG]   (f) xrefLocation = /cicd/module/target/site/xref
[DEBUG]   (f) xrefTestLocation = /cicd/module/target/site/xref-test
[DEBUG] -- end configuration --
[DEBUG] Exclusions: **/*~,**/#*#,**/.#*,**/%*%,**/._*,**/CVS,**/CVS/**,**/.cvsignore,**/RCS,**/RCS/**,**/SCCS,**/SCCS/**,**/vssver.scc,**/project.pj,**/.svn,**/.svn/**,**/.arch-ids,**/.arch-ids/**,**/.bzr,**/.bzr/**,**/.MySCMServerInfo,**/.DS_Store,**/.metadata,**/.metadata/**,**/.hg,**/.hg/**,**/.git,**/.gitignore,**/.gitattributes,**/.git/**,**/BitKeeper,**/BitKeeper/**,**/ChangeSet,**/ChangeSet/**,**/_darcs,**/_darcs/**,**/.darcsrepo,**/.darcsrepo/**,**/-darcs-backup*,**/.darcs-temp-mail
[DEBUG] Inclusions: **/*.java
[DEBUG] Searching for files in directory /cicd/module/src/main/java
[WARNING] File encoding has not been set, using platform encoding ANSI_X3.4-1968, i.e. build is platform dependent!
[DEBUG] Executing CPD...

我想知道为什么如果skip = true它会执行 根据官方FAQ,我需要“简单地将maven.pmd.enable = false放入您的项目属性中,用于该子项目。”可能我没有正确地将它放入pom。它只是 在模块pom文件中? -Dpmd.skip = true -Dcpd.skip = true给出相同的结果

maven pmd
2个回答
4
投票

如果要禁用maven模块,则在该模块中配置pmd。然后排除所有。像这样:

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<configuration>
					<analysisCache>true</analysisCache>
					<!-- enable incremental analysis -->
					<excludes>
						<exclude>**/**</exclude>
					</excludes>
				</configuration>
			</plugin>

Maven multimodul文档;hier描述,子模块中的配置会覆盖顶级pom定义。


1
投票

我找到了一个更好的解决方案,看看Disable a Maven plugin defined in a parent POM

这样你就可以禁用插件,因此它根本不会运行模块,因此不会生成任何内容,因此这样构建时间也会减少。

© www.soinside.com 2019 - 2024. All rights reserved.