From a82740094d33920dffc8e763bd30716e66868556 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Wed, 5 Jan 2022 18:56:43 +0100 Subject: [PATCH 1/4] Init with prettier-xml --- .../generator/buildtool/maven/pom.xml.mustache | 10 ++++++---- src/main/resources/generator/init/.prettierrc.mustache | 3 +++ .../resources/generator/init/package.json.mustache | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/resources/generator/buildtool/maven/pom.xml.mustache b/src/main/resources/generator/buildtool/maven/pom.xml.mustache index 3f47fa116ec..a155b074a77 100644 --- a/src/main/resources/generator/buildtool/maven/pom.xml.mustache +++ b/src/main/resources/generator/buildtool/maven/pom.xml.mustache @@ -1,7 +1,9 @@ - + 4.0.0 {{packageName}}{{^packageName}}com.mycompany.myapp{{/packageName}} @@ -229,7 +231,7 @@ enforce-dependencyConvergence - + false diff --git a/src/main/resources/generator/init/.prettierrc.mustache b/src/main/resources/generator/init/.prettierrc.mustache index dcd2665d5d7..65c2b9cdcb5 100644 --- a/src/main/resources/generator/init/.prettierrc.mustache +++ b/src/main/resources/generator/init/.prettierrc.mustache @@ -16,3 +16,6 @@ overrides: - files: "*.java" options: tabWidth: {{prettierDefaultIndent}}{{^prettierDefaultIndent}}2{{/prettierDefaultIndent}} + +# xml rules: +xmlWhitespaceSensitivity: ignore \ No newline at end of file diff --git a/src/main/resources/generator/init/package.json.mustache b/src/main/resources/generator/init/package.json.mustache index ddd2518e7b7..c8186aa58b3 100644 --- a/src/main/resources/generator/init/package.json.mustache +++ b/src/main/resources/generator/init/package.json.mustache @@ -6,10 +6,11 @@ "license": "UNLICENSED", "scripts": { "prepare": "husky install", - "prettier:check": "prettier --check \"{,src/**/}*.{md,json,yml,html,js,ts,tsx,css,scss,vue,java}\"", - "prettier:format": "prettier --write \"{,src/**/}*.{md,json,yml,html,js,ts,tsx,css,scss,vue,java}\"" + "prettier:check": "prettier --check \"{,src/**/}*.{md,json,yml,html,js,ts,tsx,css,scss,vue,java,xml}\"", + "prettier:format": "prettier --write \"{,src/**/}*.{md,json,yml,html,js,ts,tsx,css,scss,vue,java,xml}\"" }, "devDependencies": { + "@prettier/plugin-xml": "1.2.0", "husky": "7.0.4", "lint-staged": "12.1.3", "prettier": "2.5.1", From 023fc2150d83d310c28163b3e8f629a7e2f2bdbe Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Wed, 5 Jan 2022 19:07:36 +0100 Subject: [PATCH 2/4] Format existing xml templates and fix some indentation issues --- .../generator/buildtool/maven/domain/Maven.java | 2 +- .../domain/SpringBootLoggingDomainService.java | 2 +- .../generator/buildtool/maven/pom.xml.mustache | 8 +++----- .../server/springboot/core/MainApp.java.mustache | 1 - .../springboot/core/logback-spring.xml.mustache | 16 +++++++--------- .../server/springboot/core/logback.xml.mustache | 16 +++++++--------- .../application/MavenApplicationServiceIT.java | 2 +- .../buildtool/maven/domain/maven/MavenTest.java | 4 ++-- 8 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/Maven.java b/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/Maven.java index 2b4b5bddc8b..3c6fba9c60d 100644 --- a/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/Maven.java +++ b/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/Maven.java @@ -90,7 +90,7 @@ public static String getParent(Parent parent, int indentation) { .append(VERSION_END) .append(System.lineSeparator()) .append(indent(2, indentation)) - .append("") + .append("") .append(System.lineSeparator()) .append(indent(1, indentation)) .append(PARENT_END); diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/logging/domain/SpringBootLoggingDomainService.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/logging/domain/SpringBootLoggingDomainService.java index 120929e9d33..ce0b176c3dd 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/logging/domain/SpringBootLoggingDomainService.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/logging/domain/SpringBootLoggingDomainService.java @@ -35,7 +35,7 @@ private void addLoggerToConfiguration( String needleLogger ) { String loggerWithNeedle = - String.format("", packageName, level.toString()) + System.lineSeparator() + needleLogger; + String.format("", packageName, level.toString()) + System.lineSeparator() + " " + needleLogger; projectRepository.replaceText(project, getPath(folderConfig), fileLoggingConfig, needleLogger, loggerWithNeedle); } } diff --git a/src/main/resources/generator/buildtool/maven/pom.xml.mustache b/src/main/resources/generator/buildtool/maven/pom.xml.mustache index a155b074a77..f5054d97df3 100644 --- a/src/main/resources/generator/buildtool/maven/pom.xml.mustache +++ b/src/main/resources/generator/buildtool/maven/pom.xml.mustache @@ -1,4 +1,4 @@ - + - + ${project.basedir} **/*.exec @@ -243,8 +242,7 @@ - You are running an older version of Maven. JHipster requires at least Maven ${maven.version} - + You are running an older version of Maven. JHipster requires at least Maven ${maven.version} [${maven.version},) diff --git a/src/main/resources/generator/server/springboot/core/MainApp.java.mustache b/src/main/resources/generator/server/springboot/core/MainApp.java.mustache index e3df808c6b3..292e112a4ec 100644 --- a/src/main/resources/generator/server/springboot/core/MainApp.java.mustache +++ b/src/main/resources/generator/server/springboot/core/MainApp.java.mustache @@ -92,4 +92,3 @@ public class {{mainClass}}App { return hostAddress; } } - diff --git a/src/main/resources/generator/server/springboot/core/logback-spring.xml.mustache b/src/main/resources/generator/server/springboot/core/logback-spring.xml.mustache index 4b7346267a1..45942788659 100644 --- a/src/main/resources/generator/server/springboot/core/logback-spring.xml.mustache +++ b/src/main/resources/generator/server/springboot/core/logback-spring.xml.mustache @@ -1,8 +1,7 @@ - + - - + - + - - - + + + - + true - diff --git a/src/main/resources/generator/server/springboot/core/logback.xml.mustache b/src/main/resources/generator/server/springboot/core/logback.xml.mustache index 7fcb200a444..e9d09daa704 100644 --- a/src/main/resources/generator/server/springboot/core/logback.xml.mustache +++ b/src/main/resources/generator/server/springboot/core/logback.xml.mustache @@ -1,8 +1,7 @@ - + - - + - + - - - + + + WARN - + - diff --git a/src/test/java/tech/jhipster/lite/generator/buildtool/maven/application/MavenApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/buildtool/maven/application/MavenApplicationServiceIT.java index efb04b96431..12573cfd695 100644 --- a/src/test/java/tech/jhipster/lite/generator/buildtool/maven/application/MavenApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/buildtool/maven/application/MavenApplicationServiceIT.java @@ -38,7 +38,7 @@ void shouldAddParent() { "org.springframework.boot", "spring-boot-starter-parent", "2.5.3", - "", + "", "" ) ); diff --git a/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/maven/MavenTest.java b/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/maven/MavenTest.java index 967ac1f1e6b..b1195a549d2 100644 --- a/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/maven/MavenTest.java +++ b/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/maven/MavenTest.java @@ -21,7 +21,7 @@ void shouldGetParent() { " org.springframework.boot" + System.lineSeparator() + " spring-boot-starter-parent" + System.lineSeparator() + " 2.5.3" + System.lineSeparator() + - " " + System.lineSeparator() + + " " + System.lineSeparator() + " "; // @formatter:on Parent parent = Parent.builder().groupId("org.springframework.boot").artifactId("spring-boot-starter-parent").version("2.5.3").build(); @@ -37,7 +37,7 @@ void shouldGetParentWith4Indentations() { " org.springframework.boot" + System.lineSeparator() + " spring-boot-starter-parent" + System.lineSeparator() + " 2.5.3" + System.lineSeparator() + - " " + System.lineSeparator() + + " " + System.lineSeparator() + " "; // @formatter:on Parent parent = Parent.builder().groupId("org.springframework.boot").artifactId("spring-boot-starter-parent").version("2.5.3").build(); From f3625a9681984270a2632088b365efb71438eeba Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Wed, 5 Jan 2022 19:09:57 +0100 Subject: [PATCH 3/4] Add eol to prettierrc --- .prettierrc | 2 +- src/main/resources/generator/init/.prettierrc.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.prettierrc b/.prettierrc index 9783c8e61c5..1c5abaa25b9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -18,4 +18,4 @@ overrides: tabWidth: 2 # xml rules: -xmlWhitespaceSensitivity: ignore \ No newline at end of file +xmlWhitespaceSensitivity: ignore diff --git a/src/main/resources/generator/init/.prettierrc.mustache b/src/main/resources/generator/init/.prettierrc.mustache index 65c2b9cdcb5..13b5c3624df 100644 --- a/src/main/resources/generator/init/.prettierrc.mustache +++ b/src/main/resources/generator/init/.prettierrc.mustache @@ -18,4 +18,4 @@ overrides: tabWidth: {{prettierDefaultIndent}}{{^prettierDefaultIndent}}2{{/prettierDefaultIndent}} # xml rules: -xmlWhitespaceSensitivity: ignore \ No newline at end of file +xmlWhitespaceSensitivity: ignore From 2e3f4f160e3dc35b5cc0487666d1c6f1f36a5a72 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Wed, 5 Jan 2022 20:17:57 +0100 Subject: [PATCH 4/4] Fix tests related to logger xml --- .../MySQLApplicationServiceIT.java | 16 +++++++-------- .../PostgresqlApplicationServiceIT.java | 20 +++++++++---------- .../LiquibaseApplicationServiceIT.java | 8 ++++---- ...SpringBootLoggingApplicationServiceIT.java | 4 ++-- .../SpringBootMvcApplicationServiceIT.java | 12 +++++------ 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/database/mysql/application/MySQLApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/database/mysql/application/MySQLApplicationServiceIT.java index a2d91928201..c9376e31760 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/database/mysql/application/MySQLApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/database/mysql/application/MySQLApplicationServiceIT.java @@ -194,9 +194,9 @@ private void assertLoggerInConfig(Project project) { project, getPath(MAIN_RESOURCES, LOGGING_CONFIGURATION), List.of( - "", - "", - "" + "", + "", + "" ) ); @@ -204,11 +204,11 @@ private void assertLoggerInConfig(Project project) { project, getPath(TEST_RESOURCES, LOGGING_TEST_CONFIGURATION), List.of( - "", - "", - "", - "", - "" + "", + "", + "", + "", + "" ) ); } diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/database/postgresql/application/PostgresqlApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/database/postgresql/application/PostgresqlApplicationServiceIT.java index 3cc3ec5b676..dbc41f3b9d8 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/database/postgresql/application/PostgresqlApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/database/postgresql/application/PostgresqlApplicationServiceIT.java @@ -210,10 +210,10 @@ private void assertLoggerInConfig(Project project) { project, getPath(MAIN_RESOURCES, LOGGING_CONFIGURATION), List.of( - "", - "", - "", - "" + "", + "", + "", + "" ) ); @@ -221,12 +221,12 @@ private void assertLoggerInConfig(Project project) { project, getPath(TEST_RESOURCES, LOGGING_TEST_CONFIGURATION), List.of( - "", - "", - "", - "", - "", - "" + "", + "", + "", + "", + "", + "" ) ); } diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/dbmigration/liquibase/application/LiquibaseApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/dbmigration/liquibase/application/LiquibaseApplicationServiceIT.java index df7b0f97022..01c56bd19e9 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/dbmigration/liquibase/application/LiquibaseApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/dbmigration/liquibase/application/LiquibaseApplicationServiceIT.java @@ -154,16 +154,16 @@ private void assertLoggerInConfig(Project project) { assertFileContent( project, getPath(MAIN_RESOURCES, LOGGING_CONFIGURATION), - List.of("", "") + List.of("", "") ); assertFileContent( project, getPath(TEST_RESOURCES, LOGGING_TEST_CONFIGURATION), List.of( - "", - "", - "" + "", + "", + "" ) ); } diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/logging/application/SpringBootLoggingApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/logging/application/SpringBootLoggingApplicationServiceIT.java index 8ccd0b113e6..33a8d507d2f 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/logging/application/SpringBootLoggingApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/logging/application/SpringBootLoggingApplicationServiceIT.java @@ -37,7 +37,7 @@ void shouldAddLoggerWithLevel() { service.addLogger(project, "tech.jhipster.web", Level.DEBUG); String applicationProperties = getPath(MAIN_RESOURCES, "logback-spring.xml"); - assertFileContent(project, applicationProperties, ""); + assertFileContent(project, applicationProperties, ""); assertFileContent(project, applicationProperties, ""); } } @@ -60,7 +60,7 @@ void shouldAddLoggerWithLevel() { service.addLoggerTest(project, "tech.jhipster.web", Level.DEBUG); String applicationProperties = getPath(TEST_RESOURCES, "logback.xml"); - assertFileContent(project, applicationProperties, ""); + assertFileContent(project, applicationProperties, ""); assertFileContent(project, applicationProperties, ""); } } diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationServiceIT.java index cf5d8803a3d..ddc449f84f6 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationServiceIT.java @@ -43,7 +43,7 @@ void shouldInit() { assertFileContent(project, getPath(MAIN_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=8080"); assertFileContent(project, getPath(TEST_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=0"); - assertLoggingConfiguration(project, ""); + assertLoggingConfiguration(project, ""); assertTestUtil(project); assertExceptionHandler(project); @@ -62,7 +62,7 @@ void shouldAddSpringBootMvc() { assertFileContent(project, getPath(MAIN_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=8080"); assertFileContent(project, getPath(TEST_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=0"); - assertLoggingConfiguration(project, ""); + assertLoggingConfiguration(project, ""); assertTestUtil(project); assertExceptionHandler(project); @@ -82,7 +82,7 @@ void shouldAddSpringBootMvcWithServerPort() { assertFileContent(project, getPath(MAIN_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=7419"); assertFileContent(project, getPath(TEST_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=0"); - assertLoggingConfiguration(project, ""); + assertLoggingConfiguration(project, ""); assertTestUtil(project); assertExceptionHandler(project); @@ -102,7 +102,7 @@ void shouldAddSpringBootMvcWithInvalidServerPort() { assertFileContent(project, getPath(MAIN_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=8080"); assertFileContent(project, getPath(TEST_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=0"); - assertLoggingConfiguration(project, ""); + assertLoggingConfiguration(project, ""); assertTestUtil(project); assertExceptionHandler(project); @@ -121,7 +121,7 @@ void shouldAddSpringBootUndertow() { assertFileContent(project, getPath(MAIN_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=8080"); assertFileContent(project, getPath(TEST_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=0"); - assertLoggingConfiguration(project, ""); + assertLoggingConfiguration(project, ""); assertTestUtil(project); assertExceptionHandler(project); @@ -141,7 +141,7 @@ void shouldAddSpringBootUndertowWithServerPort() { assertFileContent(project, getPath(MAIN_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=1664"); assertFileContent(project, getPath(TEST_RESOURCES, "config", APPLICATION_PROPERTIES), "server.port=0"); - assertLoggingConfiguration(project, ""); + assertLoggingConfiguration(project, ""); assertTestUtil(project); assertExceptionHandler(project);