Gradle1.10とjdk1.8を使用した1.1.7Spring-Bootアプリがあります。テストにはGroovy/Spockを使用しています。これには2つの依存関係があります。jarはApacheMaven3.1.1とjdk1.8でビルドされます。私はjarをビルドし、それらを/ libディレクトリにコピーします。次に、「gradlecleanbuild」でビルドしてみます。
これが私のgradleファイルの一部です:
apply plugin: 'Java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'jacoco'
apply plugin: 'maven'
project.ext {
springBootVersion = '1.1.7.RELEASE'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
buildscript {
repositories {
flatDir {
dirs "$rootProject.projectDir/libs"
}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
testCompile('org.spockframework:spock-core:1.0-groovy-2.0') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile('org.spockframework:spock-spring:1.0-groovy-2.0') {
exclude group: 'org.spockframework', module: 'spock-core'
exclude group: 'org.spockframework', module: 'spring-beans'
exclude group: 'org.spockframework', module: 'spring-test'
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
testCompile('org.codehaus.groovy.modules.http-builder:http-builder:0.7+')
testCompile("junit:junit")
}
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
コマンドラインまたはIntelliJからの組み込みに関係なく、次のエラーが発生します。
Executing org.gradle.api.internal.tasks.compile.ApiGroovyCompiler@5474aad4 in compiler daemon.
Exception executing org.gradle.api.internal.tasks.compile.ApiGroovyCompiler@5474aad4 in compiler daemon: BUG! exception in phase 'semantic analysis' in source unit '/Users/David/projects/.../controller/AboutControllerTest.groovy' Sun.reflect.annotation.TypeNotPresentExceptionProxy.
:compileTestGroovy FAILED
スタックトレースは次のとおりです。
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileTestGroovy'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.Java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.Java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.Java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.Java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.Java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.Java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.Java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.Java:62)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.Java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.Java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.Java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.Java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.Java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.Java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.Java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.Java:158)
at org.gradle.internal.Factories$1.create(Factories.Java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.Java:155)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.Java:36)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.Java:103)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.Java:97)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.Java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.Java:97)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.Java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.Java:102)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.Java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.Java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:47)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:32)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.Java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.Java:47)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.Java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.Java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.Java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.Java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.Java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.Java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.Java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.Java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.Java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.Java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.Java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.Java:22)
at org.gradle.launcher.Main.doAction(Main.Java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.Java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.Java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.Java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.Java:23)
Caused by: BUG! exception in phase 'semantic analysis' in source unit '/Users/David/projects/.../src/test/groovy/.../controller/AboutControllerTest.groovy' Sun.reflect.annotation.TypeNotPresentExceptionProxy
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.Java:152)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.Java:51)
at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.Java:53)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.Java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.Java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.Java:360)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.Java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.Java:40)
Caused by: Java.lang.ArrayStoreException: Sun.reflect.annotation.TypeNotPresentExceptionProxy
... 8 more
それは何ヶ月も変わっていないので、それや他のテストに問題はありません。実際、2つのjarファイルをプロジェクトに追加したときに問題が発生したようです。しかし、私はこの特定のエラーメッセージに対する答えをどこにも見つけることができませんでした。
私はこれを持っていましたBUG! exception in phase 'semantic analysis' in source unit '...'
今日の問題とgradleのアップグレード(コメントで述べたように)は機能しませんでした。
私のために働いたのは、gradleキャッシュを掃除することでした:
rm -rf $HOME/.gradle/caches/
およびプロジェクトgradleディレクトリ
rm -rf $PROJECT/.gradle/caches/ && rm -rf $PROJECT/build/
Java 11 JVMを使用した場合にのみ、同じエラーが表示されます。
$ gradle -v
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11 (Oracle Corporation 11+28)
OS: Mac OS X 10.14.3 x86_64
Java 1.8(Java_HOMEを変更しました)に戻ると、エラーはなくなります。
$ gradle -v
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Mac OS X 10.14.3 x86_64
これは、GroovySpockテストを使用してプロジェクトをJDK8からJDK11にアップグレードしたときに発生しました。
修正は、gradleの依存関係のために、spockバージョンを1.3-groovy-2.5
にアップグレードし、groovyバージョンを2.5.3
にアップグレードすることでした。
さらに、私の場合、jaxwsとjaxbの実装を依存関係に追加する必要がありました。これらはJDK11から削除されたためです。
implementation 'com.Sun.xml.ws:jaxws-ri:2.3.2'
implementation 'com.Sun.xml.bind:jaxb-impl:2.4.0-b180830.0438'
私の場合、その理由はIntellijIdea変数の生成でした。
例:生成されたアイデアList<@NotNull UUID> locationIds
の代わりに List<UUID> locationIds
Groovyコンパイルはこれを処理できませんでした@NotNull
一般的な括弧内の注釈