Kotlin kapt,gradle和ebean插件构建失败

build.gradle文件看起来像:

group 'styleru-ikomarov' version '0.0.1-SNAPSHOT' buildscript { ext.kotlin_version = '1.1.3' ext.html_version = "0.6.2" ext.ktor_version = "0.3.3" ext.squash_version = "0.2.2" ext.gson_version = "2.8.1" ext.ehcache_version = "3.0.0.m4" ext.jodatime_version = "2.3" ext.slf4j_version = "1.7.5" ext.ebean_version = "10.3.1" ext.ebean_plugin_version = "10.2.2" ext.ebean_querybean_generator = "10.1.2" ext.mysql_version = "5.1.6" repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.ebean:ebean-gradle-plugin:$ebean_plugin_version" classpath "mysql:mysql-connector-java:$mysql_version" } } apply plugin: 'application' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin' apply plugin: 'ebean' repositories { mavenLocal() mavenCentral() maven { url "http://dl.bintray.com/kotlin/kotlinx.html" } maven { url "https://dl.bintray.com/kotlin/kotlinx" } maven { url "http://dl.bintray.com/kotlin/ktor" } maven { url "https://dl.bintray.com/kotlin/squash" } maven { url "https://mvnrepository.com/artifact/joda-time/joda-time" } maven { url "https://mvnrepository.com/artifact/org.jetbrains.ktor/ktor-jetty" } } sourceSets { main.kotlin.srcDirs += [file("$buildDir/generated/source/kapt/main")] } dependencies { kapt "io.ebean:kotlin-querybean-generator:$ebean_querybean_generator" compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.ktor:ktor-core:$ktor_version" compile "org.jetbrains.ktor:ktor-jetty:$ktor_version" compile "org.jetbrains.ktor:ktor-locations:$ktor_version" compile "org.jetbrains.ktor:ktor-html-builder:$ktor_version" compile "org.ehcache:ehcache:$ehcache_version" compile "io.ebean:ebean:$ebean_version" compile "io.ebean:ebean-querybean:$ebean_version" //TODO("should i remove this dependency?") compile"mysql:mysql-connector-java:$mysql_version" compile "com.google.code.gson:gson:$gson_version" compile "joda-time:joda-time:$jodatime_version" compile "org.slf4j:slf4j-log4j12:$slf4j_version" compile "org.slf4j:slf4j-api:$slf4j_version" } kapt { generateStubs = true } ebean { debugLevel = 9 //packages = ['dbo.categories'] queryBeans = true kotlin = true } compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } kotlin { experimental { coroutines "enable" } } test { useTestNG() testLogging.showStandardStreams = true testLogging.exceptionFormat = 'full' } 

干净的堆栈跟踪./gradlew clean –stacktrace:

  • 异常是:org.gradle.api.ProjectConfigurationException:配置根项目“糖尿病”发生了一个问题。 在org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79) (LifecycleProjectEvaluator.java:61)at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:529)at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:90)at在org.gradle.initialization.DefaultGradleLauncher $ 2.run(DefaultGradleLauncher.java:125)org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)处的org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42) )在org.gradle.internal.Factories $ 1.create(Factories.java:22)在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)在org.gradle.internal.progress.Def 在org.gradle上的org.gradle.initialization.DefaultGradleLauncher.access $ 200(DefaultGradleLauncher.java:32)上的org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)上的aultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)。在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)上的org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:93)处初始化.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:99) org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java :82)at org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run(InProcessBuildActionExecuter.java:94)at org.gradle.tooling.internal.provider.ExecuteBui org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)上的org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)org.gradle.launcher.run(ExecuteBuildActionRunner.java:28) .org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter .java:46)at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)at org.gradle.launcher。 org.gradle.internal.Actions上的cli.RunBuildAction.run(RunBuildAction.java:43)$ org.gradle.launcher.cli.CommandL上的$ RunnableActionAdapter.execute(Actions.java:173) 在org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:org.gradle.launcher.cli.CommandLineActionFactory)处使用$ ParseAndBuildAction.execute(CommandLineActionFactory.java:214) 35)at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)at org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:207)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 )在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:55 )在org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter。)上的org.gradle.launcher.GradleMain.main(GradleMain.java:23)处的org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36) java:30)at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)引起的:org.gradle.api.InvalidUserDataException:Can not在解决之后,改变配置':kapt'的依赖关系。 在org.gradle.api.internal.artifacts.configurations.DefaultConfiguration $ 2.run(DefaultConfiguration.java:149)org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:600)。 (org.gradle.api.internal.DelegatingDomainObjectSet.add(DelegatingDomainObjectSet。 java:81)at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.doAdd(DefaultDependencyHandler.java:84)at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.add(DefaultDependencyHandler。 java:61)at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.add(DefaultDependencyHandler.java:57)at org.gradle.api.artifacts.dsl.DependencyHandler $ add.call(Unknown Source)at org.avaje.ebean.gradle.EnhancePlug 在org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)org.avaje.ebean.gradle.EnhancePlugin中的in.hookQueryBeans(EnhancePlugin.groovy:63)org.gradle.listener.Closure(EnhancePlugin.groovy:35)在org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java)上的org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44).gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25) :79)at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)at org.gradle.messaging.dispatch.ProxyDispatchAdapter $ DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)at com.sun.proxy。 $ org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)… Proxy11.afterEvaluate(Unknown Source)… 44更多

因为我对kotlin和IntelliJ IDEA都很陌生,所以我自己很难解决这个问题。

请注意,我的DBO类在ebean的IDEA插件的帮助下得到了增强,但是由于涉及到生成查找器和查询bean,因此没有任何提供给ebean + gradle + kotlin的示例适用于我。