Skip to content

Commit

Permalink
prototype to possible solution for early classpath resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
yigit committed Oct 14, 2023
1 parent 4a853a6 commit 7af4fb5
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,16 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
kspTask.compilerPluginOptions.addPluginArgument(kotlinCompileTask.compilerPluginOptions)
}
kspTask.commonSources.from(kotlinCompileTask.commonSources)
kspTask.options.add(FilesSubpluginOption("apclasspath", processorClasspath.files.toList()))
val kspOptions = kspTask.options.get().flatMap { listOf("-P", it.toArg()) }
kspTask.compilerOptions.freeCompilerArgs.value(
kspOptions + kotlinCompileTask.compilerOptions.freeCompilerArgs.get()
kspTask.options.add(
ClasspathFilesSubpluginOption("apclasspath", processorClasspath)
)
kspTask.compilerOptions.freeCompilerArgs.addAll(
kspTask.options.map {
it.flatMap { listOf("-P", it.toArg()) }
}
)
kspTask.compilerOptions.freeCompilerArgs.addAll(
kotlinCompileTask.compilerOptions.freeCompilerArgs
)
configureLanguageVersion(kspTask)
// Cannot use lambda; See below for details.
Expand Down Expand Up @@ -786,3 +792,15 @@ internal fun Configuration.markResolvable(): Configuration = apply {
isCanBeConsumed = false
isVisible = false
}


internal class ClasspathFilesSubpluginOption(
key: String,
val configuration: Configuration
) : SubpluginOption(
key = key,
lazyValue = lazy<String> {
val files = configuration.resolve()
files.joinToString(File.pathSeparator) { it.normalize().absolutePath }
}
)

0 comments on commit 7af4fb5

Please sign in to comment.