Jacoco Gradle jacocoTestReport任务失败生成报告时出错 - 是一个目录

时间:2014-04-04 16:59:31

标签: file gradle report jacoco

我正在使用Gradle 1.6。

我运行以下命令,它适用于所有项目 gradle clean build jacocoTestReport

今天,我看到其中一个项目在" jacocoTestReport"部分。 PS附加错误日志。

主要错误行

12:35:45.920 [错误] [org.gradle.BuildExceptionReporter]引起::创建报告时出错... .... 12:35:45.924 [错误] [org.gradle.BuildExceptionReporter]引起:java.io.FileNotFoundException:/ production / jenkinsAKS / workspace / MFUSvc / src / java-test / com / thc / ids / ws / mfu / msg / formulary(是一个目录)

需要注意的几点:

  1. 这个项目在没有错误的情况下正在建设中,但今天我是 看到这个错误。
  2. 我尝试使用两个/不同版本的jacoco(如下所示) - jacocoTestReport任务在使用这两个版本的所有其他项目中都能正常工作,但是对于这个版本失败了。

    jacoco {
      // toolVersion =" 0.6.2.201302030002"
      toolVersion =" 0.7.0.201403182114"
      // reportsDir = file(" $ buildDir / customJacocoReportDir")
    }

  3. 在给定的src / java-test / ... / ...路径下,我看到一个有效的.java文件,在我的工作区中(一旦compileJava等Gradle任务完成,我看到build / classes / {main,test,integrationTest} / ...文件夹包含一个有效的.class文件(对于该错误中显示的路径,说"是目录"。

  4. 知道我错过了什么。

    完整(--stacktrace或--debug日志)显示

    12:35:45.893 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on task artifact state cache (/production/jenkinsAKS/workspace/MFUSvc/.gradle/1.6/taskArtifacts).
    12:35:45.893 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
    12:35:45.894 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':jacocoTestReport'
    12:35:45.894 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :jacocoTestReport FAILED
    12:35:45.903 [ERROR] [org.gradle.BuildExceptionReporter]
    12:35:45.903 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
    12:35:45.903 [ERROR] [org.gradle.BuildExceptionReporter]
    12:35:45.903 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
    12:35:45.904 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':jacocoTestReport'.
    12:35:45.904 [ERROR] [org.gradle.BuildExceptionReporter] > Error while creating report
    12:35:45.905 [ERROR] [org.gradle.BuildExceptionReporter]
    12:35:45.905 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
    12:35:45.906 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jacocoTestReport'.
    12:35:45.906 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    12:35:45.906 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    12:35:45.907 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    12:35:45.907 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter$1.run(CacheLockReleasingTaskExecuter.java:35)
    12:35:45.907 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.Factories$1.create(Factories.java:22)
    12:35:45.907 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
    12:35:45.908 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
    12:35:45.908 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
    12:35:45.908 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
    12:35:45.908 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter.execute(CacheLockReleasingTaskExecuter.java:33)
    12:35:45.908 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:58)
    12:35:45.909 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ContextualisingTaskExecuter.execute(ContextualisingTaskExecuter.java:34)
    12:35:45.909 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter$1.run(CacheLockAcquiringTaskExecuter.java:39)
    12:35:45.909 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.Factories$1.create(Factories.java:22)
    12:35:45.909 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
    12:35:45.910 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
    12:35:45.910 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
    12:35:45.910 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
    12:35:45.910 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter.execute(CacheLockAcquiringTaskExecuter.java:37)
    12:35:45.910 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
    12:35:45.911 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
    12:35:45.911 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    12:35:45.911 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
    12:35:45.911 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
    12:35:45.911 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:282)
    12:35:45.912 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:48)
    12:35:45.912 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:34)
    12:35:45.912 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:27)
    12:35:45.912 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:89)
    12:35:45.912 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    12:35:45.913 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    12:35:45.913 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    12:35:45.913 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    12:35:45.913 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
    12:35:45.913 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.Factories$1.create(Factories.java:22)
    12:35:45.914 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
    12:35:45.914 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
    12:35:45.914 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
    12:35:45.914 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
    12:35:45.914 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
    12:35:45.915 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    12:35:45.915 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    12:35:45.915 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    12:35:45.915 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    12:35:45.915 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    12:35:45.916 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
    12:35:45.916 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
    12:35:45.916 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    12:35:45.916 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    12:35:45.916 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
    12:35:45.917 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    12:35:45.917 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    12:35:45.917 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
    12:35:45.917 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    12:35:45.917 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
    12:35:45.918 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    12:35:45.918 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
    12:35:45.918 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
    12:35:45.918 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
    12:35:45.918 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
    12:35:45.919 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    12:35:45.919 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    12:35:45.919 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.Main.doAction(Main.java:48)
    12:35:45.919 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    12:35:45.919 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.Main.main(Main.java:39)
    12:35:45.920 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
    12:35:45.920 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
    12:35:45.920 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
    12:35:45.920 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: : Error while creating report
    12:35:45.920 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.ant.ReportTask.execute(ReportTask.java:500)
    12:35:45.920 [ERROR] [org.gradle.BuildExceptionReporter]        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    12:35:45.921 [ERROR] [org.gradle.BuildExceptionReporter]        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    12:35:45.921 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
    12:35:45.921 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:86)
    12:35:45.921 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.DefaultAntBuilder.super$3$invokeMethod(DefaultAntBuilder.groovy)
    12:35:45.921 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.DefaultAntBuilder.invokeMethod(DefaultAntBuilder.groovy:37)
    12:35:45.922 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.testing.jacoco.tasks.JacocoReport.generate(JacocoReport.groovy:77)
    12:35:45.922 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
    12:35:45.922 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
    12:35:45.922 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
    12:35:45.922 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.testing.jacoco.tasks.JacocoReport_Decorated.invokeMethod(Unknown Source)
    12:35:45.923 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
    12:35:45.923 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:217)
    12:35:45.923 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
    12:35:45.923 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:199)
    12:35:45.923 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:526)
    12:35:45.924 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:509)
    12:35:45.924 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    12:35:45.924 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    12:35:45.924 [ERROR] [org.gradle.BuildExceptionReporter]        ... 67 more
    12:35:45.924 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.FileNotFoundException: /production/jenkinsAKS/workspace/MFUSvc/src/java-test/com/thc/ids/ws/mfu/msg/formulary (Is a directory)
    12:35:45.925 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.DirectorySourceFileLocator.getSourceStream(DirectorySourceFileLocator.java:50)
    12:35:45.925 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.InputStreamSourceFileLocator.getSourceFile(InputStreamSourceFileLocator.java:49)
    12:35:45.925 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.MultiSourceFileLocator.getSourceFile(MultiSourceFileLocator.java:56)
    12:35:45.925 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.internal.html.page.PackageSourcePage.renderSourceFilePages(PackageSourcePage.java:83)
    12:35:45.925 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.internal.html.page.PackageSourcePage.render(PackageSourcePage.java:66)
    12:35:45.926 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.internal.html.page.PackagePage.render(PackagePage.java:60)
    12:35:45.926 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.internal.html.page.BundlePage.renderPackages(BundlePage.java:70)
    12:35:45.926 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.internal.html.page.BundlePage.render(BundlePage.java:57)
    12:35:45.926 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.html.HTMLFormatter$1.visitBundle(HTMLFormatter.java:212)
    12:35:45.926 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.report.MultiGroupVisitor.visitBundle(MultiReportVisitor.java:69)
    12:35:45.927 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.ant.ReportTask.createReport(ReportTask.java:555)
    12:35:45.927 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jacoco.ant.ReportTask.execute(ReportTask.java:494)
    12:35:45.927 [ERROR] [org.gradle.BuildExceptionReporter]        ... 86 more
    12:35:45.927 [ERROR] [org.gradle.BuildExceptionReporter]
    12:35:45.927 [LIFECYCLE] [org.gradle.BuildResultLogger]
    12:35:45.927 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
    12:35:45.927 [LIFECYCLE] [org.gradle.BuildResultLogger]
    12:35:45.928 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 15.283 secs
    

    现在它正在为src / java(而不是src / java-test)下的某个路径而来。

    Caused by: : Error while creating report
     at org.jacoco.ant.ReportTask.execute(ReportTask.java:500)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
     at org.gradle.api.internal.project.ant.BasicAntBuilder.doInvokeMethod(BasicAntBuilder.java:86)
     at org.gradle.api.internal.project.DefaultAntBuilder.super$3$invokeMethod(DefaultAntBuilder.groovy)
     at org.gradle.api.internal.project.DefaultAntBuilder.invokeMethod(DefaultAntBuilder.groovy:37)
     at org.gradle.testing.jacoco.tasks.JacocoReport.generate(JacocoReport.groovy:77)
     at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
     at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
     at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
     at org.gradle.testing.jacoco.tasks.JacocoReport_Decorated.invokeMethod(Unknown Source)
     at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:217)
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
     at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:199)
     at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:526)
     at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:509)
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
     ... 67 more
    Caused by: java.io.FileNotFoundException: /production/jenkinsAKS/workspace/MFUSvc/src/java/com/thc/ids/biz/mfusvc/dto (Is a directory)
     at org.jacoco.report.DirectorySourceFileLocator.getSourceStream(DirectorySourceFileLocator.java:50)
     at org.jacoco.report.InputStreamSourceFileLocator.getSourceFile(InputStreamSourceFileLocator.java:49)
     at org.jacoco.report.MultiSourceFileLocator.getSourceFile(MultiSourceFileLocator.java:56)
     at org.jacoco.report.internal.html.page.PackageSourcePage.renderSourceFilePages(PackageSourcePage.java:83)
     at org.jacoco.report.internal.html.page.PackageSourcePage.render(PackageSourcePage.java:66)
     at org.jacoco.report.internal.html.page.PackagePage.render(PackagePage.java:60)
     at org.jacoco.report.internal.html.page.BundlePage.renderPackages(BundlePage.java:70)
     at org.jacoco.report.internal.html.page.BundlePage.render(BundlePage.java:57)
     at org.jacoco.report.html.HTMLFormatter$1.visitBundle(HTMLFormatter.java:212)
     at org.jacoco.report.MultiGroupVisitor.visitBundle(MultiReportVisitor.java:69)
     at org.jacoco.ant.ReportTask.createReport(ReportTask.java:555)
     at org.jacoco.ant.ReportTask.execute(ReportTask.java:494)
     ... 86 more
    

    这是我在/init.d/common.gradle文件中对jacocoTestReport任务所拥有的:

      jacocoTestReport {
          group = "Reporting"
          description = "Generate Jacoco coverage reports after running tests."
          ignoreFailures = true
          executionData = fileTree(dir: 'build/jacoco', include: '**/*.exec')
    
          reports {
                 xml{
                     enabled true
                     //Following value is a file
                     destination "${buildDir}/reports/jacoco/xml/jacoco.xml"
                 }
                 csv.enabled false
                 html{
                     enabled true
                     //Following value is a folder
                     destination "${buildDir}/reports/jacoco/html"
                 }
          }
    
          sourceDirectories = files('src/java')
          classDirectories =  files('build/classes/main')
    }
    

2 个答案:

答案 0 :(得分:2)

更新:我知道为什么! - main / java,test / java等的sourceSet {...}部分。每个main,test等部分的srcDir设置都有'not_valid_value' - >在我的全局init.d级别“common.gradle”文件中,它应用于所有项目{...}。我在全局common.gradle文件中提到了全局sourceSet部分,因此我不必在每个项目的build.gradle文件中包含test,integrationTest等任务的常见任务/配置。现在,因为它们中的每一个的srcDir在全局级别被设置为'not_valid_value',我的假设是,这个无效的srcDir值将被实际有效的 srcDir值覆盖(当Gradle构建系统将读取时) sourceSets部分{...}来自每个单独项目的build.gradle文件的sourceSet部分,用于main,test等。或者它们将作为列表条目聚集在一起,即主srcDir将成为['src / java','not_valid_value'] - - 当我在common.gradle中打印并运行项目gradle构建时,打印有效的俱乐部值:

  println ""
  println "sourceSets.main.allJava.srcDirs is set to : " + sourceSets.main.allJava.srcDirs
  println ""
打印了

值,不知道Gradle打印好的时候是否需要'引号:

sourceSets.main.allJava.srcDirs is set to : [/production/jenkinsAKS/workspace/MFUSvc/src/main/java, /production/jenkinsAKS/workspace/MFUSvc/not_valid_value]

因此,当我在jacocoTestReport任务中使用sourceSets.main.allJava.srcDirs for sourceDirectories变量时,它的传递并没有给我一个错误(正如我在帖子中提到的那样),即使是srcDir变量为main / java是:BUILD时的['src / java','not_valid_value'],即来自common.gradle的一个,来自项目的build.gradle sourceSet部分的一个。我现在没有得到错误,但它现在打破了生成的报告中的HTML链接,也就是index.html ...请参阅下面的快照图像。

当我使用main / java的实际值时,在“common.gradle”全局文件中使用test / java(即srcDir'src / java'或srcDir'test / java'或srcDir'src / java-test') ,在sourceSet部分内部 - 或者如果我硬编码jacocoTestReport任务的sourceDirectories变量----它给了我同样的错误,我在帖子中提到的其他项目,它成功了,我看到了HTML链接在jacoco HTML report index.html中有效。无论在哪种情况下它都成功,我发现我在test / java或src / java-test树下有了有效的源代码java文件。失败并给我一个错误的项目没有任何测试/ java,src / java-test树,因此,在构建期间,不会生成build / jacoco文件夹,因为没有测试对于失败的项目。 所以,它仍然存在,为什么“src / java”或“src / java-test”失败了这个特定项目的jacocoTestReport任务。

如果我使用以下内容来定义实际值 src / java

sourceDirectories = files(sourceSets.main.allJava.srcDirs)

对于JacocoTestReport任务,它适用于正确显示覆盖率%信息,上面帖子中显示的错误消息现在显示为 NOT (可能是srcDir无效值 - 但我打印了sourceSets.main.allJava.srcDirs的值,它在构建时显示['src / java','not_valid_value'],但它打破了源文件的HTML链接,即当你浏览jacoco HTML report Element列时,你可以看到覆盖百分比,但是在深层,当您单击功能/类级别时,您无法看到文件的源代码(您可以按行看到绿色/黄色/红色覆盖)。

如果我在sourceSets {.. main {java {srcDir'src / java'}}}中使用“src / java”,或者在jacocoTestReport任务中使用sourceDirectories = files('src,java')---&gt ;然后我收到以下错误:

Caused by: java.io.FileNotFoundException: /production/jenkinsAKS/workspace/MFUSvc/src/java/com/thc/ids/biz/mfusvc/dto (Is a directory)

我在其中看到其他类似的错误消息,其中包含路径“src / java-test”,因为源控件确实包含src / java-test包含测试。

  //The following works for showing coverage %, but can't see file content at func/class level in HTML report
  sourceDirectories = files(sourceSets.main.allJava.srcDirs)

  // Enabling/uncommenting The following line for sourceDirectories - shows both coverage % and at the deep level if you click func/class Element link in jacoco HTML report, you'll see file content with colored coverage per line BUT, it gives error in few projects not in all (as for some, jacocoTestReport is successful)
  //sourceDirectories = files('src/java')


  //classDirectories =  files('build/classes/main')


  //------------------------------------------
  // If I play with uncommenting the following, I see that jacocoTestReport task generating (is a directory) error message either for src/java-test or test/java -- in some projects.. NOTE: not in all projects.
  //additionalSourceDirs = files('test/java')
  //additionalSourceDirs += files('src/java-test')

  //additionalClassDirs = files('build/classes/test')
  //additionalClassDirs += files('build/classes/integrationTest')
  //additionalClassDirs += files('build/classes/acceptanceTest')
  //------------------------------------------


ATLEAST,有一点我很清楚,我现在正在寻找一些时间。当我给出硬编码值时,函数或类级别的“元素”列链接正在工作。不知何故,它不是选择(sourceSets.main.allJava.srcDirs)或(sourceSets.main.java.srcDirs),这是我在一些博客中看到的。

enter image description here

答案 1 :(得分:0)

最终答案: 1)有人最近对这个项目进行了渐变并进行了一些JIBX处理,并且很少有JIBX CLASS文件最终用于构建/ classes / main或其他/ ....文件夹树(在我的帖子中显示在错误消息中) 。结论:jacocoTestReport设置对于" html"是正确的。部分,它失败了,因为我们在build / classes /.../树中构建时插入了一些新的.class文件,而jacoco无法找到源代码,因此它因为无法创建报告而哭泣。

我所做的一切......

build.doLast {
      delete fileTree (dir: "${buildDir}/classes", include: "**/JiBX_bindings*.class")
}

现在一切都很开心。

2)现在,我在前面的评论中说过sourceSets.main.allJava.srcDirs正在工作......是的,就在那时,我正在设置srcDir' src / java'在common.gradle文件中。后来,我决定把' not_valid_value'在common.gradle文件和GLOBAL级别文件中,您不知道项目源代码java是在src / java还是src / somefunkyfolder / java中。如果在项目的build.gradle文件/级别定义了相同的sourceSet定义,那么它会覆盖或实际上我应该说俱乐部srcDir' src / java'的实际有效值。来自项目build.gradle和' not_valid_value'从common.gradle在一起。如果文件夹/文件不存在,Gradle就会忽略一些东西,所以我很好。为什么我们在common.gradle中定义了sourceSets..section - 因为我们在common.gradle中定义了test {..}和integrationTest {..}以及jacocoTestReport任务...而不是在每个项目中放置那些80-100行& #39; s build.gradle。

3)现在,删除那些时髦的JiBx _ * ...类文件之后,它们被包含在项目的结果.jar构建工件中但是在jacocoTestReport任务之前 - 事情又回到了NORMAL +我学会了如何获取jacoco HTML报告元素链接正常工作。