From 84e165139cb0a0ee516225003b2498f6fd7f4358 Mon Sep 17 00:00:00 2001 From: Frederik Hahne Date: Mon, 19 Apr 2021 23:13:38 +0200 Subject: [PATCH] correct gradle jar deployment to heroku updates #240 --- generators/heroku/index.js | 2 +- generators/heroku/templates/heroku.gradle.ejs | 15 +++++++++------ generators/server/templates/gradle.properties.ejs | 2 +- .../templates/gradle/profile_prod.gradle.ejs | 12 ------------ 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/generators/heroku/index.js b/generators/heroku/index.js index 94fae47b..b64365aa 100644 --- a/generators/heroku/index.js +++ b/generators/heroku/index.js @@ -24,7 +24,7 @@ const HerokuGeneratorOverride = class extends HerokuGenerator { let buildCmd = 'mvnw -ntp verify -B'; if (buildTool === 'gradle') { - buildCmd = 'gradlew shadowJar'; + buildCmd = 'gradlew stage -PnodeInstall'; } if (os.platform() !== 'win32') { diff --git a/generators/heroku/templates/heroku.gradle.ejs b/generators/heroku/templates/heroku.gradle.ejs index 688b03f8..10fff297 100644 --- a/generators/heroku/templates/heroku.gradle.ejs +++ b/generators/heroku/templates/heroku.gradle.ejs @@ -22,20 +22,23 @@ heroku { appName = "<%= herokuAppName %>" buildpacks = ["heroku/jvm"] } -<%_ if (herokuDeployType === 'git') { _%> - // Task stage is used by Heroku, see also // https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku // and GRADLE_TASK configuration variable. -task stage(dependsOn: "shadowJar") { +task stage(dependsOn: "assemble") { } gradle.taskGraph.whenReady {taskGraph -> taskGraph.afterTask() {task -> - if (task.getName().equals("stage") && System.getenv("DYNO") != null) { - delete "node_modules" + if (task.getName().equals("stage")) { + if (System.getenv("DYNO") != null) { + delete "node_modules" + } delete fileTree(dir: "build/libs", exclude: "*.jar") + delete fileTree(dir: "build/libs", exclude: "*-all.jar") + delete fileTree(dir: "build/tmp") + delete fileTree(dir: "build/distributions") + delete fileTree(dir: "build/layers") } } } -<%_ } _%> diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index cb5c72f7..8acaecb5 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -69,7 +69,7 @@ jaxb_runtime_version=2.3.2 micronaut_plugin_version=1.4.0 git_properties_plugin_version=2.2.2 <%_ if (!skipClient) { _%> -gradle_node_plugin_version=2.2.4 +gradle_node_plugin_version=3.0.1 <%_ } _%> apt_plugin_version=0.21 <%_ if (databaseType === 'sql') { _%> diff --git a/generators/server/templates/gradle/profile_prod.gradle.ejs b/generators/server/templates/gradle/profile_prod.gradle.ejs index c18b365b..e0c529f6 100644 --- a/generators/server/templates/gradle/profile_prod.gradle.ejs +++ b/generators/server/templates/gradle/profile_prod.gradle.ejs @@ -59,14 +59,6 @@ task webpack(type: <%= _.upperFirst(clientPackageManager) %>Task, dependsOn: "<% <%_ } _%> <%_ if (!skipClient) { _%> -task webpackBuildDev(type: NpmTask, dependsOn: 'npmInstall') { - inputs.dir("src/main/webapp/") - inputs.files(fileTree('src/main/webapp/')) - outputs.dir("build/www/") - outputs.file("build/www/app/main.bundle.js") - args = ["run", "webpack:build"] -} - task copyIntoStatic (type: Copy) { from 'build/www/' into 'build/resources/main/static' @@ -99,10 +91,6 @@ processResources { test.dependsOn webpack_test processResources.dependsOn webpack -processResources.dependsOn webpackBuildDev -copyIntoStatic.dependsOn processResources -assemble.dependsOn copyIntoStatic - npmInstall.onlyIf { shouldWebpackRun() == true } def shouldWebpackRun() {