I'm trying to create a library and publish it to maven local. When I start trying to add a MavenPublication to publications, the IDE gives it a dotted underline like it's an unresolved reference. Same with parameters like from and artifact.
If I uncomment the pom block, gradle sync fails and says Cause: invalid type code: B3, ultimately because of org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException on one of the parameters within.
This build.gradle file is in one of my modules. The top level build.gradle is pretty simple.
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
}
}
allprojects {
apply plugin: "idea"
group = 'com.mygroup'
version = '1.0.0'
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
And here's the module's build.gradle.
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'mylibrary'
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'MyLibrary'
organization {
name 'MyOrg'
url 'www.myurl.com'
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
I'm using Gradle 5.1.1, IntelliJ Idea 2019.1.2, and JDK 12.0.1.

build.gradlewithpomblock? Otherwise, I have to add my own, specifically from the official Gradle doc. And it works just fine with yourbuild.gradlescripts. With regards to the dotted underlines, it's a problem with IntelliJ support for Gradle build scripts written in Groovypomblock to make it fail above, I think I found the issue, because if I add=signs, it completes the sync without errors. Why are equal signs necessary here, but not in apluginsblock where you have lines like `id 'maven-publish'?