Cobertura Maven插件失败了"命令行太长"在Windows上

时间:2015-05-23 18:18:44

标签: java maven code-coverage cobertura maven-cobertura-plugin

当我在Windows 8.1上使用lengthy configuration运行cobertura-maven-plugin时(用于禁止项目中的任何覆盖率下降)cobertura:check目标失败,错误为The command line is too long.

问题可能与Command prompt (Cmd. exe) command-line string limitation有关,因为当我限制提供给Cobertura的配置数量时它会消失。而且,它在Linux上运行良好。

我该如何克服这个问题?

登录调试级别:

[DEBUG] Executing command line:
[DEBUG] cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_25\jre\bin\java" net.sourceforge.cobertura.check.CheckCoverageMain --datafile C:\IdeaProjects\checkstyle\target\cobertura\cobertura.ser --branch 100 --line 100 --totalbranch 82 --totalline 90 --regex .*.checks.UncommentedMainCheck:88:83 --regex .*.checks.indentation.MethodCallLineWrapHandler:0:0 --regex .*.checks.indentation.ImportHandler:87:50 --regex .*.checks.imports.Guard:100:86 --regex .*.checks.sizes.AnonInnerLengthCheck:92:100 --regex .*.checks.DeclarationCollector:100:94 --regex .*.checks.whitespace.ParenPadCheck:95:86 --regex .*.TreeWalker:91:92 --regex .*.checks.naming.AbstractTypeParameterNameCheck:83:75 --regex .*.checks.naming.LocalVariableNameCheck:100:94 --regex .*.api.SeverityLevelCounter:76:50 --regex .*.checks.indentation.ForHandler:95:75 --regex .*.checks.regexp.RegexpMultilineCheck:76:100 --regex com.puppycrawl.tools.checkstyle.Utils:93:85 --regex .*.checks.coding.VariableDeclarationUsageDistanceCheck:97:90 --regex .*.checks.imports.ImportControlLoader:88:72 --regex .*.api.LocalizedMessage:81:66 --regex .*.api.FileContents:94:96 --regex .*.api.AbstractViolationReporter:90:100 --regex .*.checks.imports.CustomImportOrderCheck:91:93 --regex .*.checks.javadoc.AbstractJavadocCheck:93:90 --regex .*.checks.naming.ConstantNameCheck:92:88 --regex .*.checks.javadoc.HtmlTag:90:75 --regex .*.api.ScopeUtils:0:0 --regex .*.checks.modifier.RedundantModifierCheck:96:97 --regex .*.DefaultLogger:76:75 --regex .*.checks.metrics.BooleanExpressionComplexityCheck:80:74 --regex .*.checks.design.OneTopLevelClassCheck:95:77 --regex .*.checks.coding.DefaultComesLastCheck:90:87 --regex .*.checks.sizes.ExecutableStatementCountCheck:95:81 --regex .*.checks.UpperEllCheck:83:100 --regex .*.checks.regexp.CommentSuppressor:100:75 --regex .*.checks.naming.AbstractClassNameCheck:90:100 --regex .*.checks.javadoc.WriteTagCheck:91:100 --regex .*.checks.CheckUtils:97:91 --regex .*.checks.DescendantTokenCheck:96:91 --regex .*.checks.coding.UnnecessaryParenthesesCheck:96:91 --regex .*.checks.blocks.RightCurlyCheck:95:88 --regex .*.checks.coding.IllegalTypeCheck:93:93 --regex .*.checks.TodoCommentCheck:92:100 --regex .*.checks.coding.MultipleVariableDeclarationsCheck:96:96 --regex .*.checks.ClassResolver:93:86 --regex .*.checks.coding.DeclarationOrderCheck:90:82 --regex .*.checks.blocks.LeftCurlyCheck:94:87 --regex .*.checks.coding.AbstractIllegalMethodCheck:92:100 --regex .*.checks.whitespace.EmptyForInitializerPadCheck:93:91 --regex .*.checks.whitespace.WhitespaceAroundCheck:98:96 --regex .*.checks.coding.ParameterAssignmentCheck:91:80 --regex .*.checks.whitespace.NoWhitespaceBeforeCheck:100:90 --regex .*.PropertiesExpander:83:50 --regex .*.checks.indentation.BlockParentHandler:98:86 --regex .*.checks.metrics.AbstractClassCouplingCheck\$.*:100:78 --regex .*.checks.coding.IllegalInstantiationCheck:94:77 --regex .*.checks.coding.SimplifyBooleanExpressionCheck:77:100 --regex .*.checks.RegexpCheck:100:97 --regex .*.checks.coding.ReturnCountCheck:74:55 --regex .*.api.JavadocTagInfo:77:25 --regex .*.checks.coding.AvoidInlineConditionalsCheck:66:100 --regex .*.checks.coding.FinalLocalVariableCheck:100:79 --regex .*.api.AutomaticBean:82:90 --regex .*.checks.coding.InnerAssignmentCheck:97:88 --regex .*.checks.whitespace.EmptyForIteratorPadCheck:92:100 --regex .*.checks.coding.RequireThisCheck:89:100 --regex .*.checks.imports.AvoidStaticImportCheck:95:85 --regex .*.checks.whitespace.TypecastParenPadCheck:88:87 --regex .*.checks.naming.AbstractAccessControlNameCheck:80:95 --regex .*.checks.ArrayTypeStyleCheck:94:100 --regex .*.checks.TranslationCheck:83:81 --regex .*.checks.javadoc.JavadocTypeCheck:91:95 --regex .*.checks.AbstractOptionCheck:80:100 --regex .*.checks.coding.EqualsHashCodeCheck:96:75 --regex .*.checks.naming.MemberNameCheck:85:91 --regex .*.checks.javadoc.JavadocTagContinuationIndentationCheck:86:81 --regex .*.checks.whitespace.EmptyLineSeparatorCheck:98:95 --regex .*.checks.metrics.NPathComplexityCheck:96:100 --regex .*.checks.header.RegexpHeaderCheck:93:87 --regex .*.checks.AvoidEscapedUnicodeCharactersCheck:98:97 --regex .*.checks.javadoc.JavadocMethodCheck:96:90 --regex .*.checks.coding.ModifiedControlVariableCheck:93:83 --regex .*.checks.whitespace.MethodParamPadCheck:95:100 --regex .*.checks.annotation.MissingDeprecatedCheck:96:92 --regex .*.checks.indentation.NewHandler:77:83 --regex .*.checks.javadoc.JavadocUtils:91:83 --regex .*.checks.naming.MethodNameCheck:93:100 --regex .*.checks.indentation.ElseHandler:100:75 --regex .*.checks.naming.AbstractNameCheck:87:100 --regex .*.checks.naming.ParameterNameCheck:80:75 --regex .*.checks.coding.HiddenFieldCheck:97:96 --regex .*.checks.imports.RedundantImportCheck:94:81 --regex .*.api.LocalizedMessage\$.*:66:41 --regex .*.filters.SuppressionCommentFilter:87:83 --regex .*.checks.indentation.IndexHandler:75:100 --regex .*.checks.javadoc.AtclauseOrderCheck:88:88 --regex .*.checks.imports.PkgControl:100:80 --regex .*.PropertyCacheFile:19:22 --regex .*.checks.indentation.MethodCallHandler:87:63 --regex .*.checks.coding.StringLiteralEqualityCheck:87:100 --regex .*.checks.metrics.JavaNCSSCheck:96:81 --regex .*.checks.javadoc.SummaryJavadocCheck:100:93 --regex .*.checks.coding.AbstractIllegalCheck:100:64 --regex .*.checks.whitespace.GenericWhitespaceCheck:96:86 --regex .*.checks.coding.HiddenFieldCheck\$.*:100:94 --regex .*.api.TokenTypes:80:62 --regex .*.PackageObjectFactory:75:75 --regex .*.checks.naming.PackageNameCheck:88:100 --regex .*.checkstyle.AnnotationUtility:60:60 --regex .*.checks.whitespace.OperatorWrapCheck:81:68 --regex .*.api.AuditEvent:93:100 --regex .*.checks.indentation.LineSet:90:100 --regex .*.checks.AbstractTypeAwareCheck\$.*:80:50 --regex .*.api.Check:86:100 --regex .*.checks.naming.StaticVariableNameCheck:87:81 --regex .*.checks.indentation.ExpressionHandler:97:91 --regex .*.checks.regexp.MultilineDetector:87:58 --regex .*.checks.regexp.DetectorOptions:96:100 --regex .*.checks.coding.FallThroughCheck:95:90 --regex .*.checks.OuterTypeFilenameCheck:92:71 --regex .*.checks.AbstractTypeAwareCheck:84:87 --regex .*.api.AbstractFileSetCheck:87:75 --regex .*.checks.indentation.SlistHandler:94:100 --regex .*.checks.whitespace.AbstractParenPadCheck:100:88 --regex .*.checks.sizes.MethodCountCheck:23:31 --regex .*.api.JavadocTagInfo\$.*:8:0 --regex .*.checks.TrailingCommentCheck:93:90 --regex .*.checks.coding.MissingSwitchDefaultCheck:87:100 --regex .*.checks.coding.IllegalTokenCheck:100:75 --regex .*.checks.indentation.PrimordialHandler:60:100 --regex .*.checks.coding.MissingCtorCheck:92:75 --regex .*.checks.indentation.HandlerFactory:81:77 --regex .*.checks.annotation.MissingOverrideCheck:96:100 --regex .*.checks.indentation.PackageDefHandler:85:50 --regex .*.checks.UniquePropertiesCheck\$.*:90:75 --regex .*.api.FullIdent:96:83 --regex .*.checks.annotation.PackageAnnotationCheck:77:50 --regex .*.checks.blocks.EmptyBlockCheck:100:88 --regex .*.checks.metrics.AbstractClassCouplingCheck:97:87 --regex .*.checks.coding.SimplifyBooleanReturnCheck:96:83 --regex .*.checks.metrics.ClassFanOutComplexityCheck:80:100 --regex .*.checks.coding.NestedTryDepthCheck:81:50 --regex .*.checks.coding.IllegalCatchCheck:92:100 --regex .*.checks.coding.PackageDeclarationCheck:63:50 --regex .*.checks.SuppressWarningsHolder:90:70 --regex .*.checks.indentation.IndentationCheck:93:100 --regex .*.filters.SuppressionFilter:0:0 --regex .*.api.JavadocTokenTypes:0:100 --regex .*.checks.NewlineAtEndOfFileCheck:88:83 --regex .*.checks.imports.AvoidStarImportCheck:88:90 --regex .*.checks.indentation.ObjectBlockHandler:100:75 --regex .*.filters.SuppressionsLoader:77:68 --regex .*.checks.annotation.AnnotationUseStyleCheck:96:93 --regex .*.checks.design.InterfaceIsTypeCheck:85:100 --regex .*.checks.coding.IllegalThrowsCheck:84:93 --regex .*.checks.regexp.SinglelineDetector:96:93 --regex .*.checks.indentation.SynchronizedHandler:100:100 --regex .*.checks.coding.AbstractNestedDepthCheck:86:100 --regex .*.XMLLogger:97:86 --regex .*.checks.design.VisibilityModifierCheck:95:95 --regex .*.api.AbstractLoader:88:75 --regex .*.api.Comment:95:100 --regex .*.checks.coding.OverloadMethodsDeclarationOrderCheck:96:93 --regex .*.checks.sizes.ParameterNumberCheck:93:100 --regex .*.checks.javadoc.JavadocStyleCheck:97:89 --regex .*.Main:78:65 --regex .*.checks.coding.MultipleStringLiteralsCheck:94:90 --regex .*.checks.javadoc.TagParser:98:92 --regex .*.ConfigurationLoader\$.*:84:65 --regex .*.checks.blocks.EmptyCatchBlockCheck:98:96 --regex .*.checks.coding.EqualsAvoidNullCheck:96:78 --regex .*.checks.javadoc.JavadocPackageCheck:95:80 --regex .*.checks.coding.IllegalTokenTextCheck:88:60 --regex .*.checks.naming.LocalFinalVariableNameCheck:85:87 --regex .*.checks.whitespace.WhitespaceAfterCheck:90:90 --regex .*.DefaultConfiguration:92:100 --regex .*.checks.imports.UnusedImportsCheck:97:90 --regex .*.filters.SuppressionCommentFilter\$.*:69:41 --regex .*.checks.imports.ImportOrderCheck:99:91 --regex .*.api.FileText:59:50 --regex .*.checks.blocks.NeedBracesCheck:97:80 --regex .*.checks.annotation.SuppressWarningsCheck:96:79 --regex .*.checks.imports.ImportControlCheck:70:85 --regex .*.checks.regexp.RegexpSinglelineCheck:76:100 --regex .*.checks.modifier.ModifierOrderCheck:91:92 --regex .*.checks.metrics.AbstractComplexityCheck:92:83 --regex .*.filters.SuppressElement:88:82 --regex .*.filters.SuppressWithNearbyCommentFilter:89:76 --regex .*.checks.indentation.LineWrappingHandler:91:87 --regex .*.checks.javadoc.AbstractJavadocCheck\$.*:68:50 --regex .*.checks.coding.AbstractSuperCheck:88:78 --regex .*.api.AutomaticBean\$.*:90:75 --regex .*.checks.blocks.AvoidNestedBlocksCheck:90:100 --regex .*.checks.coding.NestedIfDepthCheck:83:75 --regex .*.checks.javadoc.JavadocNodeImpl:84:50 --regex .*.Checker:84:79 --regex .*.checks.coding.CovariantEqualsCheck:90:95 --regex .*.ConfigurationLoader:79:86 --regex .*.checks.metrics.CyclomaticComplexityCheck:80:85 --regex .*.checks.javadoc.JavadocParagraphCheck:100:92 --regex .*.checks.sizes.MethodLengthCheck:95:100 --regex .*.checks.sizes.OuterTypeNumberCheck:94:75 --regex .*.checks.coding.OneStatementPerLineCheck:96:93 --regex .*.filters.SuppressWithNearbyCommentFilter\$Tag:78:88 --regex .*.Definitions:0:100 --regex .*.api.AnnotationUtility:0:0 --regex .*.checks.indentation.ArrayInitHandler:97:83 --regex .*.checks.imports.IllegalImportCheck:94:100 --regex .*.checkstyle.ScopeUtils:94:90 --regex .*.checks.coding.ArrayTrailingCommaCheck:90:100 --regex .*.checks.coding.EmptyStatementCheck:80:100 --regex .*.checks.sizes.LineLengthCheck:89:100 --regex .*.checks.javadoc.JavadocTag:85:92 --regex .*.checks.whitespace.NoWhitespaceAfterCheck:98:94 --regex .*.PackageNamesLoader:72:78 --regex .*.checks.naming.AbbreviationAsWordInNameCheck:100:93 --regex .*.checks.indentation.MethodDefHandler:100:87 --regex .*.checks.coding.NestedForDepthCheck:90:50 --regex .*.checks.javadoc.JavadocVariableCheck:90:93 --regex .*.filters.IntMatchFilter:90:100 --regex .*.api.DetailAST:98:95 --regex .*.checks.annotation.AnnotationLocationCheck:78:75 --regex .*.checks.coding.ExplicitInitializationCheck:90:90 --regex .*.checks.header.HeaderCheck:45:18 --regex .*.checks.whitespace.SeparatorWrapCheck:93:100 --regex .*.checks.header.AbstractHeaderCheck:85:85 --regex .*.checks.design.InnerTypeLastCheck:93:100"
[DEBUG] exit code: 1
[DEBUG] --------------------
[DEBUG]  Standard error from the Cobertura task:
[DEBUG] --------------------
[ERROR] The command line is too long.

3 个答案:

答案 0 :(得分:2)

这是一个非常简单的解决方法,因此我将其作为答案发布。

您可以在Windows 8.1 PC上的Linux VM中运行maven构建。仅为此目的设置一个轻量级的仅命令行VM,并与它共享您的Windows目录,这样您就不必复制任何内容。使用它与打开命令行窗口并在那里运行mvn没有太大区别。 VMWare Player或VirtualBox以及大量Linux VM映像都是免费的。

然后打开cobertura的功能请求,允许将配置文件作为参数传递。查看net.sourceforge.cobertura.check.CheckCoverageMain的源代码,添加这样的功能应该很容易。

答案 1 :(得分:2)

我建议的一个解决方案是在那里安装cygwin和run命令。你可以找到如何在任何互联网上运行cygwin。 Try This Tutorial

另外,使用java直接调用CheckCoverageMain,你可以编写一个ant脚本,它将调用CheckCoverageMain并传递下面的参数,

<java classname="net.sourceforge.cobertura.check.CheckCoverageMain" fork="true">

  <jvmarg value="--regex"/>

然后从命令行调用ant脚本。 Ant script basic tutorial

答案 2 :(得分:1)

如果类路径变得太长,则会出现此问题。也有选择:

  1. 将您的存储库移动到D:更短的路径,目前它可能位于更长的路径,如C:\ Document和Settings \ XYZ.m2 ...等。
    1. 在配置中将useWildcardClassPath设置为true。
  2. 我建议先尝试第二种方法。

    让我知道它是否适合你...