wildfly-extras / wildfly-jar-maven-plugin

WildFly Bootable JAR
https://docs.wildfly.org/bootablejar/
Apache License 2.0
56 stars 40 forks source link

Partial deployment for resource files in e.g. JSF Project (dev-watch) #326

Closed kuhhpid closed 1 year ago

kuhhpid commented 1 year ago

Currently any changes to a xhtml file under src/main/webapp triggers a complete redeployment of the application. This is not as fast like in a normal Wildfly Deployment with IDE support. Changes are nearly immediately viewable.

mbrembilla commented 1 year ago

+1

RiccardoSioli commented 1 year ago

+1

jamezp commented 1 year ago

This could potentially be solved via #330. It has not been implemented yet, but seems reasonable.

jfdenise commented 1 year ago

The watch goal is actually ready to be evolved with fine grain support. I removed the need for a re-deploy for xhtml, html and jsp files in https://github.com/wildfly-extras/wildfly-jar-maven-plugin/pull/331 @kuhhpid @RiccardoSioli @mbrembilla in case you want to give it a try prior we release a new bootable JAR release. Thank-you.

kuhhpid commented 1 year ago

The watch goal is actually ready to be evolved with fine grain support. I removed the need for a re-deploy for xhtml, html and jsp files in #331 @kuhhpid @RiccardoSioli @mbrembilla in case you want to give it a try prior we release a new bootable JAR release. Thank-you.

Thank you, great news! I will give it a try. I looked in your commit and found NO_DEPLOYMENT_WEB_FILE_EXTENSIONS only mention xhtml, html and jsp. What about css files or would it be possible to extend this list as a property in the pom.xml?

jfdenise commented 1 year ago

@kuhhpid , good suggestion will add css and open the door to more extensions

jfdenise commented 1 year ago

@kuhhpid done in the opened PR.

kuhhpid commented 1 year ago

@kuhhpid done in the opened PR.

So I hope I checkout and installed your version correctly but I think so. Now this is what I see if I changed the index.xhtml:

[DEBUG] Deploy ROOT.war done [DEBUG] Deployment ROOT.war is up

[DEBUG] [WATCH] copy /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/src/main/webapp/index.xhtml~ to /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/target/deployments/ROOT.war/index.xhtml~

[DEBUG] [WATCH] copy /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/src/main/webapp/index.xhtml~ to /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/target/deployments/ROOT.war/index.xhtml~

[DEBUG] [WATCH] copy /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/src/main/webapp/index.xhtml to /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/target/deployments/ROOT.war/index.xhtml [DEBUG] [WATCH] Simple copy for file index.xhtml

[DEBUG] [WATCH] copy /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/src/main/webapp/index.xhtml to /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/target/deployments/ROOT.war/index.xhtml [DEBUG] [WATCH] Simple copy for file index.xhtml

[DEBUG] [WATCH] Delete file /home/alexander/IdeaProjects/webgate/tools/find-duplicate-names/target/deployments/ROOT.war/index.xhtml~ [DEBUG] [WATCH] updating application [DEBUG] [WATCH] re-deploy [DEBUG] Undeploy ROOT.war

I am wondering why I not see any of the debug output of DevWatchContext. <-- Sry my fault I overlooked it

kuhhpid commented 1 year ago

Okay, it works but there is an issue with hidden files and tmp files from editors. I tested now with Intellij and gedit. Intellij creates files with ~ extensions and gedit creates hidden files. Both triggers the normal deploy process. Moreover I can confirm that the mechanism works if I change the file by copy it to the directory so that there is no other file created nor changed.

jfdenise commented 1 year ago

@kuhhpid , thank-you. So should we ignore some files? Could you list exactly what are the files/directories you see created when you edit a file from your IDE.

jfdenise commented 1 year ago

@kuhhpid , I am thinking at allowing to set file patterns to ignore some events. You would have to configure it according to your IDE. So could be: ".~ and .., something like that in your case.

jfdenise commented 1 year ago

@kuhhpid , I updated the PR, you should call the goal with -Dwildfly.bootable.ignore.patterns=".~ \.." Let me know if you are fine with such changes.

jfdenise commented 1 year ago

The Issue to track ignoring file is: https://github.com/wildfly-extras/wildfly-jar-maven-plugin/issues/333

kuhhpid commented 1 year ago

@kuhhpid , I am thinking at allowing to set file patterns to ignore some events. You would have to configure it according to your IDE. So could be: ".~ and .., something like that in your case.

I tried something like that:

if(Files.isHidden(path) || fileName.endsWith("~")) { ctx.debug("[WATCH] Ignore tmp file " + fileName); return false; }

But I recognized that the index.xhtml~ is deleted by the IDE immediately and we got an ENTRY_DELETED event. Therefore it seems that ignoring should occur earlier!?

jfdenise commented 1 year ago

@kuhhpid , in the updated PR I am ignoring in the watcher. So as soon as the event is received. Seems to work well. https://github.com/jfdenise/wildfly-jar-maven-plugin/blob/jsf-fixes/plugin/src/main/java/org/wildfly/plugins/bootablejar/maven/goals/DevWatchBootableJarMojo.java#L704

jfdenise commented 1 year ago

@kuhhpid I updated the PR with builtin support to ignore hidden and files ending with ~, this seems legitimate. I don't see use-cases to not ignore these files.

kuhhpid commented 1 year ago

You are great and fast :-)

I thought it would be an idea with the patterns but you already implemented it. I can confirm that this works like a charm now.

Thank you a lot!

jfdenise commented 1 year ago

@kuhhpid , thank-you. You come with the real life requirements. That is the greatest part :-) As soon as I have merged the 2 PR in the pipe, I will release 8.1.0.Final.

kuhhpid commented 1 year ago

@jfdenise With this great enhancement I will start new small modules with this setup and maybe some day only because we can: switch from Wildfly to Wildfly Bootable with our main JSF Projekt ;-)

tp0ck3r commented 1 year ago

Many thanks for this improvement, works for me as well! Tested on MacOS with Visual Studio Code. Great work, lifesaver patch! :)