FreeMarker "hot deploy" of templates ?

Hi,

I've been struggling with this in IntelliJ for .. a whole bunch of versions, always hoping the next would solve it, and it's hindered my ability to convert Eclipsers to a better IDE:

When I'm running a webapp in a local Tomcat, I haven't found any way to get my templates hot swapped.

Saving or "compiling" doesn't seem to do anything. Intellij claims it has « packaged » a .ftl file when I « compile » it. Fine, but WHERE ? Not in my output folder anyway.

I've tried disabling all kinds of caches in FreeMarker, but to no avail.

So my first question is: can anyone get this to work in their app, when using a ClassTemplateLoader ? (it works when using a FileTemplateLoader, but that requires too many changes in the application and its configuration to be a practical development environment) ... and if so, second question: how ? :-D


Cheers, and thanks for any tip !

7 comments
Comment actions Permalink

After debugging through FreeMarker a little, I can confirm that disabling the caches etc works as expected, and it looks like it's loading my .ftl from /path/to/my/module/target/classes/path/to/my/template.ftl - which is the expected path indeed, BUT it seems like IntelliJ did NOT copy the "compiled" source over there.



My understanding of the configuration is that resources matching the configured pattern *should* be copied to the output directory. (as per http://www.jetbrains.com/idea/webhelp/compiler.html), and my pattern is "?*.properties;?*.xml;?*.gif;?*.png;?*.jpeg;?*.jpg;?*.html;?*.dtd;?*.tld;?*.ftl;?*.javaz"... still, the .ftl I see in my output folder is the one I had before modifying my source.

What am I missing ?
0
Comment actions Permalink

ok, I've enabled debug logs in IntelliJ, and it looks to me like a bug ? My .ftl in a module. Yet, it is packaged into another module, which happens to be a webapp.

If I open a new project with just that module, I see that the file is correctly copied to the module's target folder. BUT, I also see in the logs that something else happens. The "compiler" is used. And indeed, the context menus reflect that. In this project, I have the option to "compile" this file, while in the former project, I can only "package" it. What gives ?

0
Comment actions Permalink

I recreated my project, which is a bunch of maven modules, including two reactors (of ~2 modules each) and another 2 "simple" maven modules; all modules are dependencies of the webapp, which is a module of the 1st reactor. I had the "compile" option, until I "Force reimport of all Maven projects" - at that point the "compile" action was grayed out for my .ftl, and replaced by "package file".

"Make module" does the trick though, but it might not be the best option for large-ish modules.

Message was edited by: Grégory Joseph - added precisions about project

0
Comment actions Permalink

Looks like its a bug. 'Package File' and 'Compile File' are different action but they use the same shortcut (CtrlShiftF9), so if a file can be
packaged (i.e. it is included in an artifact) 'Compile File' action is disabled. Perhaps in such cases we need to copy file to all configured output
directories.

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Yeah, in my example I see two problems:
* that this .ftl is "compilable" at all - I don't see why it should be considered anything else than a resource, at any point.
* that when it is considered a resource (i.e the "package" action is enabled) it is only copied to the webapp's output (I can see how that's helpful, but I don't even know why that happens, i.e what part of the config says this should happen), and not to it's own module's output. (curious to see how it'd be behave if I had two webapps in my project)

What can I do to help this bug get fixed ?

0
Comment actions Permalink

Copying of resource files to output folder is called 'compilation' in IDEA for historical reasons.

Regarding the problem two: I know how to fix it but it isn't simple so please create an issue about that in our tracker
(http://youtrack.jetbrains.net/issues/IDEA).

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Hi Nikolai,

I finally got around to report the issue: http://youtrack.jetbrains.net/issue/IDEA-73815

Regarding the difference between "compile" and "package", the debug logs indicated vastly different behaviors (I don't remember what happened in which of the 2 cases, but in one the logs seemed to indicate that the operation was indeed carried by "Compiler" type of components, while in the other, "Resource handlers" or something similar, were involved) which kind of matches the fact that the available option was also different, even though the end result was expected to be the same (and wasn't)

Thanks again ! Hoping to see this fixed soon, should help converting a few Eclipsers from my office !

0

Please sign in to leave a comment.