IDEA报告build.gradle.kts中ShadowJar任务的错误,而./gradlew运行正常

时间:2019-03-28 14:03:55

标签: gradle intellij-idea kotlin

我正在使用Kotlin DSL进行gradle配置。

./ gradlew可以正常工作,但是IDEA仍然在build.gradle.kts中报告ShadowJar错误。

Type argument is not within its bounds.
Expected:Task!
Found:   ShadowJar

问题: ShadowJar任务是否有其他语法对gradle和IDEA都适用?

enter image description here

git repo重现该问题: https://github.com/ludenus/gradle-kts-shadow-jar

build.gradle.kts:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {

    kotlin("jvm") version "1.3.20"
    id("com.github.johnrengelman.shadow") version "4.0.4"

    application
}


group = "com.example"
version = "0.0.1"

repositories {
    jcenter()
    mavenCentral()
}

val junitVersion = "5.4.0"

dependencies {
    implementation(kotlin("stdlib", "1.3.20"))
    implementation("org.jetbrains.kotlin:kotlin-reflect:1.3.20")

    compileClasspath("com.github.jengelman.gradle.plugins:shadow:4.0.4")

    implementation("org.slf4j:slf4j-api:1.7.21")
    implementation("ch.qos.logback:logback-core:1.2.3")
    implementation("ch.qos.logback:logback-classic:1.2.3")

    testImplementation("io.kotlintest:kotlintest-runner-junit5:3.3.1")
    testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
    testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
    runtime("org.junit.jupiter:junit-jupiter-engine:$junitVersion")

}

application {
    mainClassName = "com.example.App"
}


val test by tasks.getting(Test::class) {
    useJUnitPlatform()
    testLogging.showStandardStreams = true
    testLogging.events = setOf(TestLogEvent.PASSED, TestLogEvent.FAILED, TestLogEvent.SKIPPED, TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR)
}

tasks.withType<ShadowJar> {
    manifest {
        attributes["Implementation-Title"] = "Shadow Jar"
        attributes["Implementation-Version"] = version
        attributes["Main-Class"] = "com.example.App"
    }
    classifier = "jar-with-dependencies"
}

版本

等级:

$ ./gradlew --version

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_201 (Oracle Corporation 25.201-b09)
OS:           Linux 4.15.0-46-generic amd64

想法:

IntelliJ IDEA 2019.1 (Community Edition)
Build #IC-191.6183.87, built on March 27, 2019
JRE: 1.8.0_202-release-1483-b39 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-46-generic

IDEA配置为使用gradle“包装器”任务配置。

操作系统

$ uname -a
Linux qa-pc 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

1 个答案:

答案 0 :(得分:1)

compileClasspath最有可能使想法-等级集成混乱

相关问题