This message was deleted.
# community-support
s
This message was deleted.
m
I can't use
buildEnvironment
or so because the project fails during configuration
c
is it only failing in CI? Are there CI operations that aren’t configured to run locally?
m
Yea, it's only in CI after bumping to Gradle 7.4. This is the strangest thing.
c
ok. what is the specific error / stack trace?
It ends with
Copy code
aused by: java.lang.NoClassDefFoundError: com/google/wireless/android/sdk/stats/GradleBuildProject$PluginType
	at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:70)
	at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:56)
	at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:36)
	at org.gradle.internal.instantiation.generator.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:272)
	at org.gradle.internal.instantiation.generator.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:211)
	... 218 more
Caused by: java.lang.ClassNotFoundException: com.google.wireless.android.sdk.stats.GradleBuildProject$PluginType
	... 223 more
c
This hints at a version incompatibility with android plugin. Is this relevant to your build script?
m
It's something like this indeed but I can't explain why it only fails in CI...
c
are there tasks configured to only run in CI?
m
I don't think so but I'll double check
c
ok. there’s an oddity with how build-logic is used - it a dependency in build.gradle’s buildscript (to get it on the classpath). The correct way to get it on the classpath is to apply a plugin from build-logic (even if it’s an empty one). thinking that the classpath is ending up with multiple copies of libraries, perhaps only failing on different platforms (CI) due to ordering within the classpath.
m
So something like this using dependency substitution isn't reproducible?
Copy code
buildscript {
  dependencies {
    classpath("com.apollographql.apollo3:build-logic")
  }
}
c
that doesn’t appear to be dependency substitution. it’s adding a project to the buildscript classpath. Generally there isn’t a need for buildscript. Try this in build-logic: a dummy plugin class
Copy code
open class DistributionPlugin : Plugin<Project> {
    override fun apply(project: Project) : Unit = project.run {
    }
}
…define the plugin in build-logic’s build script:
Copy code
plugins {
    `kotlin-dsl`
}
gradlePlugin {
    plugins {
        create("distributionPlugin") {
            id = "cloudshift.gradle.DistributionPlugin"
            implementationClass = "cloudshift.gradle.distribution.DistributionPlugin"
        }
    }
}
…and apply where you want to expose classes available in consuming build scripts:
Copy code
id("cloudshift.gradle.DistributionPlugin")
that will get build-logic on the classpath of consuming projects w/o using buildscript and the differing classpath/classloader mechanisms there.
The repositories in the buildscript block can be moved to settings.gradle.kts; assuming these are used just for plugins, it would be
Copy code
pluginManagement {
    repositories {
    }
}
m
Classloaders never cease to amaze 😄 . I'll try that and report back, thanks!
c
gotta love classloaders 🤯 !
😄 1
m
We were due for conventions plugins anyways so I guess now is the time...
c
lol, yea, gives you a good place to start. see that challenging `subprojects`block in the main build script, would be great to get rid of the cross-project coupling there (allowing project tasks to run in parallel and other goodness)
💯 1
m
Turns out the issue was a "bad" Github Action cache entry
This is a bit scary TBH, it means that some artifact wasn't what it was supposed to be... So long for build reproducibility...
c
ok! glad you’ve tracked this down. what was the cache config that went sideways?
m
Not sure, one of the cache keys managed by https://github.com/gradle/gradle-build-action
c
ouch. using that myself.
m
Setting the cache "write-only" fixes the issue
(I'm planning to make it read/write again once this workflow finishes)
👍 1
For the record, the cache is useful indeed
left is with cache, right is without
c
indeed!