简体   繁体   English

如何使Gradle中的Idea插件为Kotlin生成正确的项目配置?

[英]How to make idea plugin in gradle generate proper project configuration for Kotlin?

I have configured my build.gradle to run gradle test and gradle run properly. 我已经将build.gradle配置为运行gradle test并且gradle run正常。 However, IDEA does not show any run/test tasks after importing the configuration generated by gradle idea . 但是,在导入gradle idea生成的配置之后,IDEA不会显示任何run/test任务。 It seems that these tasks are not included at ipr / iws at all. 看来, ipr / iws根本不包含这些任务。

Here is my build.gradle : 这是我的build.gradle

buildscript {
    ext.kotlin_version = '1.2.0'

    repositories {
        maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
    }
}

apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'application'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'idea'

dokka {
    outputFormat = 'html'
    outputDirectory = "$buildDir/javadoc"
}

sourceSets {
    test.kotlin.srcDirs += 'src/test/kotlin'
}

junitPlatform {
    enableStandardTestTask true
}

defaultTasks 'run'
mainClassName = 'simpledb.server.Startup'

repositories {
    maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
}

dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.2'
        testRuntime (
            'org.junit.jupiter:junit-jupiter-engine:5.0.2',
            'org.junit.platform:junit-platform-launcher:1.0.2'
        )
        testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}

I was wondering is there any way to make generated project configurations include these tasks( run / test )? 我想知道有什么方法可以使生成的项目配置包括这些任务( run / test )吗? I have also heard people saying Don't use gradle idea , so is it impossible to use gradle idea to implement this? 我也听到人们说不要使用gradle想法 ,所以不可能使用gradle idea来实现这一点吗?

It is simply not necessary in your case. 在您的情况下,根本没有必要。 Just open the build.gradle file with IDEA and everything should be smooth. 只需使用IDEA打开build.gradle文件,一切就应该顺利了。 The idea Gradle plugin is somewhat deprecated. Gradle插件的idea有些过时了。 Not officially, but it was created by Gradle team and is not actively developed to adapt to new IDEA versions and features and so on. 它不是正式的,而是由Gradle团队创建的,并未积极开发以适应新的IDEA版本和功能等。 So if you don't need special customizations, just open the build.gradle with IDEA and you should be good to go. 因此,如果您不需要特殊的自定义设置,只需使用IDEA打开build.gradle ,就可以了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在用 Kotlin 编写的 Intellij IDEA Gradle 插件项目中包含 Kotlin PSI 类(例如 KtClass)? - How to include Kotlin PSI classes (e.g. KtClass) in Intellij IDEA Gradle plugin project written in Kotlin? 如何在IntelliJ IDEA插件项目中使用Gradle? - How to use gradle in intellij idea plugin project? 如何为 IntelliJ IDEA Gradle 插件设置 Kotlin PSI? - How to set up Kotlin PSI for IntelliJ IDEA Gradle Plugin? 如何使用gradle的Idea插件将项目名称从Gradle构建脚本传播到Idea项目名称 - How to propagate project name from gradle build script into Idea project name using gradle's Idea plugin gradle,idea插件和多项目设置 - gradle, idea plugin and multi-project setup 使Intellij Idea插件与Kotlin文件一起使用 - Make Intellij Idea plugin work with Kotlin files 如何在 IntelliJ IDEA/Gradle 项目中使用 Java `package-info.java` 记录 Kotlin 包? - How do I document a Kotlin package like with the Java `package-info.java` in an IntelliJ IDEA/Gradle project? 尝试更新到 Kotlin 1.4.0 时出现奇怪的错误。 如何使其与 Gradle 和 IntelliJ IDEA 2020.2.1 一起使用? - Getting weird bugs when trying to update to Kotlin 1.4.0. How to make it work with Gradle and IntelliJ IDEA 2020.2.1? 如何在IDEA中从Gradle设置checkstyle配置 - How to set checkstyle configuration from Gradle in IDEA 如何在部署之前在IntelliJ IDEA 13中设置Tomcat服务器配置以构建Gradle项目? - How to setup Tomcat Server configuration in IntelliJ IDEA 13 to build Gradle project before deployment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM