Skip to content

Commit c1f4036

Browse files
authored
spring-boot: migrate neo4j to Spring Boot 4 (#31852)
1 parent c1996f2 commit c1f4036

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

generators/liquibase/generator.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export default class LiquibaseGenerator<
107107
// Generate h2 properties at master.xml for blueprints that uses h2 for tests or others purposes.
108108
application.liquibaseAddH2Properties ??= application.devDatabaseTypeH2Any;
109109
},
110+
liquibaseNeo4j({ application }) {
111+
// TODO drop hardcoded version
112+
if (application.databaseTypeNeo4j && application.javaManagedProperties['liquibase.version'] === '5.0.1') {
113+
application.javaDependencies['liquibase-neo4j'] = '5.0.0';
114+
}
115+
},
110116
checkDatabaseCompatibility({ application }) {
111117
if (!application.databaseTypeSql && !application.databaseTypeNeo4j) {
112118
throw new Error(`Database type ${application.databaseType} is not supported`);
@@ -488,16 +494,16 @@ export default class LiquibaseGenerator<
488494
});
489495
}
490496

491-
if (relationalApplication.databaseTypeNeo4j) {
492-
if (relationalApplication.backendTypeSpringBoot) {
497+
if (application.databaseTypeNeo4j) {
498+
if (application.backendTypeSpringBoot && !application.springBoot4) {
493499
source.addMavenDependency?.([{ groupId: 'org.springframework', artifactId: 'spring-jdbc' }]);
494500
}
495501
source.addMavenDependency?.([
496502
{
497503
groupId: 'org.liquibase.ext',
498504
artifactId: 'liquibase-neo4j',
499505
// eslint-disable-next-line no-template-curly-in-string
500-
version: '${liquibase.version}',
506+
version: application.javaDependencies['liquibase-neo4j'] ?? '${liquibase.version}',
501507
// Exclude current neo4j driver and use the one provided by spring-data
502508
// See: https://github.com/jhipster/generator-jhipster/pull/24241
503509
additionalContent: `
@@ -548,6 +554,13 @@ export default class LiquibaseGenerator<
548554
{ gradleFile: 'gradle/liquibase.gradle' },
549555
);
550556
}
557+
if (application.databaseTypeNeo4j && application.javaDependencies['liquibase-neo4j']) {
558+
source.addGradleDependencyCatalogLibrary!({
559+
libraryName: 'liquibase-neo4j',
560+
module: 'org.liquibase.ext:liquibase-neo4j',
561+
version: application.javaDependencies['liquibase-neo4j'],
562+
});
563+
}
551564
},
552565
nativeHints({ source, application }) {
553566
if (!application.graalvmSupport) return;

generators/liquibase/templates/gradle/liquibase.gradle.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies {
3333
<%_ } else if (databaseTypeNeo4j) { _%>
3434
// Exclude current neo4j driver and use the one provided by spring-data
3535
// See: https://github.com/jhipster/generator-jhipster/pull/24241
36-
implementation ("org.liquibase.ext:liquibase-neo4j:${dependencyManagement.importedProperties['liquibase.version']}") {
36+
implementation (<%- javaDependencies['liquibase-neo4j'] ? 'libs.liquibase.neo4j' : '"org.liquibase.ext:liquibase-neo4j:${dependencyManagement.importedProperties[\'liquibase.version\']}"' %>) {
3737
exclude group: "org.neo4j.driver", module: "neo4j-java-driver"
3838
exclude group: "org.slf4j", module: "*"
3939
}

generators/spring-boot/generators/bootstrap/generator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export default class BootstrapGenerator extends SpringBootApplicationGenerator {
3535
applicationDefaults({
3636
springBoot4: data =>
3737
Boolean(
38-
data.databaseTypeSql &&
39-
!data.reactive &&
38+
((data.databaseTypeSql && !data.reactive) || data.databaseTypeNeo4j) &&
4039
!data.cacheProviderInfinispan &&
4140
!data.cacheProviderHazelcast &&
4241
!data.searchEngineElasticsearch,

0 commit comments

Comments
 (0)