groovy无法解决kotlin类 [英] groovy is unable to resolve kotlin classes

查看:552
本文介绍了groovy无法解决kotlin类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我无法解决我与 kotlin 有关的问题,因此我决定返回到 groovy in为了实现插件。



然而我遇到了这个问题。我有这样的项目结构。





控制台输出如下所示(我使用另一个类,我输入 PluginUtils c $ c $> $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b:compileKotlin(...多次弃用的消息...)
:compileJava UP-TO-DATE
:compileGroovy
启动失败:
D:\groovy_apps\MISC \gradle-app-environment-plugin\src\main\groovy\com.lapots.gradle.plugins.appenv\ApplicationEnvironmentGroovyPlugin.g
roovy:4:无法解析类com.lapots。 gradle.plugins.appenv.core.PluginUtils
@第4行第1列。
import com.lapots.gradle.plugins.appenv.core.PluginUtils
^


解决方案

看起来并不那么简单。 https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/2 < a>



使用这里的建议,我添加了

  compileGroovy { 
dependsOn tasks.getByPath('compileKotlin')
classpath + = files(compileKotlin.destinationDir)
}

而且它工作。


As I was not able to resolve the issue I have with kotlin, I decided to return to groovy in order to implement the plugin.

However I ran into the issue. I have such project structure.

In order not to rewrite all classes I decided to reuse classes implemented in kotlin.

However my classes FileProcessingCoreGroovy & DownloadCoreGroovy are unable to resolve class ProcessStream and UnpackStream.

I thought they should be able freely use each other but I guess I was wrong. What is the problem?

The classes itself are imported just fine by IDE (not marked in red color and so on)

The console output looks like this (I use another class where I import PluginUtils from kotlin classes)

:clean                                                                           
:compileKotlin (...multiple deprecated messages...)
:compileJava UP-TO-DATE       
:compileGroovy                 
startup failed:                
D:\groovy_apps\MISC\gradle-app-environment-plugin\src\main\groovy\com.lapots.gradle.plugins.appenv\ApplicationEnvironmentGroovyPlugin.g
roovy: 4: unable to resolve class com.lapots.gradle.plugins.appenv.core.PluginUtils
 @ line 4, column 1.
   import com.lapots.gradle.plugins.appenv.core.PluginUtils
   ^                           

解决方案

Looks like it is not so simple.

See https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/2

Using suggestions from there, I added

compileGroovy {
    dependsOn tasks.getByPath('compileKotlin')
    classpath += files(compileKotlin.destinationDir)
}

And it worked.

这篇关于groovy无法解决kotlin类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆