Migration from apollo android to apollo kotlin 3.8.2

Hello, again.

We have multi module project, during the migration from apollo android to apollo kotlin i am getting duplocate content root errors, in order to resolve these warrnings i have to add

outputDirConnection {
  connectKotlinSourceSet("test")
}

so with my understainding without this it generates kotlin models two times one time will be for main and second will be for the test package.
after i add this in all of the module gradle file warning is gone but i wonder if there is a way to write this once in somewhere like a global file ? i dont want to have added this in like 40 modules.

1 Like

Hi :wave: I would recommend to use convention plugins (Sharing build logic between subprojects Sample).

If you have 40 modules, chances are that you already have some shared configuration already for things like target JVM/Android versions? You can share the Apollo configuration there.

it will be nice but than i will lose flexibility to configure each module for services.
we had two scheme some modules uses only one some of them uses both so is there any other option ?

You can pass parameters to your convention plugins, either through custom extensions or plain function parameters. You can then wrap all the Apollo configuration in your convention plugin.

plugins {
  id("my.convention.plugin")
}

myConventionExtension {
  apolloSchema1()
  // or 
  apolloSchema2()
}

There is a small setup price to pay (you need to touch all your 40 modules once) but in the long run it’s a lot more maintainable as all the configuration happens in a centralized place.