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.configuration.DefaultBuildConfigurer 中的 org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)。在 org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36) 在 org.gradle 在 org.gradle.launcher.runNoExit(ProcessBootstrap.java:55) 运行(EntryPoint.java:45) .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$2 的 org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:600)。
由于我对 kotlin 和 IntelliJ IDEA 都很陌生,所以我很难自己解决这个问题。
请注意,我的 DBO 类在 ebean 的 IDEA 插件的帮助下得到了增强,但是在生成查找器和查询 bean 时,我很震惊,因为为 ebean+gradle+kotlin 提供的示例都不适合我。