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.addConfigurationFailure(LifecycleProjectEvaluator.java:79) 在org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74) 在org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61) 在org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:529) 在org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:90) 在org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42) 在org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) 在org.gradle.initialization.DefaultGradleLauncher $ 2.run(DefaultGradleLauncher.java:125) 在org.gradle.internal.Factories $ 1.create(Factories.java:22) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52) 在org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122) 在org.gradle.initialization.DefaultGradleLauncher.access $ 200(DefaultGradleLauncher.java:32) 在org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:99) 在org.gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:93) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62) 在org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93) 在org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82) at org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run(InProcessBuildActionExecuter.java:94) 在org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) 在org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) 在org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) 在org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) 在org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51) 在org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28) 在org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43) 在org.gradle.internal.Actions $ RunnableActionAdapter.execute(Actions.java:173) 在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:241) 在org.gradle.launcher.cli.CommandLineActionFactory $ ParseAndBuildAction.execute(CommandLineActionFactory.java:214) 在org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35) 在org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) at org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:207) 在org.gradle.launcher.cli.CommandLineActionFactory $ WithLogging.execute(CommandLineActionFactory.java:169) 在org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) 在org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 在org.gradle.launcher.Main.doAction(Main.java:33) 在org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 在org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55) 在org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36) 在org.gradle.launcher.GradleMain.main(GradleMain.java:23) 在org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30) 在org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) 在org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) 引起:org.gradle.api.InvalidUserDataException:无法更改 配置的依赖性' kapt'在它解决之后。 在org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:600) 在org.gradle.api.internal.artifacts.configurations.DefaultConfiguration $ 2.run(DefaultConfiguration.java:149) at org.gradle.api.internal.DefaultDomainObjectCollection.assertMutable(DefaultDomainObjectCollection.java:267) 在org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:158) 在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) 在org.gradle.api.artifacts.dsl.DependencyHandler $ add.call(未知 资源) 在org.avaje.ebean.gradle.EnhancePlugin.hookQueryBeans(EnhancePlugin.groovy:63) 在org.avaje.ebean.gradle.EnhancePlugin $ _apply_closure1.doCall(EnhancePlugin.groovy:35) at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40) at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25) 在org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44) 在org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79) 在org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30) at org.gradle.messaging.dispatch.ProxyDispatchAdapter $ DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 在com.sun.proxy。$ Proxy11.afterEvaluate(未知来源) 在org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67) ... 44更多
由于我对kotlin和IntelliJ IDEA都很陌生,我自己很难解决这个问题。
请注意,我的DBO类在ebean的IDEA插件的帮助下得到了增强,但是在生成查找程序和查询bean时,我很震惊,因为没有为ebean + gradle + kotlin提供的样本对我有效