Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve the "Cannot assign 'String' to 'Publication'" Gradle errors in IntelliJ?

I'm using Gradle 6.7 for a project and I'm using IntelliJ. When writing Gradle files or when running inspections, I keep getting this error.

"Cannot assign 'String' to 'Publication'".

Based on the Gradle docs and all the examples, it seems as though my configuration is correct but I'm unable to resolve these warnings.

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"
                }
            }
        }
    }
}

Here's a screenshot that better illustrates the issue:

enter image description here

like image 482
Mridang Agarwalla Avatar asked Oct 22 '25 09:10

Mridang Agarwalla


1 Answers

It is false positive inspection warning. You can vote for this issue in tracker: IDEA-162281.

like image 133
Andrey Avatar answered Oct 24 '25 05:10

Andrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!