Task 'bootRepackage' not found in root project 'gateway' - spring-boot

I am reading Full Stack Development with JHipster book.
I created a Microservice gateway with 'gateway' app name.
By following the book when I run
./gradlew bootRepackage -Pprod buildDocker
in the terminal, it says
Task 'bootRepackage' not found in root project 'gateway'
and then stop running.
My Jhipster version is 5.0.0

In JHipster v5.0.0+, the goal bootRepackage doesn't exist. It has changed to bootWar, so you need to use:
./gradlew bootWar -Pprod buildDocker

I have similar issue for Spring Boot 2.X. And solved it by changing to bootJar.
gradlew clean && gradlew bootJar

Related

Difference between gradle bootrun and bootjar/build in a springboot application

I'm working in a quite complex app that for some reason, gradle bootRun works as expected but when gradle bootjar or gradle build is used to then execute the packaged jar with java -jar pathtojar, it fails to load some jruby scripts present in a dependency.
What are the differences between those two in terms of packaging and how can bootRun be more reliable?

spring boot: maven command to download all dependencies

In a spring boot project I would like to download all dependencies before starting the application.
When I run "mvn compile" first, it is downloading a lot of dependecies. But when I run "mvn spring-boot:run" after that, it still downloads tons of dependecies.
So what is the right way to download all dependecies like spring-boot:run does - but without running the application?
Thank you!
Try running maven with -o switch to run your maven command in offline mode. This will use already downloaded dependencies in the local repository.

unable to pass spring profile from gradle command line

I have gone through multiple suggestions in stackoverflow but unable to do it.
I have spring boot gradle app and trying to execute and run the gradle build through command line. I want to pass teh spring profile also while executing so.
I tried adding
bootRun {
systemProperties = System.properties
}
in gradle.build
and also tried
gradle bootrun -Pdev
command but it is not pciking up profile. I am very very new to gradle and dont sure what to do .
so i added below part in build.gradle
bootRun {
systemProperties = System.properties
}
and i used below command line command to pass spring profile.
gradle bootRun -Dspring.profiles.active=dev
i am able to see the below spring profile loaded logs.
The following profiles are active: dev

jhipster v4.14.4 - building an executable WAR-file

As mentioned here as well as here it should be possible - and a must-have for the docker-container - to be able to build a WAR-file of the whole application with ./gradlew -Pprod bootWar or make the application ready for a deployment via docker-container with ./gradlew bootWar -Pprod buildDocker.
But Intellij IDEA tells me, that there is no task bootWar. And ./gradlew -Pprod bootRundoesn't generate a *.war-file in build/libs/.
I also tried publishing directly to heroku, triggered by pushes to my github-repository controlled by a local jenkins2 docker-container. Maybe even the 404-Site after successful builds at heroku comes from this. The manual way documented in the jhipster.tech-documentation with ./gradlew -Pprod bootWar -x test and heroku deploy:jar --jar build/libs/*war can't work without the *.war.
So how can I export my monolithic jhipster-application into a *.war-file?
AFAIK you can generate a war with gradle by typing the following command
./gradlew -P prod build and/or ./gradlew -P prod build bootRepackage

Unable to access jar when running gradle dropwizard app deployed on heroku

I am trying to deploy a dropwizard app on heroku which fails to launch.
Its works fine locally using "gradle run server config.yml"
I am using gradle for build and when I push to heroku the build is successful.
My gradle stage task dependsOn clean and jar(fat jar creation)
My Procfile has:
web: java $JAVA_OPTS -jar dropwizard-app/build/libs/dropwizard-app.jar server dropwizard-app/config.yml
The above fails with "Unable to access jarfile dropwizard-app/build/libs/dropwizard-app.jar"
I have tried unsuccessfully with
web: java $JAVA_OPTS -jar build/libs/dropwizard-app.jar server config.yml
I have also tried to execute using gradle command
web: gradle run server config.yml
This gives an error
bash: gradle command not found
My gradle tasks are as follows:
task stage(dependsOn: ['clean', 'jar'])
run {
args 'server', 'config.yml'
}
jar {
manifest {
attributes 'Title': 'dropwizard-app', 'Version': version,'Main-Class': mainClassName
}
archiveName 'dropwizard-app'
dependsOn configurations.runtime
from {
configurations.compile.collect {it.isDirectory()? it: zipTree(it)}
}
}
Am I missing out something here?
How do I launch my dropwizard application?
Got it working.
As mentioned above I was trying to execute dropwizard-app.jar
but the jar created on heroku was not of mentioned name, it took the default archive name
starting with build-'some autogenerated value'.jar
So I added a settings.gradle to my project:
rootProject.name = 'dropwizard-app'
Now the jar created was dropwizard-app-1.0.jar
as I have set the version attribute to 1.0 in build.gradle
I used heroku run bash
to check the files on heroku
I wrote a Maven-based deployment guide describing how to deploy a Dropwizard to Heroku which may offer some help. While it doesn't cover gradle, it does point out some common gotchas with the Heroku environment.
For example, your Procfile should look like this:
web java $JAVA_OPTS -Ddw.http.port=$PORT -Ddw.http.adminPort=$PORT -jar path/to/dw/module/target/example-develop-SNAPSHOT.jar server path/to/dw/module/config-heroku.yml

Resources