@@ -178,17 +178,20 @@ interface InstrumentWorkParameters extends WorkParameters {
178178abstract class InstrumentAction implements WorkAction<InstrumentWorkParameters > {
179179 private static final Object lock = new Object ()
180180 private static ClassLoader pluginCL
181- private static volatile long lastBuildStamp
181+ private static String cachedPluginPath
182+ private static volatile long cachedBuildStamp
182183
183184 @Override
184185 void execute () {
185186 // reset shared class-loaders each time a new build starts
186187 long buildStamp = parameters. buildStartedTime. get()
187- if (lastBuildStamp < buildStamp || ! pluginCL) {
188+ String pluginPath = parameters. pluginClassPath. join(' :' )
189+ if (rebuildSharedClassLoader(buildStamp, pluginPath)) {
188190 synchronized (lock) {
189- if (lastBuildStamp < buildStamp || ! pluginCL ) {
191+ if (rebuildSharedClassLoader( buildStamp, pluginPath) ) {
190192 pluginCL = createClassLoader(parameters. pluginClassPath)
191- lastBuildStamp = buildStamp
193+ cachedPluginPath = pluginPath
194+ cachedBuildStamp = buildStamp
192195 }
193196 }
194197 }
@@ -199,6 +202,10 @@ abstract class InstrumentAction implements WorkAction<InstrumentWorkParameters>
199202 InstrumentingPlugin . instrumentClasses(plugins, instrumentingCL, sourceDirectory, targetDirectory)
200203 }
201204
205+ static boolean rebuildSharedClassLoader (long buildStamp , String pluginPath ) {
206+ return cachedBuildStamp < buildStamp || cachedPluginPath != pluginPath
207+ }
208+
202209 static ClassLoader createClassLoader (cp , parent = InstrumentAction . classLoader) {
203210 return new URLClassLoader (cp* . toURI()* . toURL() as URL [], parent as ClassLoader )
204211 }
0 commit comments