maven-pmd-plugin禁用一个模块

时间:2014-10-24 10:59:53

标签: maven pmd

我试图为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,我需要&#34;简单地将maven.pmd.enable = false放入您的项目属性中,用于该子项目。&#34;可能我没有正确地将它放入pom。它只是&lt; properties&gt;在模块pom文件中?

-Dpmd.skip = true -Dcpd.skip = true给出相同的结果

2 个答案:

答案 0 :(得分: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-documentation ;hier 描述,子模块中的配置会覆盖顶级pom定义。

答案 1 :(得分:1)

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

这样,您将禁用插件,因此该插件根本不会在模块上运行,因此不会生成任何内容,因此,构建时间也会减少。