【问题标题】:How do I resolve the "Cannot assign 'String' to 'Publication'" Gradle errors in IntelliJ?如何解决 IntelliJ 中的“无法将 'String' 分配给 'Publication'”Gradle 错误?
【发布时间】:2020-11-10 15:21:44
【问题描述】:

我正在为一个项目使用 Gradle 6.7,并且我正在使用 IntelliJ。在编写 Gradle 文件或运行检查时,我不断收到此错误。

“无法将 'String' 分配给 'Publication'”。

根据 Gradle 文档和所有示例,我的配置似乎是正确的,但我无法解决这些警告。

import org.gradle.api.tasks.testing.logging.TestLogEvent

buildscript {
    buildscript {
        repositories {
            google()
            mavenCentral()
            gradlePluginPortal()
            jcenter()
        }
        dependencies {
            classpath "org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11:1.0.1"
            classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.8"
            classpath "net.ltgt.gradle:gradle-nullaway-plugin:0.2"
            classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.5"
        }
    }
}


apply plugin: 'java'
apply plugin: 'scalaStyle'
apply plugin: 'scala'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'net.ltgt.nullaway'
apply plugin: "com.dorongold.task-tree"
apply plugin: "jacoco"

group 'com.mridang'
version '0.0.2'

...
...

publishing {
    repositories {
        maven {
            name = "github"
            url = uri("https://maven.pkg.github.com/mridang/myrepo")
            credentials(PasswordCredentials)
        }
    }
    publications {
        maven(MavenPublication) {
            from components.java

            artifact sourcesJar
            artifact scaladocJar

            pom {
                name = 'myproject'
                description = 'Foo'
                url = 'https://github.com/mridang/myrepo'
                issueManagement {
                    system = "Github"
                    url = "https://github.com/mridang/myrepo/issues"
                }
            }
        }
    }
}

这是一个更能说明问题的屏幕截图:

【问题讨论】:

  • 要明确一点:这是您在命令行/终端上运行 gradle 时遇到的错误吗?还是只是 intellij 抱怨?
  • 这只是 Intellij 2020.1 的抱怨
  • 欢迎来到“intellij 不知道发生了什么”的世界;)

标签: gradle intellij-idea groovy ide jetbrains-ide


【解决方案1】:

这是误报检查警告。您可以在 tracker 中为这个问题投票:IDEA-162281

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    相关资源
    最近更新 更多