Gradle 6 upgrade causes NoSuchMethodError on getPublishableFiles

41 Views Asked by At

Background

  • Gradle project that uses maven-publish and the jfrog artifactory plugins.
  • Upgrading from Gradle 5.6.4 to Gradle 6.9.4 (reproducible when upgrading to 6.0).

Problem

Running the build e.g.

./gradlew clean build

fails before any tasks are run, because of:

[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]

Caused by: java.lang.NoSuchMethodError: org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal.getPublishableFiles()Lorg/gradle/api/file/FileCollection;

Code (excerpted)

apply plugin: "maven-publish"
apply plugin: "com.jfrog.artifactory"

buildscript {
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1"
  }
}

publishing {
  publications {
    mavenJava(MavenPublication) {
      from components.java
    }
  }
}

artifactory {
    publish {
      defaults {
        publications('mavenJava') # This is the line that throws the exception
      }
    }
  }
}

Notes

Someone else ran into the same issue and the solution was "Looks I have to update the plugin in root project build.gradle" which didn't quite get me there since it wasn't clear which plugin they were talking about.

1

There are 1 best solutions below

0
Kenny Linsky On

I upgraded build-info-extractor-gradle to the latest 4.x release and that fixed the issue.

buildscript {
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.33.13"
  }
}