Skip to content

Commit

Permalink
Merge pull request #426 from mshima/migration
Browse files Browse the repository at this point in the history
Use modular templates for gateway, Kafka and feign-client generators
  • Loading branch information
DanielFran authored Aug 5, 2024
2 parents df234e0 + 74f0ede commit 23b0a3f
Show file tree
Hide file tree
Showing 32 changed files with 77 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ application {
cacheProvider ehcache
clientFramework angular
creationTimestamp 1617901618887
feignClient true
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
// tests are not stable enough
// messageBroker pulsar
Expand All @@ -72,6 +73,7 @@ application {
creationTimestamp 1617901618888
dtoSuffix Rest
entitySuffix Entity
feignClient true
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
// tests are not stable enough
// messageBroker pulsar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ application {
clientFramework angular
creationTimestamp 1617901618887
databaseType neo4j
feignClient true
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
packageName com.okta.developer.blog
serverPort 8081
Expand All @@ -70,6 +71,7 @@ application {
databaseType neo4j
dtoSuffix Rest
entitySuffix Entity
feignClient true
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
packageName com.okta.developer.store
serverPort 8082
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ application {
databaseType mongodb
dtoSuffix Rest
entitySuffix Entity
feignClient true
jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ="
messageBroker kafka
packageName com.okta.developer.store
Expand Down
31 changes: 31 additions & 0 deletions generators/spring-boot-v2/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export default class extends BaseApplicationGenerator {
['EntityDTO', '_dtoClass_'],
[/\/Entity(.*)\./, '/_entityClass_$1.'],
['/BaseEntityMapper.', '/EntityMapper.'],
['JWT_UserFeignClientInterceptor.', 'UserFeignClientInterceptor_jwt.'],
['OAuth2UserClientFeignConfiguration.', 'OAuth2InterceptedFeignConfiguration.'],
['OAuth2_UserFeignClientInterceptor.', 'TokenRelayRequestInterceptor.'],
]) {
// Files renamed in v8
sourceFile = sourceFile.replace(...fileMap);
Expand Down Expand Up @@ -184,6 +187,12 @@ export default class extends BaseApplicationGenerator {
'gradlew.bat',
// jhipster:java:docker
'entrypoint.sh',
// jhipster:spring-cloud:gateway
'JWTRelayGatewayFilterFactory.java',
'ModifyServersOpenApiFilter.java',
'GatewayResource.java',
'RouteVM.java',
'ModifyServersOpenApiFilterTest.java',
// jhipster:spring-data-couchbase
'DatabaseConfiguration_couchbase.java',
// jhipster:spring-data-cassandra
Expand Down Expand Up @@ -235,6 +244,28 @@ export default class extends BaseApplicationGenerator {
'docker.gradle',
// jhipster:java:code-quality
'sonar.gradle',
// jhipster:feign-client
'AuthorizedFeignClient.java',
'OAuth2InterceptedFeignConfiguration.java',
'TokenRelayRequestInterceptor.java',
'FeignConfiguration.java',
'JWT_UserFeignClientInterceptor.java',
'OAuth2UserClientFeignConfiguration.java',
'OAuth2_UserFeignClientInterceptor.java',
'AuthorizationHeaderUtilTest.java',
'AuthorizationHeaderUtil.java',
'OAuthIdpTokenResponseDTO.java',
// jhipster:spring-cloud-stream:kafka
'KafkaTestContainer.java',
'EmbeddedKafka.java',
'EmbeddedKafka.java',
'EmbeddedKafka.java',
'KafkaResource.java',
'KafkaResourceIT.java',
'KafkaResource_reactive.java',
'KafkaResourceIT_reactive.java',
'KafkaSseConsumer.java',
'KafkaSseProducer.java',
// jhipster:java:openapi-generator v7.6.1
// 'swagger.gradle',
].includes(sourceBasename)
Expand Down
60 changes: 0 additions & 60 deletions generators/spring-boot/__snapshots__/matrix.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3396,9 +3396,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -4028,9 +4025,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -4696,9 +4690,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -5262,9 +5253,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -5909,9 +5897,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > gatew
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -12668,9 +12653,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -13872,9 +13854,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -15076,9 +15055,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -16214,9 +16190,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -17550,9 +17523,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > micro
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -24529,9 +24499,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -25194,9 +25161,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -25826,9 +25790,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -26503,9 +26464,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -27156,9 +27114,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -27758,9 +27713,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -28330,9 +28282,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -28932,9 +28881,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -29492,9 +29438,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/tech/jhipster/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/tech/jhipster/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -30253,9 +30196,6 @@ exports[`Matrix test of SubGenerator kotlin of kotlin JHipster blueprint > monol
"src/main/kotlin/com/mycompany/security/oauth2/JwtGrantedAuthorityConverter.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/security/oauth2/OAuthIdpTokenResponseDTO.kt": {
"stateCleared": "modified",
},
"src/main/kotlin/com/mycompany/service/AnotherSimpleService.kt": {
"stateCleared": "modified",
},
Expand Down
32 changes: 22 additions & 10 deletions generators/spring-boot/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ export default class extends BaseApplicationGenerator {
application.customizeTemplatePaths.unshift(
// Remove package-info.java files
file => (file.sourceFile.includes('package-info.java') ? undefined : file),
// Ignore files from generators
file =>
[
'jhipster:spring-cloud:gateway',
'jhipster:feign-client',
'jhipster:spring-cloud-stream:kafka',
'jhipster:spring-cloud-stream:pulsar',
].includes(file.namespace) && !file.sourceFile.includes('buildSrc')
? undefined
: file,
// Kotling blueprint does not implements these files
file => {
const sourceBasename = basename(file.sourceFile);
Expand Down Expand Up @@ -126,6 +116,7 @@ export default class extends BaseApplicationGenerator {
destinationFile = adjustTestContainersSpringContextCustomizerFactoryFile(destinationFile);
}

sourceFile = sourceFile.replace('KafkaConsumer_reactive', 'KafkaConsumer_imperative');
sourceFile = convertToKotlinFile(sourceFile);
destinationFile = convertToKotlinFile(destinationFile);
}
Expand All @@ -147,6 +138,27 @@ export default class extends BaseApplicationGenerator {

return { ...file, sourceFile, javaResolvedSourceFile, resolvedSourceFile, destinationFile };
},
// Adjust feign-client and kafka destinationFile for jhipster 7 paths
file => {
if (!['jhipster:feign-client', 'jhipster:spring-cloud-stream:kafka'].includes(file.namespace)) return file;
const renamedFiles = file => {
for (const fileMap of [
['security/oauth2/AuthorizationHeaderUtilTest.', 'client/AuthorizationHeaderUtilTest.'],
['security/oauth2/AuthorizationHeaderUtil.', 'client/AuthorizationHeaderUtil.'],
['security/oauth2/OAuthIdpTokenResponseDTO.', 'client/OAuthIdpTokenResponseDTO.'],
['config/KafkaSseConsumer.', 'broker/KafkaConsumer.'],
['config/KafkaSseProducer.', 'broker/KafkaProducer.'],
]) {
// Files renamed in v8
file = file.replace(...fileMap.reverse());
}
return file;
};
return {
...file,
destinationFile: renamedFiles(file.destinationFile),
};
},
);
},
});
Expand Down
12 changes: 11 additions & 1 deletion generators/spring-boot/templates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ describe('test if kotlin templates has a matching java template', async () => {
// Partials reworked
!file.includes('relationship_validators.ejs') &&
// Modularized file in JHipster 8
!file.includes('_entityClass_Repository'),
!file.includes('_entityClass_Repository') &&
// Mapped to KafkaResourceIT_imperative
!file.includes('KafkaResourceIT_reactive'),
)) {
const javaTemplate = file.replace('.kt', '.java').replace('kotlin/_package_', 'java/_package_');
const possibleTemplates = [];
Expand All @@ -38,6 +40,14 @@ describe('test if kotlin templates has a matching java template', async () => {
javaTemplateRelativePath = relative(join(__dirname, 'templates', folder), javaTemplate);
if (['domain'].includes(folder)) {
possibleTemplates.push(join(jhipster8Generators, 'java/generators', folder, 'templates', javaTemplateRelativePath));
} else if (['gateway'].includes(folder)) {
possibleTemplates.push(
join(jhipster8Generators, 'spring-cloud/generators', folder, 'templates', javaTemplateRelativePath),
);
} else if (['kafka'].includes(folder)) {
possibleTemplates.push(
join(jhipster8Generators, 'spring-cloud-stream/generators', folder, 'templates', javaTemplateRelativePath),
);
} else {
possibleTemplates.push(join(jhipster8Generators, folder, 'templates', javaTemplateRelativePath));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import <%= packageName %>.config.KafkaSseProducer
@RestController
@RequestMapping("/api/<%= dasherizedBaseName %>-kafka")
class <%= upperFirstCamelCase(baseName) %>KafkaResource(
class <%= upperFirstCamelCaseBaseName %>KafkaResource(
@Qualifier(KafkaSseProducer.CHANNELNAME) val output: MessageChannel
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import <%= packageName %>.config.KafkaSseProducer

@RestController
@RequestMapping("/api/<%= dasherizedBaseName %>-kafka")
class <%= upperFirstCamelCase(baseName) %>KafkaResource(@Qualifier(KafkaSseProducer.CHANNELNAME) val output: MessageChannel) {
class <%= upperFirstCamelCaseBaseName %>KafkaResource(@Qualifier(KafkaSseProducer.CHANNELNAME) val output: MessageChannel) {

private val log = LoggerFactory.getLogger(javaClass)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import <%= packageName %>.config.KafkaSseProducer;
@AutoConfigureMockMvc
@WithMockUser
@EmbeddedKafka
class <%= upperFirstCamelCase(baseName) %>KafkaResourceIT {
class <%= upperFirstCamelCaseBaseName %>KafkaResourceIT {
@Autowired
private lateinit var collector: MessageCollector
Expand Down
Loading

0 comments on commit 23b0a3f

Please sign in to comment.