Wenn ich versuche, mein Projekt gradlew build
, erhalte ich eine Fehlermeldung von der compileKotlin
Aufgabe:deaktivieren Check ‚Kotlin‘ Paket in Gradle für die Verwendung von
F:\IdeaProjects\walp.tinykotlintest>gradlew build
:compileKotlin
...
Only the Kotlin standard library is allowed to use the 'kotlin' package
...
BUILD FAILED
Total time: 6.214 secs
Dies geschieht, weil ich eine Klasse in einem Paket deklariert haben das beginnt mit: kotlin
...
Gibt es eine Möglichkeit, diese Überprüfung durch Konfigurieren meines Skripts build.gradle
zu lösen?
EDIT: Ich weiß sicher, dies ist möglich, wenn ich mit den bloßen Kotlin Compiler kompiliert ... here is an example den Kotlin Compiler der Verwendung eine Klasse in dem Kotlin Paket zu kompilieren ... Also ich denke, es sollte eine sein wie es in gradle zu tun zu .... ich hoffe, ...
Was ich bisher versucht:
ich die
gradle.build
durch die Konfiguration der KotlinCompile Aufgabe zu konfigurieren versucht:import org.jetbrains.kotlin.gradle.tasks.KotlinCompile tasks.withType(KotlinCompile) { it.kotlinOptions.allowKotlinPackage = true }
Das Gradle-Skript läuft gut mit diesen Änderungen ... but it seems like this is getting ignored ... und ich stoße immer noch auf den Fehler.
Ich versuchte, die
KotlinCompile
Klasse, Unterklasse und seinebeforeCompileHook()
außer Kraft setzen und die bestehendencompileKotlin
Aufgabe mit meiner Version ersetzen:import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments import org.jetbrains.kotlin.gradle.tasks.KotlinCompile class MyKotlinCompile extends KotlinCompile { @Override public void beforeCompileHook(K2JVMCompilerArguments args) { args.allowKotlinPackage = true throw new RuntimeException("HELLO") // added to see if hook is run } } tasks.create(name: "compileKotlin", type: MyKotlinCompile, overwrite: true)
Studying the source code...I was fairly certain this would work aber es hat offenbar nicht. Ich habe versucht, mit und ohne die
RuntimeException
zu werfen, aber ich folgende Fehlermeldung immer, wenn ich zugradle build
versuchte es noch einmal:F:\IdeaProjects\walp.tinykotlintest>gradlew build --stacktrace :compileKotlin UP-TO-DATE :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar UP-TO-DATE :sourcesJar UP-TO-DATE :assemble UP-TO-DATE :compileTestKotlin FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileTestKotlin'. > java.lang.NullPointerException (no error message) * Try: Run with --info or --debug option to get more log output. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileTestKotlin'. 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.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: java.lang.NullPointerException at org.jetbrains.kotlin.gradle.tasks.KotlinCompile$populateTargetSpecificArgs$2.invoke(Tasks.kt:215) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.populateTargetSpecificArgs(Tasks.kt:222) at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.populateTargetSpecificArgs(Tasks.kt:148) at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:105) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) ... 60 more
Ich hätte wahrscheinlich sowieso nicht tun dies sein ... aber ich möchte wirklich Versuch es.
danke!
Wie lautet der vollständige Name des Pakets? – voddan
'kotlin.jvm.internal' .... haha: x – Eric