natario1
08/30/2021, 9:31 PMKotlinTarget
, named ksp<TargetName>
. For single-platform projects though, it might make sense to skip this step - when kotlin-jvm plugin is used for example, there's no point in having to write kspJvm
as it would be identical to root ksp
. What do you think?
2. Within each target, I create a configuration per KotlinCompilation
, named ksp<TargetName><CompilationName>
, extending the target configuration. As above, target name is omitted in single-platform. We could avoid creating this configuration for the main compilation, but after playing with it I think it's very nice to have fine grained control over main vs. test vs. both.
3. Within each compilation, I create a configuration per KotlinSourceSet
, named ksp<SourceSetName>
, but only if the source set is not the default one for that compilation. Basically this will be skipped 99% of the times?
4. Intermediate source sets do not have their own configuration. May be introduced in a future PR/version?
5. Android needs special handling. The KotlinSourceSet names are very confusing:
compilation=debug sourceSets=[androidDebug, androidMain]
compilation=debugAndroidTest sourceSets=[androidDebugAndroidTest, androidAndroidTest, androidAndroidTestDebug]
compilation=debugUnitTest sourceSets=[androidDebugUnitTest, androidTest, androidTestDebug]
compilation=release sourceSets=[androidRelease, androidMain]
compilation=releaseUnitTest sourceSets=[androidReleaseUnitTest, androidTest, androidTestRelease]
Looks to me that compilations == AGP variants, so one option is to create one config per variant named ksp<TargetName><VariantName>
. Another option is to read the `AndroidSourceSet`s from AGP (main, debug, release, test, testDebug, testRelease, androidTest, androidTestDebug, androidTestRelease). This gives more fine grained control, but it's harder to do (testDebug should extend both debug and test... Also not clear how to retrieve the correct configurations later in applyToCompilation()
).Ting-Yuan Huang
08/31/2021, 7:25 AMnatario1
08/31/2021, 8:04 AMgavra
09/03/2021, 11:04 AMksp
(for the main) and testKsp
(for the test)
• for android: ksp (for main), testKsp (for test) and androidTestKsp (for device tests). In general, we want allAndroidSourceSets>Ksp
which in a typical project maps to (ksp
, debugKsp
, releaseKsp
, testKsp
, androidTestKsp
)
• for multi-platform, it is the same, all sources sets, followed by KSP
I think this part is already in KSP. The part that is not is how we construct the final configuration (used by KSP task, let's call that _KspClasspath
). E.g:
• for kotlin-jvm projects: mainKspClasspath
should contain only ksp
, and testKspClasspath
(should contain testKsp
- right now it also contains ksp
which causes perf issues)
• for android: it is <variant>KspClasspath
and we need to figure out the same thing
• for multi-platform: dittonatario1
09/03/2021, 11:47 AM*Jvm*
and *Js*
configs. Ignore Android targets at this step.
2. enable multiplatform Android-specific configurations. We'll need to add the target name (typically Android
) in the config to avoid conflicts with other targets. We can discuss this later.
3. fix classpath perf issues
What do you think?
As a side note, I think we should name configurations ksp<Something> (ksp at start, not end). That's what ksp currently does and also what kapt
does (kaptAndroidTest for example).gavra
09/03/2021, 5:38 PMConfigurationName<sourceSet>
we can continue using that pattern.
The thing is that we need to decide about 3 before 1&2 are done. Creating user-visible configurations is one thing, but we also need to use them to resolve the ksp classpath when running the tasks (i.e we need to decide which configurations will be part of ksptClasspath
one). So, I think we need to consider all of 1&2&3 together 🙂
When it comes to which configurations to create, we should create the same configurations as for the compile/runtime classpath e.g if there is implementationJvm
we should have corresponding kspJvm
. This info should be in the source set extension of KMP (it also has Android info) and single-platform mpp projects.natario1
09/03/2021, 5:59 PMKotlinCompilation.kotlinSourceSets
info in applyToCompilation to determine the correct user-facing configuration(s), instead of the current approach with KotlinCompilation.allKotlinSourceSets
. That could be enough.natario1
09/03/2021, 6:05 PMksp
to all compilations, as what we really mean with it is kspMain
so it shouldn't be added to test for instancenatario1
09/03/2021, 7:44 PMnatario1
09/04/2021, 5:35 PMnatario1
09/06/2021, 10:56 AMgavra
09/07/2021, 5:20 PMnatario1
09/08/2021, 8:57 AMnatario1
09/20/2021, 9:42 AMgavra
09/22/2021, 10:06 AM