Skip to content

Commit

Permalink
correct gradle jar deployment to heroku
Browse files Browse the repository at this point in the history
updates jhipster#240
  • Loading branch information
atomfrede committed Apr 19, 2021
1 parent ac326c7 commit 84e1651
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion generators/heroku/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
15 changes: 9 additions & 6 deletions generators/heroku/templates/heroku.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
<%_ } _%>
2 changes: 1 addition & 1 deletion generators/server/templates/gradle.properties.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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') { _%>
Expand Down
12 changes: 0 additions & 12 deletions generators/server/templates/gradle/profile_prod.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 84e1651

Please sign in to comment.