Kotlin Gradle插件-如何使用自定义输出目录? [英] Kotlin gradle plugin - how to use custom output directory?

查看:162
本文介绍了Kotlin Gradle插件-如何使用自定义输出目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎Kotlin Gradle插件会忽略指定的编译输出目录:

In seems that Kotlin Gradle plugin ignores the specified compilation output directory:

sourceSets {
    main {
        kotlin {
            srcDirs 'source/kotlin'
            outputDir = file('work/program')
        }
    }
}

编译器输出转到"build/classes/kotlin/main"目录,而不是"work/program"目录. 但是,以相同的方式指定的outputDir可以在Java Gradle项目中按预期方式工作.

The compiler output goes to 'build/classes/kotlin/main' directory instead of 'work/program'. But outputDir specified in the same way works as expected in Java Gradle projects.

是否可以通过Kotlin Gradle插件使用自定义编译器输出目录? (版本:Kotlin 1.2.31,Gradle 4.6)

Is there a way to use custom compiler output directory with Kotlin Gradle plugin? (versions: Kotlin 1.2.31, Gradle 4.6)

更新: 我提交了有关以下内容的错误报告: https://youtrack.jetbrains.com/issue/KT-23807

Update: I submitted bug report about this: https://youtrack.jetbrains.com/issue/KT-23807

推荐答案

其他用户在Kotlin问题跟踪器中发布了一种解决方法:

There is workaround, posted by other user in the Kotlin issue tracker:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    destinationDir = new File(buildDir, "work/program")
}

(将此片段添加到您的"build.gradle"文件中)

(add this fragment in your 'build.gradle' file)

这篇关于Kotlin Gradle插件-如何使用自定义输出目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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