BUG: gradle-plugin-publish fails with dependency constraints

If I have a parent build file that defined dependency constraints and a plugin project that defines its dependencies without version.

However if you use the maven-publish plugin also things seem to work OK except for this other weird bug:

parent build.gradle:

dependencies {
  constraints {
    implementation 'com.google.guava:guava:27.0.1-jre'
    ...
  }
}

subproject build.gradle (this is the gradle plugin project)

dependencies {
  implementation 'com.google.guava:guava'
  ..
}

the task publishPlugins fails because the plugin-publish plugin doesn’t seem to resolve the versions when trying to write the pom.

full stacktrace:

Caused by: com.gradle.publish.MissingDependencyVersionException: No version found for com.google.guava:guava on pom generation.
        at com.gradle.publish.PomWriter.addDependency(PomWriter.java:58)
        at com.gradle.publish.PomWriter.createPomDocument(PomWriter.java:44)
        at com.gradle.publish.PomWriter.writePom(PomWriter.java:30)
        at com.gradle.publish.PublishTask.generatePom(PublishTask.java:168)
        at com.gradle.publish.PublishTask.ensurePomIsAvailable(PublishTask.java:154)
        at com.gradle.publish.PublishTask.publish(PublishTask.java:70)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)

What’s curious is that if using the maven-publish plugin WITH the plugin-publish the resolution happens fine, but then you run into this weird bug: Debug an issue in publish-plugin? gradle.plugin not being prepended to groupid

Debugging the code, it appears the code path specifically for PomWriter (however its getting there is broken). Using maven-publish in conjunction with plugins-publish avoids this code path completely (presumably because it’s delegating pom generation to the maven-publish code?).