Processor fails to locate the template html file when placed next to the template class
Closed this issue · 7 comments
if the template file is moved from the resources folder and placed next to the template class the processor will fail to locate the template file and application wont compile.
intellij ide will not copy the resource until a manual rebuild is executed while the application is running
having the template in the resources folder, this will produce a stale copy of the template file in the target folder.
meanwhile the html template is meant only for gwt compilation, tbroyer plugin does not copy these resources from the sources folder, which prevent the creation of a stale copy anyway, and to be aligned with tbroyer setup we need the templates to be in the sources folder not the resources folder.
Thanks
AFAICT the annotation processing API only supports reading resources from the class path: javax.annotation.processing.Filer.getResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName)
using javax.tools.StandardLocation.CLASS_PATH
as location.
I've tried different locations w/o success. As a workaround you can place your templates into src/main/java
and configure HTML files as resources:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.html</include>
</includes>
</resource>
</resources>
</build>
with this elemento can locate the file and generate the template, but yet this does not solve the stale copy of the file issue, since this does exactly what putting the file into the resources folder, it is still copying the file to the target folder, and intellij wont update the file after the edit until the rebuild project is triggered.
the actual solution for this is to detect the file without copying to the target folder.
i might help in this one and work on it later, and if i got a solution i will make PR. would you accept that?
Great. I'll leave this open then.
But this is totally NOT an elemento problem, it's either a maven or an IntelliJ issue not copying resources to the target folder (expected to be in the classpath). OTOH, IntelliJ updates the resources correctly when you "Build Project" which is the expected behavior for IntelliJ, and eclipse compiles constantly so it will probably copy the resource constantly too (not checked).
I agree. We should not try to add "magic" into Elemento to workaround maven / IntelliJ issues or to support non standard builds.
TBH, i prefer the template to live in the resources folder, and also with the current issue with APT and resources even if we put the template in the sources folder instead of the resources folder we will still need to fire the apt processors, which means we are not really solving the issue.