ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
191 stars 28 forks source link

Incompatibility with new grgit version #168

Closed jochil closed 2 years ago

jochil commented 2 years ago

Hi. We have encountered the following problem:

* What went wrong:
An exception occurred applying plugin request [id: 'org.ajoberstar.reckon', version: '0.13.0']
> Failed to apply plugin [class 'org.ajoberstar.grgit.gradle.GrgitServicePlugin']
   > Could not create plugin of type 'GrgitServicePlugin'.
      > Could not generate a decorated class for class org.ajoberstar.grgit.gradle.GrgitServicePlugin.
         > org/gradle/api/services/BuildServiceSpec

It seems like the 0.13 versions of reckon are not compatible with the new 5.0.0-rc1 version of grgit and the newly introduced grgit service-plugin (https://github.com/ajoberstar/grgit/pull/354). Our guess is that the missing version number at https://github.com/ajoberstar/reckon/blob/main/build.gradle.kts#L2 causes loading always the latest grgit version... in this case a release candidate.

Our workaround

buildscript {
  repositories {
    ...
  }
  dependencies {
    classpath ('org.ajoberstar.grgit:grgit-gradle:4.1.1') {
      force = true
    }
  }
}

Expected behavior/solution: Maybe it might a solution to use a fixed version of grgit inside of reckon... something like this:

plugins {
  id 'org.ajoberstar.grgit' version '4.1.1'
  ...
}
coderdude1 commented 2 years ago

Seeing something very similar with 0.13.0' and0.13.1and gradle6.8.3`

Caused by: java.lang.AbstractMethodError: Receiver class org.ajoberstar.grgit.operation.OpenOp does not define or inherit an implementation of the resolved method 'abstract void setProperty(java.lang.String, java.lang.Object)' of interface groovy.lang.GroovyObject.
at org.ajoberstar.grgit.internal.OpSyntax$_mapOperation_closure1.doCall(OpSyntax.groovy:17)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.sun.proxy.$Proxy50.accept(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.ajoberstar.grgit.internal.OpSyntax.mapOperation(OpSyntax.groovy:16)
at org.ajoberstar.grgit.internal.OpSyntax$mapOperation.callStatic(Unknown Source)
at org.ajoberstar.grgit.Grgit.open(Grgit.groovy)

Adding the force dependency mentioned above seems to work.

ajoberstar commented 2 years ago

Ugh 😫, 0.13.1 fixed the POM files on Maven Central, but for some reason Gradles publish plugin ignores the way maven-publish was configured and puts the ranges in the POM on the plugin portal. Will look into a fix later today.

maestr0 commented 2 years ago

I had a similar issue with org.ajoberstar:gradle-git-publish:3.0.0 and org.ajoberstar.reckon:0.13.1

this worked for me. Notice I forced grgit-core

buildscript {
    dependencies {
        classpath('org.ajoberstar.grgit:grgit-core:4.1.1') {
            force = true
        }
        classpath('org.ajoberstar:gradle-git-publish:3.0.0')
    }
}

plugins {
   ...
    id "org.ajoberstar.reckon" version "0.13.1"

}

apply plugin: 'org.ajoberstar.git-publish' 
edesdan commented 2 years ago

Same issue here:

Could not resolve all files for configuration ':core:compileClasspath'.
   > Could not resolve org.ajoberstar.grgit:grgit-gradle:[4.0.0,5.0.0).
     Required by:
         project :core > org.ajoberstar.reckon:reckon-gradle:0.13.0
      > No matching variant of org.ajoberstar.grgit:grgit-gradle:5.0.0-rc.1 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably not packaged as a jar, and its dependencies declared externally but:

we added this as workaround:

compile('org.ajoberstar.grgit:grgit-gradle:4.1.1')

ajoberstar commented 2 years ago

This should be fixed now in 0.13.2. It was caused by some interplay with com.gradle.plugin-publish, java-gradle-plugin, and dependency locking. I believe I've got a solution that's more reliable now (which includes not publishing directly to the Gradle plugin portal anymore, and making use of the fact that the portal proxies Maven Central).

It may take up to an hour for the version to show up in Central (due to their syncing process), but it should resolve the issue you all encountered.