grails / grails-testing-support

Trait-based testing library for Grails framework
http://testing.grails.org
Apache License 2.0
11 stars 21 forks source link

Grails 7: Gradle 8.7+: JCenter retirement breaks webdriver-binaries-gradle-plugin and/or grolifant #443

Open jamesfredley opened 1 month ago

jamesfredley commented 1 month ago

The work around is to adjust gradle/wrapper/gradle-wrapper.properties to version 8.6.

https://blog.gradle.org/portal-jcenter-impact

This does not appear to occur if you have locally cached versions before the JCenter retirement. github actions caches dependencies also, so they are OK for now.

But on a new environment or if you delete .m2 and .gradle caches you will see this issue.

Current guess is that artifacts on maven central are different than the ones that were on JCenter. Micronaut ran into a similar issue, but they used an older version of web driver and the required jars for that exist on https://repo.grails.org/ui/native/core/org/ysb33r/gradle/grolifant/

Execution failed for task ':examples-grails3-hibernate5:configureChromeDriverBinary'.
> org/gradle/wrapper/ExclusiveFileAccessManager

Caused by: java.lang.NoClassDefFoundError: org/gradle/wrapper/ExclusiveFileAccessManager
    at org.ysb33r.grolifant.api.core.ExclusiveFileAccess.$getStaticMetaClass(ExclusiveFileAccess.groovy)
    at org.ysb33r.grolifant.api.core.ExclusiveFileAccess.<init>(ExclusiveFileAccess.groovy)
    at org.ysb33r.grolifant.api.v4.downloader.ArtifactDownloader.<init>(ArtifactDownloader.groovy:166)
    at org.ysb33r.grolifant.api.v4.downloader.AbstractDistributionInstaller.getDistFromCache(AbstractDistributionInstaller.groovy:184)
    at org.ysb33r.grolifant.api.v4.downloader.AbstractDistributionInstaller.resolveDistributionLocationForVersion(AbstractDistributionInstaller.groovy:154)
    at org.ysb33r.grolifant.api.v4.downloader.AbstractDistributionInstaller$1.call(AbstractDistributionInstaller.groovy:107)
    at org.ysb33r.grolifant.api.v4.downloader.AbstractDistributionInstaller$1.call(AbstractDistributionInstaller.groovy)
    at org.gradle.api.internal.provider.DefaultProvider.calculateOwnValue(DefaultProvider.java:72)
    at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateOwnPresentValue(AbstractMinimalProvider.java:80)
    at org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:100)
    at org.gradle.api.provider.Provider$get$0.call(Unknown Source)

The work around is to use Gradle 8.6, before they moved org/gradle/wrapper/ExclusiveFileAccessManager to https://github.com/gradle/gradle/blob/master/platforms/core-runtime/files/src/main/java/org/gradle/internal/file/locking/ExclusiveFileAccessManager.java

Related issues:

https://github.com/erdi/webdriver-binaries-gradle-plugin/issues/43 https://github.com/micronaut-projects/micronaut-core/discussions/10988 https://github.com/micronaut-projects/micronaut-core/pull/10990 - micronaut was using an older version of the web driver plugin and the required jars for that exist on https://repo.grails.org/ui/native/core/org/ysb33r/gradle/grolifant/

micronaut was using an older version with different id than grails: https://plugins.gradle.org/search?term=webdriver-binaries

\--- com.github.erdi:webdriver-binaries-gradle-plugin:3.2
     +--- org.ysb33r.gradle:grolifant50:2.0.2
     |    +--- org.tukaani:xz:1.6
     |    +--- org.ysb33r.gradle:grolifant40:2.0.2
     |    |    +--- org.tukaani:xz:1.6
     |    |    +--- org.apache.commons:commons-collections4:4.4
     |    |    +--- org.ysb33r.gradle:grolifant-core:2.0.2
     |    |    |    +--- org.tukaani:xz:1.6
     |    |    |    +--- org.apache.commons:commons-collections4:4.4
     |    |    |    \--- org.ysb33r.gradle:grolifant-rawhide:2.0.2
     |    |    |         \--- org.tukaani:xz:1.6
     |    |    \--- org.ysb33r.gradle:grolifant-rawhide:2.0.2 (*)
     |    +--- org.ysb33r.gradle:grolifant-core:2.0.2 (*)
     |    \--- org.ysb33r.gradle:grolifant40-legacy-api:2.0.2
     |         +--- org.tukaani:xz:1.6
     |         +--- org.apache.commons:commons-collections4:4.4
     |         +--- org.ysb33r.gradle:grolifant-core:2.0.2 (*)
     |         \--- org.ysb33r.gradle:grolifant40:2.0.2 (*)
     \--- org.apache.maven:maven-artifact:3.8.7
          +--- org.codehaus.plexus:plexus-utils:3.3.1
          \--- org.apache.commons:commons-lang3:3.8.1
jamesfredley commented 1 month ago

We need a new version of com.github.erdi:webdriver-binaries-gradle-plugin that uses a version of grolifant with this change

https://gitlab.com/ysb33rOrg/grolifant/-/blob/master/grolifant-core/src/main/groovy/org/ysb33r/grolifant/api/core/ExclusiveFileAccess.groovy?blame=1#L79

that does not call OperatingSystem.getExecutableName() which was removed in grolifant:3.0.1 https://ysb33rorg.gitlab.io/grolifant/3.0.1/docs/changelog.html

codeconsole commented 1 month ago
   /** Returns OS-specific decorated exe name.
     *
     * @param executablePath Name of exe
     * @return Returns an appropriately decorated exe
     * @deprecated Use{ @link #getExecutableNames(String) } instead
     */
    @Deprecated
    abstract String getExecutableName(String executablePath)

https://gitlab.com/ysb33rOrg/grolifant/-/merge_requests/130/diffs#2402bbf8216852c2f0c3e23d000b0f505d742441

https://gitlab.com/ysb33rOrg/grolifant/-/blob/RELEASE_3_0_1/grolifant-core/src/main/groovy/org/ysb33r/grolifant/api/core/OperatingSystem.groovy?ref_type=tags#L198-203


    /** Returns list of possible OS-specific decorated exe names.
     *
     * @param executablePath Name of exe
     * @return Returns a list of possible appropriately decorated exes
     */
    abstract List<String> getExecutableNames(String executablePath)

https://gitlab.com/ysb33rOrg/grolifant/-/blob/RELEASE_3_0_1/grolifant-core/src/main/groovy/org/ysb33r/grolifant/api/core/OperatingSystem.groovy?ref_type=tags#L142-163


    /** Locates the given exe in the system path.
     * @param name Name of exe to search for.
     * @return Executable location of {@code null} if not found.
     */
    File findInPath(String name) {
        for (String exeName : getExecutableNames(name)) {
            if (exeName.contains(pathSeparator)) {
                File candidate = new File(exeName)
                if (candidate.file) {
                    return candidate
                }
            } else {
                for (File dir : (path)) {
                    File candidate = new File(dir, exeName)
                    if (candidate.file) {
                        return candidate
                    }
                }
            }
        }
        null
    }

How it was used by the various operating system implementations:

https://gitlab.com/search?search=getExecutableName&nav_source=navbar&project_id=3777693&group_id=1800845&search_code=true&repository_ref=cd01e88c58aaf98819fa67611eb2eea6c6af5695

matrei commented 1 month ago

https://gitlab.com/ysb33rOrg/grolifant/-/issues/142

jamesfredley commented 1 month ago

PR submitted to https://github.com/erdi/webdriver-binaries-gradle-plugin/pull/44