@@ -39,7 +39,7 @@ import type { Source as CommonSource } from '../common/types.ts';
3939import type { Entity as CypressEntity } from '../cypress/types.ts' ;
4040import { ADD_SPRING_MILESTONE_REPOSITORY } from '../generator-constants.ts' ;
4141import { addJavaImport , generateKeyStore , javaBeanCase } from '../java/support/index.ts' ;
42- import { getPomVersionProperties , parseMavenPom } from '../maven/support/index .ts' ;
42+ import type { JavaArtifactType } from '../java-simple-application/types .ts' ;
4343import {
4444 getJavaValueGeneratorForType ,
4545 getSpecificationBuildForType ,
@@ -52,12 +52,14 @@ import cleanupTask from './cleanup.ts';
5252import { writeFiles as writeEntityFiles } from './entity-files.ts' ;
5353import { serverFiles } from './files.ts' ;
5454import { askForOptionalItems , askForServerSideOpts , askForServerTestOpts } from './prompts.ts' ;
55+ import springBootDependencies from './resources/spring-boot-dependencies.ts' ;
5556import type {
5657 Application as SpringBootApplication ,
5758 Config as SpringBootConfig ,
5859 Entity as SpringBootEntity ,
5960 Options as SpringBootOptions ,
6061 Source as SpringBootSource ,
62+ SpringBootModule ,
6163} from './types.ts' ;
6264
6365const { CAFFEINE , EHCACHE , HAZELCAST , INFINISPAN , MEMCACHED , REDIS } = cacheTypes ;
@@ -274,11 +276,9 @@ export default class SpringBootGenerator extends SpringBootApplicationGenerator
274276 'spring-boot-dependencies' : "'SPRING-BOOT-VERSION'" ,
275277 } ;
276278 } else {
277- const pomFile = this . readJHipsterResource ( 'spring-boot-dependencies.pom' ) ! ;
278- const pom = parseMavenPom ( pomFile ) ;
279- application . springBootDependencies = this . prepareDependencies ( getPomVersionProperties ( pom ) , 'java' ) ;
279+ application . springBootDependencies = this . prepareDependencies ( springBootDependencies . versions , 'java' ) ;
280280 application . javaDependencies ! [ 'spring-boot' ] = application . springBootDependencies [ 'spring-boot-dependencies' ] ;
281- Object . assign ( application . javaManagedProperties ! , pom . project . properties ) ;
281+ Object . assign ( application . javaManagedProperties ! , springBootDependencies . properties ) ;
282282 application . javaDependencies ! . liquibase = application . javaManagedProperties ! [ 'liquibase.version' ] ! ;
283283 }
284284 } ,
@@ -420,6 +420,26 @@ ${classProperties
420420 ) ;
421421 } ;
422422 } ,
423+ needles ( { source } ) {
424+ const getScopeForModule = ( moduleName : SpringBootModule ) : JavaArtifactType [ 'scope' ] => {
425+ if ( moduleName === 'spring-boot-properties-migrator' ) return 'runtime' ;
426+ if ( moduleName === 'spring-boot-configuration-processor' ) return 'annotationProcessor' ;
427+ return moduleName . endsWith ( '-test' ) ? 'test' : undefined ;
428+ } ;
429+ source . addSpringBootModule = ( ...moduleNames ) =>
430+ source . addJavaDependencies ?.(
431+ moduleNames
432+ . filter ( module => typeof module === 'string' || module . condition )
433+ . map ( module => ( typeof module === 'string' ? module : module . module ) )
434+ . map ( name => ( {
435+ groupId : 'org.springframework.boot' ,
436+ artifactId : name ,
437+ scope : getScopeForModule ( name ) ,
438+ } ) ) ,
439+ ) ;
440+
441+ source . overrideProperty = props => source . addJavaProperty ! ( props ) ;
442+ } ,
423443 } ) ;
424444 }
425445
@@ -616,6 +636,26 @@ ${classProperties
616636
617637 get postWriting ( ) {
618638 return this . asPostWritingTaskGroup ( {
639+ baseDependencies ( { application, source } ) {
640+ source . addSpringBootModule ! (
641+ 'spring-boot-configuration-processor' ,
642+ 'spring-boot-loader-tools' ,
643+ 'spring-boot-starter' ,
644+ 'spring-boot-starter-actuator' ,
645+ 'spring-boot-starter-aop' ,
646+ 'spring-boot-starter-mail' ,
647+ 'spring-boot-starter-test' ,
648+ 'spring-boot-starter-thymeleaf' ,
649+ 'spring-boot-starter-tomcat' ,
650+ 'spring-boot-starter-validation' ,
651+ `spring-boot-starter-web${ application . reactive ? 'flux' : '' } ` ,
652+ 'spring-boot-test' ,
653+ {
654+ condition : application . authenticationTypeSession ,
655+ module : 'spring-boot-starter-security' ,
656+ } ,
657+ ) ;
658+ } ,
619659 addJHipsterBomDependencies ( { application, source } ) {
620660 const {
621661 applicationTypeGateway,
@@ -695,11 +735,7 @@ ${classProperties
695735 } ;
696736 source . addMavenPluginRepository ?.( springRepository ) ;
697737 source . addMavenRepository ?.( springRepository ) ;
698- source . addMavenDependency ?.( {
699- groupId : 'org.springframework.boot' ,
700- artifactId : 'spring-boot-properties-migrator' ,
701- scope : 'runtime' ,
702- } ) ;
738+ source . addSpringBootModule ?.( 'spring-boot-properties-migrator' ) ;
703739 }
704740 if ( application . jhipsterDependenciesVersion ?. endsWith ( '-SNAPSHOT' ) ) {
705741 source . addMavenRepository ?.( {
0 commit comments