BreadMoirai / github-release-gradle-plugin

A Gradle Plugin to send Releases to Github
Apache License 2.0
108 stars 26 forks source link

Client field related error #55

Closed Crystal-Spider closed 2 years ago

Crystal-Spider commented 2 years ago

I get the following error:

The supplied phased action failed with an exception. No signature of method: build_4pkvxzzeeuemixxfixjnmbsjs.githubRelease() is applicable for argument types: (build_4pkvxzzeeuemixxfixjnmbsjs$_run_closure7) values: [build_4pkvxzzeeuemixxfixjnmbsjs$_run_closure7@554984f2]

My build.gradle file is as follows (it's a Minecraft mod):

plugins {
  id 'fabric-loom' version '0.12-SNAPSHOT'
  id 'maven-publish'
  id "com.github.breadmoirai.github-release" version "2.3.7"
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.modid
version = "${minecraft_version}-${mod_version}-fabric"
group = project.group

repositories {
  mavenCentral()
  maven {
    name = "Fuzs Mod Resources"
    url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
  }
}

dependencies {
  // To change the versions see the gradle.properties file
  minecraft "com.mojang:minecraft:${minecraft_version}"
  mappings "net.fabricmc:yarn:${yarn_mappings}:v2"
  modImplementation "net.fabricmc:fabric-loader:${loader_version}"

  // Fabric API. This is technically optional, but you probably want it anyway.
  modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"

  // Forge Config API Port to handle configuration.
  modImplementation "net.minecraftforge:forgeconfigapiport-fabric:${forgeconfigapiport_version}"

  implementation "com.squareup.okhttp3:okhttp:4.10.0"
}

jar {
  manifest {
    attributes([
      "Specification-Title"     : project.mod_title,
      "Specification-Version"   : project.mod_version,
      "Specification-Vendor"    : project.author,
      "Implementation-Title"    : project.mod_title,
      "Implementation-Version"  : project.mod_version,
      "Implementation-Vendor"   : project.author,
      "Implementation-Vendor-Id": project.group,
      "Implementation-URL"      : "https://github.com/${github_user}/${modid_kebab}/tree/${minecraft_version}",
      "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
    ])
  }
}

tasks.withType(JavaCompile).configureEach {
  it.options.encoding = 'UTF-8'
  it.options.release = 17
}

file("../api-keys.properties").withReader { 
  Properties props = new Properties()
  props.load(it)
  project.api_keys = props
}

githubRelease {
  token "${api_keys.github}"
  owner "nyphet"
  // repo "github-release" // by default this is set to your project name
  tagName "v${minecraft_version}-${mod_version}"
  targetCommitish "${minecraft_version}" // by default this is set to "main"
  // releaseName "v1.0.0" // Release title, by default this is the same as the tagName
  generateReleaseNotes false
  body "See [Changelog](https://github.com/${github_user}/${modid_kebab}/blob/master/CHANGELOG.md#${minecraft_version.replaceAll('\\.', '')}-${mod_version.replaceAll('\\.', '')}---${new Date().format("yyyyMMdd")})."
  draft true
  prerelease false
  releaseAssets jar.archiveFile // this points to which files you want to upload as assets with your release, by default this is empty
  // allowUploadToExisting.set false // Setting this to true will allow this plugin to upload artifacts to a release if it found an existing one. If overwrite is set to true, this option is ignored.  
  // overwrite false // by default false; if set to true, will delete an existing release with the same tag and name
  // dryRun false // by default false; you can use this to see what actions would be taken without making a release
  apiEndpoint "https://api.github.com"
  // client new OkHttpClient.Builder().writeTimeout(5, TimeUnit.Minutes).build()
}

If I try to uncomment the line with client new OkHttpClient.Builder().writeTimeout(5, TimeUnit.Minutes).build() I get the following error instead:

unable to resolve class OkHttpClient.Builder

Yes, I am sure it's not something else causing the issue because I removed the part inherent to githubRelease and I got no error.
Yes, all the properties referenced are correctly resolved.
What am I doing wrong?

Crystal-Spider commented 2 years ago

Update: I managed to solve the second error (unable to resolve class OkHttpClient.Builder).
I just needed to add an import statement to my build.gradle file import okhttp3.OkHttpClient.

Now regardless of manually creating the OkHttpClient or leaving it to its default I get the first error

No signature of method: build_4pkvxzzeeuemixxfixjnmbsjs.githubRelease() is applicable for argument types: (build_4pkvxzzeeuemixxfixjnmbsjs$_run_closure7) values: [build_4pkvxzzeeuemixxfixjnmbsjs$_run_closure7@554984f2]

Crystal-Spider commented 2 years ago

In the end the error was caused by the field generateReleaseNotes. I was using version 2.3.7 when that field is supported in version 2.4.1
I suggest to update the readme with the latest version, currently it still says 2.3.7 in the import examples and that lead me to think it was the latest.