GradleのマルチプロジェクトビルドのすべてのKotlinプロジェクトを構成する方法?

マルクスWeninger:

私はGradleのマルチプロジェクトビルドを使用するプロジェクトを持っています。サブプロジェクトのいくつかは、Java、Kotlinの他の新しいものに書かれています。

私たちは、1つのトップレベルの持っているbuild.gradleファイルを。このファイルには、以下の部分が含まれています。

allprojects {
    plugins.withType(JavaPlugin) {
        // All the stuff that all Java sub-projects have in common
        ...
    }
    // All the stuff that all sub-projects have in common
    ...
}

私たちは、今、私たちKotlinのサブプロジェクトに共通の設定を紹介したいと思いますが、私は見つけることができませんでしたwithType使用します。

build.gradle当社Kotlinプロジェクトのファイルがで始まります

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.0"
} 

しかし、どちらwithType(org.jetbrains.kotlin.jvm)withType(KotlinProject)動作します。

私はそこに使用するためにどのような種類がありますか?ありがとう!

M.Ricciuti:

あなたはそのことでKotlinプラグインを参照することができid、次のように、代わりにそのタイプの:

allprojects {

    plugins.withType(JavaPlugin) {
        // All the stuff that all Java sub-projects have in common
        // ...
    }
    plugins.withId("org.jetbrains.kotlin.jvm") {
        // All the stuff that all Kotlin sub-projects have in common
        // ...
    }    
}

Javaの場合、それのeaserをプラグインし、あなたが使用することができplugins.withType、それは「コア」のGradleプラグインだと、そしてJavaPluginクラスがのGradleのそれの一部として使用することができますデフォルトの輸入import org.gradle.api.plugins.*

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=173168&siteId=1