@@ -42,7 +42,7 @@ abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
4242 private fun configureSourceSets (project : Project , extension : CallSiteInstrumentationExtension ) {
4343 // create a new source set for the csi files
4444 val targetFolder = newBuildFolder(project, extension.targetFolder.get().asFile.toString())
45- val sourceSets = getSourceSets( project)
45+ val sourceSets = project.sourceSets
4646 val mainSourceSet = sourceSets.named(MAIN_SOURCE_SET_NAME ).get()
4747 val csiSourceSet = sourceSets.create(" csi" ) {
4848 compileClasspath + = mainSourceSet.output // mainly needed for the plugin tests
@@ -91,10 +91,6 @@ abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
9191 return file
9292 }
9393
94- private fun getSourceSets (project : Project ): SourceSetContainer {
95- return project.extensions.getByType<JavaPluginExtension >().sourceSets
96- }
97-
9894 private fun createTasks (project : Project , extension : CallSiteInstrumentationExtension ) {
9995 registerGenerateCallSiteTask(project, extension, " compileJava" )
10096 val targetFolder = extension.targetFolder.get().asFile
@@ -152,17 +148,20 @@ abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
152148
153149 // Write the call site instrumenter arguments into a temporary file
154150 doFirst {
151+ val sourceSetOutput = project.sourceSets.matching { it.name.startsWith(MAIN_SOURCE_SET_NAME ) }.flatMap {
152+ it.output.classesDirs.files
153+ }
155154 val programClassPath = csiExtension.configurations.get().flatMap {
156155 it.files
157- }.map { it.toString() }
156+ }
158157
159158 val arguments = listOf (
160159 csiExtension.srcFolder.get().asFile.toString(),
161160 inputProvider.get().asFile.toString(),
162161 output.get().asFile.toString(),
163162 csiExtension.suffix.get(),
164163 csiExtension.reporters.get().joinToString(" ," )
165- ) + programClassPath
164+ ) + (sourceSetOutput + programClassPath).map { it.toString() }
166165
167166 val argumentFile = newTempFile(temporaryDir, " call-site-arguments" )
168167 Files .write(argumentFile.toPath(), arguments)
@@ -174,7 +173,7 @@ abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
174173 }
175174
176175 // make all sourcesets' class tasks depend on call site generator
177- val sourceSets = getSourceSets( project)
176+ val sourceSets = project.sourceSets
178177 sourceSets.named(MAIN_SOURCE_SET_NAME ) {
179178 project.tasks.named(classesTaskName) {
180179 dependsOn(callSiteGeneratorTask)
@@ -188,4 +187,7 @@ abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
188187 }
189188 }
190189 }
190+
191+ private val Project .sourceSets: SourceSetContainer
192+ get() = project.extensions.getByType<JavaPluginExtension >().sourceSets
191193}
0 commit comments