Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable quarkus:dev to hot-reload resources from non-standard paths #10298

Closed
hacst opened this issue Jun 26, 2020 · 7 comments · Fixed by #17184
Closed

Enable quarkus:dev to hot-reload resources from non-standard paths #10298

hacst opened this issue Jun 26, 2020 · 7 comments · Fixed by #17184
Labels
area/devmode kind/enhancement New feature or request
Milestone

Comments

@hacst
Copy link
Contributor

hacst commented Jun 26, 2020

Description
quarkus:dev should allow hot-reloading of resources specified in the pom using build resources entries (see https://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html).

Example pom.xml snippet:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  ...
  <build>
    <resources>
      <resource> <!-- Standard resource path -->
        <directory>src/main/resources</directory>
      </resource>
      <resource> <!-- Additional custom resource path currently not hot-reloaded by quarkus:dev -->
        <directory>configurations/common</directory>
        <targetPath>${project.build.directory}/configurations/common</targetPath>
      </resource>
    </resources>
    ...
  </build>
...
@hacst hacst added the kind/enhancement New feature or request label Jun 26, 2020
@famod
Copy link
Member

famod commented Jun 26, 2020

Isn't that basically the same as #10234?

@hacst
Copy link
Contributor Author

hacst commented Jun 26, 2020

@famod Not sure I fully understand that issue. From what I can tell everything in /src/main/resources/ is "watched" and automatically copied over to target/classes on change when the next request hits. Other resources aren't (which is the problem I stumbled over). Also specifying additional files to watch without something that defines where they go on change doesn't seem helpful for my use-case. I am not familiar with how quarkus implements this feature so I might be missing something.

The advantage of supporting the normal way additional resources are defined with maven directly instead of having quarkus dev specific parameters would be that you do not have to configure things twice with potential divergence issues down the road.

@38leinaD
Copy link
Contributor

I would also be interested to see this working from a Gradle-perspective; just unsure what is the right way.
The usecase I basically have is that i have a Gradle multi-module-project. One module is the main quarkus app and it depends on a project that contains a plain HTML 5 frontend that should be packaged/served from the Quarkus app.
When running in dev-mode, the frontend can actually be served in modern browser without running a build-step; that's why i would like it if quakus-dev could be told to watch an additional folder from the frontend project; modifications to the frontend would be available immediately without running a full build.
Today, i still need a seperate server/tool that serves the frontend (e.g. browsersync) so i can work an frontend and backend at the same time.
i hope this explaination makes sens.
would be apply to help out in getting this off the ground.

@famod
Copy link
Member

famod commented Jun 28, 2020

@hacst Quarkus is only "watching" a defined set of file names.
See also: https://github.com/quarkusio/quarkus/blob/1.6.0.CR1/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java

I've created PR #10328 to define custom file names to watch, but those must exist in the respective io.quarkus.deployment.dev.DevModeContext.ModuleInfo.getResourcePath().

@hacst
Copy link
Contributor Author

hacst commented Jun 28, 2020

@famod I am unsure but we might be talking about different things here. As I mentioned I'm woefully unaware of quarkus internals an might be using wrong terminology. Using the code-with-quarkus example I can do:

$:code-with-quarkus/src/main/resources$ touch foo.bar
$:code-with-quarkus/src/main/resources$ ls ../../../target/classes/
application.properties  META-INF  org
$:code-with-quarkus/src/main/resources$ curl localhost:8080/hello
hello
$:code-with-quarkus/src/main/resources$ ls ../../../target/classes/
application.properties  foo.bar  META-INF  org

As you can see an arbitrarily named file like foo.bar is picked up/updated by quarkus:dev once I load the page as long as it resides in the src/main/resources directory. Ideally I would like to see quarkus do that for other resources I specify in my pom.xml.

The specific use case I have right now is additional configuration provided by custom ConfigProviders that is read from the cwd in the server. It comes from outside of the src/ folder and isn't supposed to go into the jar. Right now I have to manually run the maven process-resource phase on the side to get the resource plugin to execute instead of quarkus:dev picking it up like the hard-coded resource folder.

@ghost
Copy link

ghost commented Jul 2, 2020

I have another use case for this, it would be nice to also exclude the same folders than are exclude on a production build. For example, I don't need to quarkus dev watches for changes on my node_modules folder, which makes it crash.

2020-07-02 10:02:14,879 ERROR [io.qua.dep.dev.DevModeMain] (main) Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors                                                                                                                                                                                          
        [error]: Build step io.quarkus.deployment.steps.MainClassBuildStep#build threw an exception: org.objectweb.asm.ClassTooLargeException: Class too large: io/quarkus/deployment/steps/ResteasyStandaloneBuildStep$staticInit32                                                                                                                                                         
        at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:599)                                                                                                                                                                                                                                                                                                                   
        at io.quarkus.gizmo.ClassCreator.writeTo(ClassCreator.java:192)                                                                                                                                                                                                                                                                                                                      
        at io.quarkus.gizmo.ClassCreator.close(ClassCreator.java:203)                                                                                                                                                                                                                                                                                                                        
        at io.quarkus.deployment.recording.BytecodeRecorderImpl.writeBytecode(BytecodeRecorderImpl.java:475)                                                                                                                                                                                                                                                                                 
        at io.quarkus.deployment.steps.MainClassBuildStep.writeRecordedBytecode(MainClassBuildStep.java:360)                                                                                                                                                                                                                                                                                 
        at io.quarkus.deployment.steps.MainClassBuildStep.build(MainClassBuildStep.java:141)                                                                                                                                                                                                                                                                                                 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                                                                                                                                                                                                                                       
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)                                                                                                                                                                                                                                                                                                     
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                                                                                                                                                                                                                                                                             
        at java.lang.reflect.Method.invoke(Method.java:498)                                                                                                                                                                                                                                                                                                                                  
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:931)                                                                                                                                                                                                                                                                                                         
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)                                                                                                                                                                                                                                                                                                                        
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)                                                                                                                                                                                                                                                                                  
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)                                                                                                                                                                                                                                                                                                  
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)                                                                                                                                                                                                                                                                                     
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)                                                                                                                                                                                                                                                                                           
        at java.lang.Thread.run(Thread.java:748)                                                                                                                                                                                                                                                                                                                                             
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                             
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:247)                                                                                                                                                                                                                                                                                              
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:130)                                                                                                                                                                                                                                                                         
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:52)                                                                                                                                                                                                                                                                          
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:62)                                                                                                                                                                                                                                                                                             
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:268)                                                                                                                                                                                                                                                                                                
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:40)                                                                                                                                                                                                                                                                                                 
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:129)                                                                                                                                                                                                                                                                                                  
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:82)                                                                                                                                                                                                                                                                                   
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:119)                                                                                                                                                                                                                                                                                                                 
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:56)                                                                                                                                                                                                                                                                                                                   
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors                                                                                                                                                                                                                                                                                                      
        [error]: Build step io.quarkus.deployment.steps.MainClassBuildStep#build threw an exception: org.objectweb.asm.ClassTooLargeException: Class too large: io/quarkus/deployment/steps/ResteasyStandaloneBuildStep$staticInit32                                                                                                                                                         
        at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:599)                                                                                                                                                                                                                                                                                                                   
        at io.quarkus.gizmo.ClassCreator.writeTo(ClassCreator.java:192)                                                                                                                                                                                                                                                                                                                      
        at io.quarkus.gizmo.ClassCreator.close(ClassCreator.java:203)                                                                                                                                                                                                                                                                                                                        
        at io.quarkus.deployment.recording.BytecodeRecorderImpl.writeBytecode(BytecodeRecorderImpl.java:475)                                                                                                                                                                                                                                                                                 
        at io.quarkus.deployment.steps.MainClassBuildStep.writeRecordedBytecode(MainClassBuildStep.java:360)                                                                                                                                                                                                                                                                                 
        at io.quarkus.deployment.steps.MainClassBuildStep.build(MainClassBuildStep.java:141)                                                                                                                                                                                                                                                                                                 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                                                                                                                                                                                                                                       
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)                                                                                                                                                                                                                                                                                                     
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                                                                                                                                                                                                                                                                             
        at java.lang.reflect.Method.invoke(Method.java:498)                                                                                                                                                                                                                                                                                                                                  
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:931)                                                                                                                                                                                                                                                                                                         
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)                                                                                                                                                                                                                                                                                                                        
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)                                                                                                                                                                                                                                                                                  
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)                                                                                                                                                                                                                                                                                                  
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)                                                                                                                                                                                                                                                                                     
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)                                                                                                                                                                                                                                                                                           
        at java.lang.Thread.run(Thread.java:748)                                                                                                                                                                                                                                                                                                                                             
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                             
        at io.quarkus.builder.Execution.run(Execution.java:115)                                                                                                                                                                                                                                                                                                                              
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)                                                                                                                                                                                                                                                                                                   
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:156)                                                                                                                                                                                                                                                                                                             
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:245)                                                                                                                                                                                                                                                                                              
        ... 9 more                                                                                                                                                                                                                                                                                                                                                                           
Caused by: org.objectweb.asm.ClassTooLargeException: Class too large: io/quarkus/deployment/steps/ResteasyStandaloneBuildStep$staticInit32                                                                                                                                                                                                                                                   
        at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:599)                                                                                                                                                                                                                                                                                                                   
        at io.quarkus.gizmo.ClassCreator.writeTo(ClassCreator.java:192)                                                                                                                                                                                                                                                                                                                      
        at io.quarkus.gizmo.ClassCreator.close(ClassCreator.java:203)                                                                                                                                                                                                                                                                                                                        
        at io.quarkus.deployment.recording.BytecodeRecorderImpl.writeBytecode(BytecodeRecorderImpl.java:475)
        at io.quarkus.deployment.steps.MainClassBuildStep.writeRecordedBytecode(MainClassBuildStep.java:360)
        at io.quarkus.deployment.steps.MainClassBuildStep.build(MainClassBuildStep.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:931)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.lang.Thread.run(Thread.java:748)
        at org.jboss.threads.JBossThread.run(JBossThread.java:479)

@essobedo
Copy link
Contributor

A potential PR for this #17184

@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devmode kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants