Repository: jhipster/jhipster-lite
Pull request #10924 (2024-09-20 08:46:34)

Init with target in gitignore
fix https://github.com/jhipster/jhipster-lite/issues/10873


Patch:
diff --git a/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactory.java
index 3ce6d2ac7..05b400994 100644
--- a/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactory.java
@@ -36,10 +36,6 @@ public class MavenModuleFactory {
         .put("dasherizedBaseName", properties.projectBaseName().kebabCase())
         .and()
       .prerequisites(JAVA_PREREQUISITES)
-      .gitIgnore()
-        .comment("Maven")
-        .pattern("/target/")
-        .and()
       .files()
         .add(SOURCE.template("pom.xml"), to("pom.xml"))
         .and()
diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
index ce433aaeb..5128fa28e 100644
--- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
+++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
@@ -3,6 +3,7 @@ package tech.jhipster.lite.generator.client.react.core.domain;
 import static tech.jhipster.lite.module.domain.JHipsterModule.*;
 import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.COMMON;
 import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.REACT;
+import static tech.jhipster.lite.module.domain.replacement.ReplacementCondition.always;
 
 import java.util.function.Consumer;
 import tech.jhipster.lite.module.domain.Indentation;
@@ -99,7 +100,7 @@ public class ReactCoreModulesFactory {
       .mandatoryReplacements()
         .in(path("eslint.config.js"))
           .add(lineAfterRegex("from 'typescript-eslint'"), "import react from 'eslint-plugin-react/configs/recommended.js';")
-            .add(regex("\\s+\\.\\.\\.typescript\\.configs\\.recommended.*"), "")
+            .add(regex(always(), "\\s+\\.\\.\\.typescript\\.configs\\.recommended.*"), "")
             .add(regex("[ \\t]+files: \\['src/\\*/webapp/\\*\\*\\/\\*\\.ts'],"), reactConfig)
             .add(
               lineAfterRegex("globals: \\{ \\.\\.\\.globals\\.browser },"),
@@ -154,7 +155,7 @@ public class ReactCoreModulesFactory {
       .mandatoryReplacements()
         .in(path("vitest.config.ts"))
           .add(lineAfterRegex("from 'vitest/config';"), "import react from '@vitejs/plugin-react';")
-          .add(text( "plugins: ["), "plugins: [react(), ")
+          .add(text("plugins: ["), "plugins: [react(), ")
           .add(text("environment: 'node',"), "environment: 'jsdom',")
           .add(vitestCoverageExclusion(properties,"src/main/webapp/app/index.tsx"))
           .and();
diff --git a/src/main/resources/generator/init/gitignore b/src/main/resources/generator/init/gitignore
index 90fb4cead..2d7245df7 100644
--- a/src/main/resources/generator/init/gitignore
+++ b/src/main/resources/generator/init/gitignore
@@ -69,6 +69,11 @@ out/
 !.vscode/extensions.json
 *.code-workspace
 
+######################
+# Maven
+######################
+/target/
+
 ######################
 # Package Files
 ######################


Test patch:
diff --git a/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactoryTest.java
index 64e07d068..ff5314b4e 100644
--- a/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactoryTest.java
+++ b/src/test/java/tech/jhipster/lite/generator/buildtool/maven/domain/MavenModuleFactoryTest.java
@@ -25,14 +25,6 @@ class MavenModuleFactoryTest {
     JHipsterModule module = factory.buildMavenModule(properties);
 
     assertThatModuleWithFiles(module, readmeFile())
-      .hasFile(".gitignore")
-      .containing(
-        """
-        # Maven
-        /target/\
-        """
-      )
-      .and()
       .hasFile("pom.xml")
       .containing("<groupId>tech.jhipster.jhlitest</groupId>")
       .containing("<artifactId>my-app</artifactId>")