-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add node-gradle generator/conventions plugin (#25594)
add node-gradle generator/conventions plugin
- Loading branch information
Showing
16 changed files
with
295 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import BaseApplicationGenerator from '../../../base-application/index.js'; | ||
import { GRADLE_BUILD_SRC_MAIN_DIR } from '../../../generator-constants.js'; | ||
import { GENERATOR_GRADLE } from '../../../generator-list.js'; | ||
|
||
export default class NodeGradleGenerator extends BaseApplicationGenerator { | ||
async beforeQueue() { | ||
if (!this.fromBlueprint) { | ||
await this.composeWithBlueprints(); | ||
} | ||
|
||
if (!this.delegateToBlueprint) { | ||
await this.dependsOnBootstrapAplication(); | ||
await this.dependsOnJHipster(GENERATOR_GRADLE); | ||
} | ||
} | ||
|
||
get writing() { | ||
return this.asWritingTaskGroup({ | ||
async writing({ application }) { | ||
await this.writeFiles({ | ||
blocks: [{ templates: [`${GRADLE_BUILD_SRC_MAIN_DIR}/jhipster.node-gradle-conventions.gradle`] }], | ||
context: application, | ||
}); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseApplicationGenerator.WRITING]() { | ||
return this.delegateTasksToBlueprint(() => this.writing); | ||
} | ||
|
||
get postWriting() { | ||
return this.asPostWritingTaskGroup({ | ||
customize({ application, source }) { | ||
source.addGradlePlugin!({ id: 'jhipster.node-gradle-conventions' }); | ||
source.addGradleBuildSrcDependencyCatalogLibraries!([ | ||
{ | ||
libraryName: 'node-gradle', | ||
module: 'com.github.node-gradle:gradle-node-plugin', | ||
version: application.javaDependencies!['node-gradle'], | ||
scope: 'implementation', | ||
}, | ||
]); | ||
|
||
source.addGradleProperty!({ property: 'nodeInstall', comment: 'Install and use a local version of node and npm.' }); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseApplicationGenerator.POST_WRITING]() { | ||
return this.delegateTasksToBlueprint(() => this.postWriting); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export { default } from './generator.js'; |
101 changes: 101 additions & 0 deletions
101
...ode-gradle/templates/buildSrc/src/main/groovy/jhipster.node-gradle-conventions.gradle.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
plugins { | ||
id "com.github.node-gradle.node" | ||
} | ||
|
||
if (project.hasProperty("nodeInstall")) { | ||
node { | ||
version = "<%= nodeVersion %>" | ||
npmVersion = "<%= nodeDependencies.npm %>" | ||
download = true | ||
} | ||
|
||
// Copy local node and npm to a fixed location for npmw | ||
def deleteOldNpm = tasks.register("deleteOldNpm", Delete) { | ||
delete '<%= temporaryDir %>node/lib/node_modules/npm' | ||
} | ||
def fixedNode = tasks.register("fixedNode", Copy) { | ||
from nodeSetup | ||
into '<%= temporaryDir %>node' | ||
finalizedBy deleteOldNpm | ||
} | ||
tasks.named("nodeSetup").configure { finalizedBy fixedNode } | ||
|
||
def fixedNpm = tasks.register("fixedNpm", Copy) { | ||
from npmSetup | ||
into '<%= temporaryDir %>node' | ||
} | ||
tasks.named("npmSetup").configure { finalizedBy fixedNpm } | ||
} | ||
|
||
<%_ 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("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) | ||
<%_ 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") | ||
.withPathSensitivity(PathSensitivity.RELATIVE) | ||
<%_ } _%> | ||
inputs.files(".postcssrc") | ||
.withPropertyName("postcssrc") | ||
.withPathSensitivity(PathSensitivity.RELATIVE) | ||
<%_ } _%> | ||
outputs.dir("build/test-results/jest/") | ||
.withPropertyName("jest-result-dir") | ||
outputs.file("build/test-results/TESTS-results-jest.xml") | ||
.withPropertyName("jest-result") | ||
outputs.file("build/test-results/clover.xml") | ||
.withPropertyName("clover-result") | ||
dependsOn npmInstall,compileTestJava | ||
args = ["run", "webapp:test"] | ||
} | ||
test.dependsOn webapp_test | ||
<%_ } _%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
generators/gradle/templates/buildSrc/gradle/libs.versions.toml.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
[versions] | ||
# jhipster-needle-gradle-build-src-dependency-catalog-version - JHipster will add additional versions for convention plugins here | ||
# jhipster-needle-gradle-dependency-catalog-version - JHipster will add additional versions for convention plugins heref | ||
# jhipster-needle-gradle-build-src-dependency-catalog-version - Deprecated: JHipster will add additional versions for convention plugins here | ||
|
||
[libraries] | ||
# jhipster-needle-gradle-dependency-catalog-libraries - JHipster will add additional libraries versions | ||
|
||
[plugins] | ||
# jhipster-needle-gradle-dependency-catalog-plugins - JHipster will add additional plugins versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.