diff --git a/generators/migration/generator.js b/generators/migration/generator.js index 77d5effcf..aac3b8180 100644 --- a/generators/migration/generator.js +++ b/generators/migration/generator.js @@ -5,21 +5,17 @@ export default class extends BaseApplicationGenerator { get [BaseApplicationGenerator.PREPARING]() { return this.asPreparingTaskGroup({ async source({ application, source }) { - this.queueTask({ - method: () => { - source.addAllowBlockingCallsInside = () => undefined; - source.addApplicationPropertiesContent = () => undefined; - source.addIntegrationTestAnnotation = () => undefined; - source.addTestSpringFactory = () => undefined; + this.delayTask(() => { + source.addAllowBlockingCallsInside = () => undefined; + source.addApplicationPropertiesContent = () => undefined; + source.addIntegrationTestAnnotation = () => undefined; + source.addTestSpringFactory = () => undefined; - if (application.buildToolGradle) { - // Add a noop needles for spring-gateway generator - source.addJavaDefinition = () => {}; - source.addJavaDependencies = () => {}; - } - }, - taskName: `${this.runningState.methodName}(delayed)`, - queueName: this.runningState.queueName, + if (application.buildToolGradle) { + // Add a noop needles for spring-gateway generator + source.addJavaDefinition = () => {}; + source.addJavaDependencies = () => {}; + } }); }, }); @@ -89,4 +85,12 @@ export default class extends BaseApplicationGenerator { }, }); } + + delayTask(method) { + this.queueTask({ + method, + taskName: `${this.runningState.methodName}(delayed)`, + queueName: this.runningState.queueName, + }); + } } diff --git a/generators/spring-boot/generator.js b/generators/spring-boot/generator.js index af510afab..f0f716381 100644 --- a/generators/spring-boot/generator.js +++ b/generators/spring-boot/generator.js @@ -284,38 +284,34 @@ export default class extends BaseApplicationGenerator { }); }, addCacheNeedles({ source, application }) { - this.queueTask({ - method: () => { - if (application.cacheProviderEhcache) { - const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`; - const needle = `${application.cacheProvider}-add-entry`; - const useJcacheConfiguration = application.cacheProviderRedis; - const addEntryToCacheCallback = entry => - createNeedleCallback({ - needle, - contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''})`, - }); - - source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry)); - source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => { - const entry = `${entityAbsoluteClass}::class.java.name`; - this.editFile( - cacheConfigurationFile, - addEntryToCacheCallback(entry), - ...(relationships ?? []) - .filter(rel => rel.collection) - .map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)), - ); - }; - } else { - // Add noop - source.addEntryToCache = () => {}; - // Add noop - source.addEntityToCache = () => {}; - } - }, - taskName: `${this.runningState.methodName}(delayed)`, - queueName: this.runningState.queueName, + this.delayTask(() => { + if (application.cacheProviderEhcache) { + const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`; + const needle = `${application.cacheProvider}-add-entry`; + const useJcacheConfiguration = application.cacheProviderRedis; + const addEntryToCacheCallback = entry => + createNeedleCallback({ + needle, + contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''})`, + }); + + source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry)); + source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => { + const entry = `${entityAbsoluteClass}::class.java.name`; + this.editFile( + cacheConfigurationFile, + addEntryToCacheCallback(entry), + ...(relationships ?? []) + .filter(rel => rel.collection) + .map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)), + ); + }; + } else { + // Add noop + source.addEntryToCache = () => {}; + // Add noop + source.addEntityToCache = () => {}; + } }); }, }); @@ -548,4 +544,12 @@ export default class extends BaseApplicationGenerator { }, }); } + + delayTask(method) { + this.queueTask({ + method, + taskName: `${this.runningState.methodName}(delayed)`, + queueName: this.runningState.queueName, + }); + } }