Apollo-android: Kotlin & Java files being generated

Created on 5 Mar 2020  路  9Comments  路  Source: apollographql/apollo-android

Hey all! Been using the library for awhile and loving it 馃挭

Summary
I recently tried to uptake the kotlin model generation.

apollo {
    setGenerateKotlinModels(true)
}

This works well, but it also generates the Java class which results in a duplicate class error.

Description
Queries and schema live in src/main/graphql/{package}/

Version
1.3.2

Bug Investigation

All 9 comments

Did you try to clean, maybe it was left overs from previous build?

cc @martinbonnin

Yeah, I cleaned & delete the entire build directory in the module that contained the Java + Kotlin files 馃槙

setGenerateKotlinModels(true)

I would not expect this to work on 1.3.2. I believe this changed to

generateKotlinModels.set(true)

Can you double check your plugin version matches the apollo-api version ?

Also can you share the structure of your build directory ? it should be something like

build/generated/source/apollo/debug/service

@martinbonnin Thanks for the quick reply!

I did also try generateKotlinModels.set(true), but no luck there. According to the 1.3.x migration guide, this adjustment should only matter if you are using a .kts build file.

I've confirmed that my apollo-gradle-plugin is also 1.3.2.

My build directory is build/generated/source/apollo/debug/service/{package} as you described above. Within the package there are files (Java & Kotlin) for each graphql query file. There is also a type package with all of the generated ENUMs & inputs (Java & Kotlin).

According to the 1.3.x migration guide, this adjustment should only matter if you are using a .kts build file.

Indeed, Groovy still allows setGenerateKotlinModels() 馃憤

Within the package there are files (Java & Kotlin) for each graphql query file

Can you check the following?

  • Only run one task: ./gradlew :module:generateDebugServiceApolloSources
  • Disable caching: ./gradlew :module:generateDebugServiceApolloSources --no-build-cache

Happy Monday! It was a gradle cache issue 馃う鈥嶁檪 Thanks @martinbonnin !

I am still facing this issue.
apollo version: 1.4.3
gradle: 6.3

apollo { generateKotlinModels.set(true) }

@sudansh can you try deleting your gradle directory (rm -rf ~/.gradle) and re-run your task with --no-build-cache ? Does it still happen ?

thanks. this fixed it.

Was this page helpful?
0 / 5 - 0 ratings