Tag: groovy

将Groovy gradle移植到Kotlin gradle(ext缺少或闭包转换,不确定)

我有一些Git帮手写在groovy: git.gradle: def gitHash() { def res = 'git rev-parse –short HEAD'.execute([], project.rootDir).text.trim() def diff = 'git diff'.execute([], project.rootDir).text.trim() if (diff != null && diff.length() > 0) { res += "-dirty" } return res } // method needs to be converted to closure, in order to be visible outside of script ext.gitHash = { return […]

构建包含混合Groovy,Kotlin的IntelliJ项目的jar时出错

我在包含Groovy,Kotlin和Java源代码的IntelliJ项目中引用了Kotlin文件中的Groovy类。 当我运行gradle jar时, compileKotlin步骤失败了。 Gradle错误的形式SomeKotlinFile.kt: Unresolved reference: SomeGroovyClass 有没有办法解决这个问题? Groovy类是否在编译Kotlin的时候没有被编译? 非常感谢! 跟进 这个关于Kotlin / Groovy编译顺序的页面很有帮助。 我决定在Groovy代码中删除Kotlin代码的依赖关系,而不是改变我的项目构建中的默认顺序。

无法获得null对象上的属性'kotlinOutputDir' – Kotlin和Spock

我想用Spock Framework来测试Kotlin类。 当我的项目中只有Java类时,一切正常。 但是,在版本1.1.51添加kotlin到我的项目后,测试stoped工作,现在我收到这样的错误: Error:Execution failed for task ':app:compileDebugUnitTestGroovyWithGroovyc'. > Cannot get property 'kotlinOutputDir' on null object 我正在使用Android Studio 3.0 Beta 7 这里是我的项目和模块build.gradle文件: 项目build.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.51' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta7' classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.2.0' // […]

编译Groovy和Kotlin?

我正在使用Groovy和Kotlin开发一个小型项目,我的Kotlin代码依赖于我的Groovy代码,而不是相反。 但是,Kotlin首先编译我的代码,而不是Groovy,结果,我得到像Unresolved reference: SiteRepository一样的错误Unresolved reference: SiteRepository 任何建议,我可以通过更改构建序列,或Kotlin明确取决于Groovy,或任何其他建议来解决这个问题?