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

Update build stack #420

Merged
merged 8 commits into from
Aug 2, 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
16 changes: 16 additions & 0 deletions generators/kotlin/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ export default class extends BaseApplicationGenerator {
});
}
}

if (application.enableSwaggerCodegen) {
this.editFile(
'build.gradle',
content => `${content}
tasks.withType(org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask.class).configureEach {
dependsOn 'openApiGenerate'
}
`,
);
this.editFile('gradle/swagger.gradle', content => content.replace(', useSpringBoot3: "true"', ''));
}
}
},
async customizeMaven({ application, source }) {
Expand Down Expand Up @@ -317,6 +329,10 @@ export default class extends BaseApplicationGenerator {
},
],
});

if (application.enableSwaggerCodegen) {
this.editFile('pom.xml', content => content.replace('<useSpringBoot3>true</useSpringBoot3>', ''));
}
}
},
});
Expand Down
11 changes: 11 additions & 0 deletions generators/ktlint/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ export default class extends BaseApplicationGenerator {
addToBuild: true,
},
]);

if (application.enableSwaggerCodegen) {
this.editFile(
'build.gradle',
content => `${content}
tasks.named('runKtlintFormatOverMainSourceSet').configure {
dependsOn 'openApiGenerate'
}
`,
);
}
} else {
source.addJavaDefinition({
versions: [{ name: 'ktlint-maven-plugin', version: application.javaDependencies['ktlint-maven'] }],
Expand Down
4 changes: 4 additions & 0 deletions generators/ktlint/templates/gradle/ktlint.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
ktlint {
//See more options: https://github.com/JLLeitschuh/ktlint-gradle#configuration
ignoreFailures = true
filter {
include("src/main/kotlin/**")
include("src/test/kotlin/**")
}
}

// Reformat code before compilation
Expand Down
106 changes: 52 additions & 54 deletions generators/migration/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,69 @@ import { passthrough } from '@yeoman/transform';
export default class extends BaseApplicationGenerator {
get [BaseApplicationGenerator.PREPARING]() {
return this.asPreparingTaskGroup({
async source({ application, source }) {
async source({ source }) {
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 = () => {};
}
});
},
});
}

get [BaseApplicationGenerator.DEFAULT]() {
return this.asDefaultTaskGroup({
async defaultTask({ application }) {
if (application.buildToolGradle) {
this.queueTransformStream(
{
name: 'updating gradle files',
filter: file => file.path.endsWith('.gradle'),
refresh: false,
},
passthrough(file => {
file.contents = Buffer.from(
file.contents
.toString()
.replaceAll(/reportOn (.*)/g, 'testResults.from($1)')
.replaceAll('destinationDir =', 'destinationDirectory =')
.replaceAll('html.enabled =', 'html.required =')
.replaceAll('xml.enabled =', 'xml.required =')
.replaceAll('csv.enabled =', 'csv.required ='),
);
}),
);
}
async defaultTask() {
this.queueTransformStream(
{
name: 'updating build files',
filter: file => file.path.endsWith('.gradle') || file.path.endsWith('pom.xml'),
refresh: false,
},
passthrough(file => {
file.contents = Buffer.from(
file.contents
.toString()
.replace('micrometer-registry-prometheus-simpleclient', 'micrometer-registry-prometheus')
.replaceAll('jakarta.', 'javax.')
.replaceAll('spring-cloud-stream-test-binder', 'spring-cloud-stream-test-support')
.replaceAll('org.hibernate.orm', 'org.hibernate')
.replaceAll('mongock-springboot-v3', 'mongock-springboot')
.replaceAll('mongodb-springdata-v4-driver', 'mongodb-springdata-v3-driver')
.replaceAll('jackson-datatype-hibernate6', 'jackson-datatype-hibernate5')
.replaceAll('org.apache.cassandra', 'com.datastax.oss')
// Gradle only
.replace(
'importMappings = [Problem:"org.zalando.problem.Problem"]',
'importMappings = [Problem:"org.springframework.http.ProblemDetail"]',
)
.replace('hibernate-jcache"', 'hibernate-jcache:${hibernateVersion}"')
.replace(
"excludes = ['time']",
`properties {
time = null
}`,
)
// Maven only
.replaceAll('<classifier>jakarta</classifier>', '')
.replace(
'<skipValidateSpec>false</skipValidateSpec>',
'<importMappings>Problem=org.zalando.problem.Problem</importMappings><skipValidateSpec>false</skipValidateSpec>',
),
);
}),
);

this.queueTransformStream(
{
name: 'updating log files',
filter: file => file.path.endsWith('logback-spring.xml') || file.path.endsWith('logback.xml'),
refresh: false,
},
passthrough(file => {
file.contents = Buffer.from(file.contents.toString().replaceAll('jakarta.', 'javax.'));
}),
);
},
});
}
Expand All @@ -58,31 +81,6 @@ export default class extends BaseApplicationGenerator {
scriptsStorage.delete('pree2e:headless');
}
},
async postWritingTemplateTask({ application }) {
this.editFile('src/main/resources/logback-spring.xml', contents => contents.replaceAll('jakarta.', 'javax.'));
this.editFile('src/test/resources/logback.xml', contents => contents.replaceAll('jakarta.', 'javax.'));

if (application.buildToolGradle) {
// JHipster 8 have needles fixed
this.editFile('build.gradle', contents => contents.replaceAll('//jhipster', '// jhipster'));
if (application.databaseTypeSql) {
const { javaDependencies } = application;
this.editFile('build.gradle', contents =>
contents.replace(
'\nconfigurations {',
'\nconfigurations {\n liquibaseRuntime.extendsFrom sourceSets.main.compileClasspath\n',
),
);
this.editFile('gradle.properties', contents =>
contents
.replace(/liquibasePluginVersion=(.*)/, 'liquibasePluginVersion=2.2.2')
.replace(/(checkstyleVersion)=(.*)/, `$1=${javaDependencies.checkstyle}`)
.replace(/(noHttpCheckstyleVersion)=(.*)/, `$1=${javaDependencies['nohttp-checkstyle']}`),
);
}
this.editFile('settings.gradle', contents => contents.replaceAll('//jhipster', '// jhipster'));
}
},
});
}

Expand Down
Loading
Loading