@@ -12,7 +12,6 @@ import org.gradle.api.Plugin
1212import org.gradle.api.Project
1313import org.gradle.api.plugins.AppliedPlugin
1414import org.gradle.api.plugins.PluginManager
15- import org.gradle.api.provider.Provider
1615import org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask
1716import org.jetbrains.kotlin.gradle.plugin.KaptExtension
1817import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
@@ -115,26 +114,26 @@ open class HephaestusPlugin : Plugin<Project> {
115114 // compile task. If the plugin classpath changed, then DisableIncrementalCompilationTask sets
116115 // the signal to false.
117116 @Suppress(" UnstableApiUsage" )
118- val incrementalSignal = project.gradle.sharedServices
119- .registerIfAbsent(" incrementalSignal" , IncrementalSignal ::class .java) { }
117+ val incrementalSignalServiceKey = registerIncrementalSignalBuildService(project)
120118
121119 if (isAndroidProject) {
122120 project.androidVariantsConfigure { variant ->
123121 val compileTaskName = " compile${variant.name.capitalize(US )} Kotlin"
124- disableIncrementalCompilationAction(project, incrementalSignal , compileTaskName)
122+ disableIncrementalCompilationAction(project, incrementalSignalServiceKey , compileTaskName)
125123 }
126124 } else {
127125 // The Java plugin has two Kotlin tasks we care about: compileKotlin and compileTestKotlin.
128- disableIncrementalCompilationAction(project, incrementalSignal , " compileKotlin" )
129- disableIncrementalCompilationAction(project, incrementalSignal , " compileTestKotlin" )
126+ disableIncrementalCompilationAction(project, incrementalSignalServiceKey , " compileKotlin" )
127+ disableIncrementalCompilationAction(project, incrementalSignalServiceKey , " compileTestKotlin" )
130128 }
131129 }
132130
133131 fun disableIncrementalCompilationAction (
134132 project : Project ,
135- incrementalSignal : Provider < IncrementalSignal > ,
133+ incrementalSignalServiceKey : IncrementalSignalServiceKey ,
136134 compileTaskName : String
137135 ) {
136+
138137 // Disable incremental compilation, if the compiler plugin dependency isn't up-to-date.
139138 // This will trigger a full compilation of a module using Hephaestus even though its
140139 // source files might not have changed. This workaround is necessary, otherwise
@@ -146,16 +145,12 @@ open class HephaestusPlugin : Plugin<Project> {
146145 task.pluginClasspath.from(
147146 project.configurations.getByName(PLUGIN_CLASSPATH_CONFIGURATION_NAME )
148147 )
149- task.incrementalSignal.set(incrementalSignal)
150148 }
151149
152150 project.tasks.named(compileTaskName, KotlinCompile ::class .java) { compileTask ->
153151 compileTask.dependsOn(disableIncrementalCompilationTaskProvider)
154152 }
155153
156- // We avoid a reference to the project in the doFirst.
157- val projectPath = project.path
158-
159154 // If we merge the block below and the block above, it looks like
160155 // the kotlin compiler is generating byte code for
161156 // disableIncrementalCompilationTaskProvider to be visible from the doFirst block
@@ -164,7 +159,7 @@ open class HephaestusPlugin : Plugin<Project> {
164159 compileTask.doFirst {
165160 // If the signal is set, then the plugin classpath changed. Apply the setting that
166161 // DisableIncrementalCompilationTask requested.
167- val incremental = incrementalSignal.get( ).incremental[projectPath]
162+ val incremental = getIncrementalSignalService(incrementalSignalServiceKey ).incremental
168163 if (incremental != null ) {
169164 compileTask.incremental = incremental
170165 }
0 commit comments