Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use custom SNAPSHOT version due to checkApolloVersions error #6315

Open
scana opened this issue Dec 10, 2024 · 2 comments
Open

Can't use custom SNAPSHOT version due to checkApolloVersions error #6315

scana opened this issue Dec 10, 2024 · 2 comments

Comments

@scana
Copy link

scana commented Dec 10, 2024

Version

4.1.1-SNAPSHOT

Summary

It seems that checkApolloVersions tasks gets two different version names when targeting a specific SNAPSHOT build, resulting in an error.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':network:checkApolloVersions'.
> Apollo: All apollo versions should be the same. Found:
  [4.1.1-20241209.154106-39, 4.1.1-SNAPSHOT]

In order to reproduce, use any SNAPSHOT version from here: https://s01.oss.sonatype.org/content/repositories/snapshots/com/apollographql/apollo/apollo-compiler/4.1.1-SNAPSHOT/

[versions]
apollo = '4.1.1-20241209.154106-39'
[plugins]
apollo = { id = "com.apollographql.apollo", version.ref = "apollo" }
[libraries]
apollo-cache = { module = "com.apollographql.apollo:apollo-normalized-cache", version.ref = "apollo" }
apollo-db = { module = "com.apollographql.apollo:apollo-normalized-cache-sqlite", version.ref = "apollo" }
apollo-runtime = { module = "com.apollographql.apollo:apollo-runtime", version.ref = "apollo" }
apollo-testing = { module = "com.apollographql.apollo:apollo-testing-support", version.ref = "apollo" }

Using apollo = '4.1.1-SNAPSHOT works fine.

One can disable the task to circumvent this issue temporarily:

tasks.configureEach {
  if (it.name == "checkApolloVersions") {
    it.enabled = false
  }
}
@martinbonnin
Copy link
Contributor

Good find! This is because of the apollo-compiler dependency that doesn't know about the "pinned" version (here).

I'm not sure how to fix. We'd need to get access to the "pinned" version at build time. Or maybe just leave the version out and let dependency resolution do its magic 🤔 . I'll dig.

In the meantime, disabling the check works unless you need to test a specific SNAPSHOT version of the compiler. If you do, you'll need to force the version using Gradle APIs. (If you're testing #6309, this only touches apollo-gradle-plugin so apollo-compiler should not matter)

@martinbonnin
Copy link
Contributor

martinbonnin commented Dec 10, 2024

In order to use the matching apollo-compiler version, you can do something like so:

configurations.getByName("apolloServiceCompiler").dependencies.apply {
  clear()
  add(dependencies.create("com.apollographql.apollo:apollo-compiler:4.1.1-20241209.154106-39"))
}

I haven't found a way to make a more general fix work. The SNAPSHOT timestamp is known way too late during the Gradle plugin build and relying on runtime looking up of the requested version seems fragile.

Longer term, that check should probably be moved to a runtime check (like antlr is doing). I have always resisted it because it'd add a version property to every generated query but it's probably not too bad.

For the record, SNAPSHOTs are special because:

  1. the version is replaced at publish time here
  2. and at resolve time here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants