尝试运行gradle任务时出错。无法弄清楚还需要什么或错误是什么。我正在开发的项目有几个子项目,所以我有一个main build.gradle。该错误是针对我想尝试Kotlin的子项目。
* Where: Build file '/home/oracle/bnc/KotlinHandler/build.gradle' line: 13
* What went wrong: A problem occurred evaluating root project 'KotlinHandler'.
> Failed to apply plugin [id 'kotlin']
> Could not generate a proxy class for class org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
这是我的build.gradle,用于失败的模块(子项目)。
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
由于其中的所有任务,这里Pastebin build.gradle非常大
在将jdk更改为1.8并将依赖项编译为compile "org.jetbrains.kotlin:kotlin-stdlib-jre8
之后添加了--debug output
答案 0 :(得分:7)
启动kotlin 1.1.2
kotlin
编译器不再支持1.8以下的JDK,如1.1.2 blog post所示:
Kotlin编译器现在需要运行JDK 8。您不应该注意到任何更改,因为大多数其他Java开发工具(如Gradle和Android工具链)也需要JDK 8,因此您几乎肯定已经安装了它。对于编译器生成的代码,Java 1.6兼容性仍然是默认设置,我们没有计划放弃对生成Java 1.6兼容字节码的支持。
答案 1 :(得分:3)
在我的情况下,这是因为我正在使用java 1.7运行gradle,看起来插件只针对1.8进行编译:
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'kotlin']
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:153)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.Script$apply$1.callCurrent(Unknown Source)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] at build_4u37tyfuy0k7d4zd8vsk5lx9d.run(build.gradle:17)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] ... 63 more
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.GradleException: Could not generate a proxy class for class org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:201)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractClassGenerator.generate(AbstractClassGenerator.java:64)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:115)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:77)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.java:101)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(DependencyAutoWireTaskFactory.java:39)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:62)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:97)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider.createKotlinJVMTask(TasksProvider.kt:26)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.doCreateTask(KotlinPlugin.kt:111)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.doCreateTask(KotlinPlugin.kt:93)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor.createKotlinCompileTask(KotlinPlugin.kt:83)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor.<init>(KotlinPlugin.kt:56)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.<init>(KotlinPlugin.kt:101)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.buildSourceSetProcessor$kotlin_gradle_plugin_main(KotlinPlugin.kt:302)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.buildSourceSetProcessor$kotlin_gradle_plugin_main(KotlinPlugin.kt:295)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin$configureSourceSetDefaults$1.execute(KotlinPlugin.kt:279)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin$configureSourceSetDefaults$1.execute(KotlinPlugin.kt:256)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin.configureSourceSetDefaults(KotlinPlugin.kt:278)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin.apply(KotlinPlugin.kt:269)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.apply(KotlinPlugin.kt:306)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.apply(KotlinPlugin.kt:295)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:46)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:34)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:137)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] ... 73 more
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.UnsupportedClassVersionError: org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments : Unsupported major.minor version 52.0
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:67)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:51)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:31)
16:48:42.746 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:260)
16:48:42.746 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:216)
16:48:42.746 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:95)
相关门票:https://youtrack.jetbrains.com/issue/KT-17866和https://youtrack.jetbrains.com/issue/KT-17297
答案 2 :(得分:1)
尽管您仍然仍然收到此错误:
public function rules()
{
$client = Client::find($this->client);
return [
'name' => 'required|string',
'address' => 'required|string',
'gender' => 'required|string',
'dob' => 'required|string',
'phone' => 'required|string',
'email' => 'required|unique:clients,email,' . $client->id,
'password' => 'regex:/^[0-9a-zA-Z]*$/',
'profile-photo' => 'image|mimes:jpg,png,jpeg',
'c_name' => 'nullable|regex:/^[a-zA-Z ]*$/',
'c_address' => 'nullable|regex:/^[a-zA-Z ]*$/',
'c_email' => 'nullable|email|unique:clients,company_email,'. $client->id,
'c_contact' => 'nullable|regex:/^[0-9]*$/',
];
}
环境变量。JAVA_HOME
文件中更改sourceCompatibility
。build.gradle
文件中的JDK8。您可能正在运行旧版本的gradle。
我在gradle gradle.properties
上收到此错误,但是升级到version 3.2
对我来说解决了该错误。
您可以从Gradle's Website下载最新版本。
更多信息here。
答案 3 :(得分:0)
尝试在jcenter()
存储库中添加buildscript
repo并更新kotlin版本。
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin"
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
如果您要定位JDK 7或JDK 8,则可以使用Kotlin标准库的扩展版本,其中包含在新JDK版本中添加的API的其他扩展功能。而不是kotlin-stdlib,使用以下依赖项之一:
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8"