diff --git a/generators/angular/generator.ts b/generators/angular/generator.ts index ad54b8d083ec..18bd94f3f78f 100644 --- a/generators/angular/generator.ts +++ b/generators/angular/generator.ts @@ -91,6 +91,12 @@ export default class AngularGenerator extends BaseApplicationGenerator { application.addPrettierExtensions?.(['html', 'css', 'scss']); }, + async javaNodeBuildPaths({ application }) { + application.javaNodeBuildPaths?.push('angular.json', 'tsconfig.json', 'tsconfig.app.json'); + if (application.clientBundlerWebpack) { + application.javaNodeBuildPaths?.push('webpack/'); + } + }, addNeedles({ source, application }) { source.addEntitiesToClient = param => { this.addEntitiesToModule(param); diff --git a/generators/app/__snapshots__/generator.spec.ts.snap b/generators/app/__snapshots__/generator.spec.ts.snap index 952df2ba0376..70c64f90b09a 100644 --- a/generators/app/__snapshots__/generator.spec.ts.snap +++ b/generators/app/__snapshots__/generator.spec.ts.snap @@ -1906,6 +1906,7 @@ exports[`generator - app with microservice should match snapshot 1`] = ` "xmemcached-provider": "'XMEMCACHED-PROVIDER-VERSION'", }, "javaManagedProperties": {}, + "javaNodeBuildPaths": [], "javaPackageSrcDir": "src/main/java/com/mycompany/myapp/", "javaPackageTestDir": "src/test/java/com/mycompany/myapp/", "javaProperties": {}, diff --git a/generators/bootstrap-application-server/generator.ts b/generators/bootstrap-application-server/generator.ts index c9ad39f4b1c4..d2aab855b65c 100644 --- a/generators/bootstrap-application-server/generator.ts +++ b/generators/bootstrap-application-server/generator.ts @@ -96,6 +96,7 @@ export default class BoostrapApplicationServer extends BaseApplicationGenerator applicationDefaults({ javaVersion: this.useVersionPlaceholders ? 'JAVA_VERSION' : JAVA_VERSION, packageInfoJavadocs: [], + javaNodeBuildPaths: [], javaProperties: {}, javaManagedProperties: {}, javaDependencies: ({ javaDependencies }) => ({ diff --git a/generators/gradle/generators/node-gradle/templates/buildSrc/src/main/groovy/jhipster.node-gradle-conventions.gradle.ejs b/generators/gradle/generators/node-gradle/templates/buildSrc/src/main/groovy/jhipster.node-gradle-conventions.gradle.ejs index 4f44a0969e91..ef75a30fce97 100644 --- a/generators/gradle/generators/node-gradle/templates/buildSrc/src/main/groovy/jhipster.node-gradle-conventions.gradle.ejs +++ b/generators/gradle/generators/node-gradle/templates/buildSrc/src/main/groovy/jhipster.node-gradle-conventions.gradle.ejs @@ -30,65 +30,16 @@ if (project.hasProperty("nodeInstall")) { <%_ if (!skipClient) { _%> task webapp_test(type: NpmTask) { inputs.property('appVersion', project.version) - inputs.files("package-lock.json") - .withPropertyName('package-lock') - .withPathSensitivity(PathSensitivity.RELATIVE) inputs.files("build.gradle") .withPropertyName('build.gradle') .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ if (clientFrameworkAngular) { _%> inputs.files(<%- javaNodeBuildPaths.filter(file => !file.endsWith('/')).map(file => `'${file}'`).join(', ') %>) - .withPropertyName('angular-build') + .withPropertyName('<%= clientFramework %>-build') .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ for (const file of javaNodeBuildPaths.filter(file => file.endsWith('/'))) { _%> + <%_ for (const file of javaNodeBuildPaths.filter(file => file.endsWith('/'))) { _%> inputs.dir("<%= file %>") .withPropertyName("<%= file %>") .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - <%_ } else { _%> - inputs.dir("<%= clientSrcDir %>") - .withPropertyName("webapp-source-dir") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ if (clientFrameworkReact) { _%> - inputs.files("tsconfig.json") - .withPropertyName("tsconfig") - .withPathSensitivity(PathSensitivity.RELATIVE) - - def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>") - webpackDevFiles.exclude("webpack.prod.js") - inputs.files(webpackDevFiles) - .withPropertyName("webpack-dir") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - <%_ if (clientFrameworkVue) { _%> - - inputs.files("tsconfig.json", "tsconfig.app.json") - .withPropertyName("tsconfig") - .withPathSensitivity(PathSensitivity.RELATIVE) - - inputs.files(".postcssrc") - .withPropertyName("postcssrc") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - <%_ if (clientBundlerVite && clientFrameworkBuiltIn) { _%> - - inputs.files("vite.config.mts") - .withPropertyName("vite") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - <%_ if (clientFrameworkVue) { _%> - <%_ if (clientBundlerWebpack) { _%> - def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>") - webpackDevFiles.exclude("webpack.prod.js") - inputs.files(webpackDevFiles) - .withPropertyName("webpack-dir") - <%_ } _%> - <%_ if (microfrontend) { _%> - inputs.files("module-federation.config.cjs") - .withPropertyName("module-federation") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - <%_ } _%> <%_ } _%> outputs.dir("build/test-results/jest/") diff --git a/generators/java/generators/node/generator.ts b/generators/java/generators/node/generator.ts index dc88af7b90d1..c9aacc24b76c 100644 --- a/generators/java/generators/node/generator.ts +++ b/generators/java/generators/node/generator.ts @@ -52,37 +52,12 @@ export default class NodeGenerator extends BaseApplicationGenerator { get preparing() { return this.asPreparingTaskGroup({ async javaNodeBuildPaths({ application }) { - application.javaNodeBuildPaths ??= []; - const { - clientBundlerVite, - clientBundlerWebpack, - clientFrameworkAngular, - clientFrameworkReact, - clientFrameworkVue, - clientFrameworkBuiltIn, - microfrontend, - srcMainWebapp, - javaNodeBuildPaths, - clientDistDir, - } = application; + const { buildToolMaven, srcMainWebapp, javaNodeBuildPaths, clientDistDir } = application; - javaNodeBuildPaths.push(srcMainWebapp, clientDistDir!, 'package-lock.json', 'package.json', 'tsconfig.json'); - if (clientFrameworkAngular) { - javaNodeBuildPaths.push('angular.json', 'tsconfig.app.json'); - } else if (clientFrameworkReact) { - javaNodeBuildPaths.push('.postcss.config.js'); - } else if (clientFrameworkVue) { - javaNodeBuildPaths.push('.postcssrc.js', 'tsconfig.app.json'); - if (microfrontend) { - javaNodeBuildPaths.push('module-federation.config.cjs'); - } - } - if (clientFrameworkBuiltIn) { - if (clientBundlerWebpack) { - javaNodeBuildPaths.push('webpack/'); - } else if (clientBundlerVite) { - javaNodeBuildPaths.push('vite.config.mts'); - } + javaNodeBuildPaths.push(srcMainWebapp, 'package-lock.json', 'package.json'); + if (buildToolMaven) { + // Gradle throws an error if the directory does not exist + javaNodeBuildPaths.push(clientDistDir!); } }, }); diff --git a/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap b/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap index cc3dc8c9d616..ea6a18b2aef8 100644 --- a/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap +++ b/generators/maven/generators/frontend-plugin/__snapshots__/generator.spec.ts.snap @@ -53,14 +53,10 @@ exports[`generator - maven:frontend-plugin with defaults options should call sou \${project.basedir} - angular.json package-lock.json package.json src/main/webapp/**/*.* target/classes/static/**/*.* - tsconfig.app.json - tsconfig.json - webpack/**/*.* **/app/**/service-worker.js diff --git a/generators/react/generator.ts b/generators/react/generator.ts index 3eb635f1c52a..4eaf0748fc29 100644 --- a/generators/react/generator.ts +++ b/generators/react/generator.ts @@ -97,6 +97,14 @@ export default class ReactGenerator extends BaseApplicationGenerator { webappEnumerationsDir: app => `${app.clientSrcDir}app/shared/model/enumerations/`, }); }, + async javaNodeBuildPaths({ application }) { + const { clientBundlerWebpack, javaNodeBuildPaths } = application; + + javaNodeBuildPaths?.push('.postcss.config.js', 'tsconfig.json'); + if (clientBundlerWebpack) { + javaNodeBuildPaths?.push('webpack/'); + } + }, prepareForTemplates({ application, source }) { source.addWebpackConfig = args => { const webpackPath = `${application.clientRootDir}webpack/webpack.common.js`; diff --git a/generators/spring-boot/templates/gradle/profile_dev.gradle.ejs b/generators/spring-boot/templates/gradle/profile_dev.gradle.ejs index 9eb7e98b8a48..dc737fe11e1b 100644 --- a/generators/spring-boot/templates/gradle/profile_dev.gradle.ejs +++ b/generators/spring-boot/templates/gradle/profile_dev.gradle.ejs @@ -51,59 +51,18 @@ bootRun { <%_ if (!skipClient) { _%> task webapp(type: NpmTask) { inputs.property('appVersion', project.version) - inputs.files("package-lock.json") - .withPropertyName('package-lock') - .withPathSensitivity(PathSensitivity.RELATIVE) inputs.files("build.gradle") .withPropertyName('build.gradle') .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ if (clientFrameworkAngular) { _%> - inputs.files("angular.json") - .withPropertyName('angular.json') - .withPathSensitivity(PathSensitivity.RELATIVE) - inputs.files("tsconfig.json", "tsconfig.app.json") - .withPropertyName("tsconfig") - .withPathSensitivity(PathSensitivity.RELATIVE) - inputs.dir("<%= CLIENT_WEBPACK_DIR %>") - .withPropertyName("<%= CLIENT_WEBPACK_DIR %>") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - inputs.dir("<%= clientSrcDir %>") - .withPropertyName("webapp-source-dir") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ if (clientFrameworkReact) { _%> - inputs.files("tsconfig.json") - .withPropertyName("tsconfig") - .withPathSensitivity(PathSensitivity.RELATIVE) - - def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>") - webpackDevFiles.exclude("webpack.prod.js") - inputs.files(webpackDevFiles) - .withPropertyName("webpack-dir") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } _%> - <%_ if (clientFrameworkVue) { _%> - inputs.files("tsconfig.json", "tsconfig.app.json") - .withPropertyName("tsconfig") - .withPathSensitivity(PathSensitivity.RELATIVE) - - inputs.files(".postcssrc") - .withPropertyName("postcssrc") + inputs.files(<%- javaNodeBuildPaths.filter(file => !file.endsWith('/')).map(file => `'${file}'`).join(', ') %>) + .withPropertyName('<%= clientFramework %>-build') .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ if (microfrontend) { _%> - - def webpackDevFiles = fileTree("<%= CLIENT_WEBPACK_DIR %>") - webpackDevFiles.exclude("webpack.prod.js") - inputs.files(webpackDevFiles) - .withPropertyName("webpack-dir") - .withPathSensitivity(PathSensitivity.RELATIVE) - <%_ } else { _%> - - inputs.files("vite.config.ts") - .withPropertyName("vite") + <%_ for (const file of javaNodeBuildPaths.filter(file => file.endsWith('/'))) { _%> + inputs.dir("<%= file %>") + .withPropertyName("<%= file %>") .withPathSensitivity(PathSensitivity.RELATIVE) <%_ } _%> - <%_ } _%> + outputs.dir("<%= clientDistDir %>") .withPropertyName("webapp-build-dir") diff --git a/generators/vue/generator.ts b/generators/vue/generator.ts index c34a51f91a61..99d8586c9b5b 100644 --- a/generators/vue/generator.ts +++ b/generators/vue/generator.ts @@ -100,6 +100,19 @@ export default class VueGenerator extends BaseApplicationGenerator { webappEnumerationsDir: app => `${app.clientWebappDir}shared/model/enumerations/`, }); }, + async javaNodeBuildPaths({ application }) { + const { clientBundlerVite, clientBundlerWebpack, microfrontend, javaNodeBuildPaths } = application; + + javaNodeBuildPaths?.push('.postcssrc.js', 'tsconfig.json', 'tsconfig.app.json'); + if (microfrontend) { + javaNodeBuildPaths?.push('module-federation.config.cjs'); + } + if (clientBundlerWebpack) { + javaNodeBuildPaths?.push('webpack/'); + } else if (clientBundlerVite) { + javaNodeBuildPaths?.push('vite.config.mts'); + } + }, prepareForTemplates({ application, source }) { application.addPrettierExtensions?.(['html', 'vue', 'css', 'scss']);