Closed kadel closed 1 year ago
After some tests, I can see that files are correctly synced to the container, which are detected, and the rebuild is executed.
tools: [INFO] Scanning for projects...
tools: [INFO]
tools: [INFO] --------------------------< com.example:demo >--------------------------
tools: [INFO] Building demo 0.0.1-SNAPSHOT
tools: [INFO] --------------------------------[ jar ]---------------------------------
tools: [INFO]
tools: [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
tools: [INFO] Deleting /projects/target
tools: [INFO]
tools: [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
tools: [INFO] Using 'UTF-8' encoding to copy filtered resources.
tools: [INFO] Copying 1 resource
tools: [INFO] Copying 0 resource
tools: [INFO]
tools: [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo ---
tools: [INFO] Changes detected - recompiling the module!
tools: [INFO] Compiling 1 source file to /projects/target/classes
tools: [INFO]
tools: [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ demo ---
tools: [INFO] Not copying test resources
tools: [INFO]
tools: [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo ---
tools: [INFO] Not compiling test sources
tools: [INFO]
tools: [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo ---
tools: [INFO] Tests are skipped.
tools: [INFO]
tools: [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo ---
tools: [INFO] Building jar: /projects/target/demo-0.0.1-SNAPSHOT.jar
tools: [INFO]
tools: [INFO] --- spring-boot-maven-plugin:2.3.5.RELEASE:repackage (repackage) @ demo ---
tools: [INFO] Replacing main artifact with repackaged archive
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] BUILD SUCCESS
tools: [INFO] ------------------------------------------------------------------------
tools: [INFO] Total time: 1.773 s
tools: [INFO] Finished at: 2023-03-22T07:49:49Z
tools: [INFO] ------------------------------------------------------------------------
Adding this dependency to the project fixes the issue:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
Separate issue: make the run command hotReloadCapable
in the Devfile stack
I've tried adding spring-boot-devtools and it doesn't help
I had tested only on podman (odo dev --platform podman).
I can reproduce it on podman, but not on cluster.
After some research, I can see that the difference between both platforms is that, when you mark the Run command as hotReloadCapable, the Build command is executed after sources changes in Podman, but not on the cluster.
@kadel could you please double-check that you can reproduce on Podman?
As I understand:
springboot reload is done in 2 stages:
The first stage is done by the Build command, after the sources are synced, and the second stage is done by mvn spring-boot:run
(with spring-boot-devtools) when a class changes.
On the other hand, node reload works only with the command npm start
; the Build command does not need to be ran again after each source change.
I've created a related issue regarding running the build command when Run is hotReloadCapable: https://github.com/redhat-developer/odo/issues/6695
After some tests, I can see that files are correctly synced to the container, which are detected, and the rebuild is executed.
tools: [INFO] Scanning for projects... tools: [INFO] tools: [INFO] --------------------------< com.example:demo >-------------------------- tools: [INFO] Building demo 0.0.1-SNAPSHOT tools: [INFO] --------------------------------[ jar ]--------------------------------- tools: [INFO] tools: [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo --- tools: [INFO] Deleting /projects/target tools: [INFO] tools: [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo --- tools: [INFO] Using 'UTF-8' encoding to copy filtered resources. tools: [INFO] Copying 1 resource tools: [INFO] Copying 0 resource tools: [INFO] tools: [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- tools: [INFO] Changes detected - recompiling the module! tools: [INFO] Compiling 1 source file to /projects/target/classes tools: [INFO] tools: [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ demo --- tools: [INFO] Not copying test resources tools: [INFO] tools: [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo --- tools: [INFO] Not compiling test sources tools: [INFO] tools: [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo --- tools: [INFO] Tests are skipped. tools: [INFO] tools: [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo --- tools: [INFO] Building jar: /projects/target/demo-0.0.1-SNAPSHOT.jar tools: [INFO] tools: [INFO] --- spring-boot-maven-plugin:2.3.5.RELEASE:repackage (repackage) @ demo --- tools: [INFO] Replacing main artifact with repackaged archive tools: [INFO] ------------------------------------------------------------------------ tools: [INFO] BUILD SUCCESS tools: [INFO] ------------------------------------------------------------------------ tools: [INFO] Total time: 1.773 s tools: [INFO] Finished at: 2023-03-22T07:49:49Z tools: [INFO] ------------------------------------------------------------------------
Adding this dependency to the project fixes the issue:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
Fixed when adding this dependency with latest odo version
/close
@feloy: Closing this issue.
/kind bug /priority high
odo init --name java-springboot-starter --devfile java-springboot --starter springbootproject
hotReloadCapable: true
torun
exec
commandodo dev
mvn spring-boot:run
(the same command devfile uses) it works correctly.When trying similar steps with nodejs, it works as expected.
odo init --name test --devfile nodejs --starter nodejs-starter
hotReloadCapable: true
torun
exec
commandnodemon
to projectnpm install --save-dev nodemon
package.json
and usenodemon server.js
asstart
scriptodo dev
Because it works in nodejs but doesn't with springboot it looks like this is specific to springboot container.