Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusts #419

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const command = {
configs: {
sampleName: {
prompt: gen => ({
when: !gen.all && existsSync(gen.templatePath(gen.samplesFolder)),
when: !gen.jdlSamples && !gen.appSample && !gen.all && existsSync(gen.templatePath(gen.samplesFolder)),
type: 'list',
message: 'which sample do you want to generate?',
choices: async () => getSamples(gen.templatePath(gen.samplesFolder)),
Expand Down
32 changes: 18 additions & 14 deletions generators/migration/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {};
}
});
},
});
Expand Down Expand Up @@ -89,4 +85,12 @@ export default class extends BaseApplicationGenerator {
},
});
}

delayTask(method) {
this.queueTask({
method,
taskName: `${this.runningState.methodName}(delayed)`,
queueName: this.runningState.queueName,
});
}
}
1 change: 0 additions & 1 deletion generators/spring-boot/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const command = {
...springBootCommand.configs,
},
import: ['jhipster-kotlin:ktlint'],
compose: ['jhipster-kotlin:detekt'],
};

export default command;
76 changes: 41 additions & 35 deletions generators/spring-boot/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const JAVA_COMPATIBLE_VERSIONS = ['17'];

export default class extends BaseApplicationGenerator {
constructor(args, options, features) {
super(args, options, { ...features, jhipster7Migration: true, checkBlueprint: true, inheritTasks: true });
super(args, options, { ...features, jhipster7Migration: true, checkBlueprint: true, inheritTasks: true, queueCommandTasks: true });

this.jhipsterTemplatesFolders = [
this.templatePath(),
Expand All @@ -55,8 +55,8 @@ export default class extends BaseApplicationGenerator {
get [BaseApplicationGenerator.COMPOSING]() {
const mainComposing = super.composing;
return this.asComposingTaskGroup({
async composingTemplateTask() {
await this.composeCurrentJHipsterCommand();
async composeDetekt() {
await this.composeWithJHipster('jhipster-kotlin:detekt');
},
async composeWithPostWriting() {
await this.composeWithJHipster('docker');
Expand Down Expand Up @@ -121,6 +121,8 @@ export default class extends BaseApplicationGenerator {
'ElasticsearchExceptionMapper.java',
'ElasticsearchExceptionMapperTest.java',
'QuerySyntaxException.java',
'_enumName_.java',
'_persistClass_.java.jhi.jackson_identity_info.ejs',
].includes(sourceBasename)
? undefined
: file;
Expand Down Expand Up @@ -282,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 = () => {};
}
});
},
});
Expand Down Expand Up @@ -546,4 +544,12 @@ export default class extends BaseApplicationGenerator {
},
});
}

delayTask(method) {
this.queueTask({
method,
taskName: `${this.runningState.methodName}(delayed)`,
queueName: this.runningState.queueName,
});
}
}
Loading