Closed olivierperez closed 8 years ago
I can't accept this PR as-is, because it will break backwards compatibility for T5.3 projects. And this matters because T5.4 wasn't even released yet.
My idea of supporting multiple tapestry versions was by creating separate template files by appending tapestry version suffix to them.
For example for T5.4 this snippet.tml
could be named like snippet-5.4.tml
.
Or maybe even better update the snippet.tml
as you proposed (latest version without suffix) and create new snippet-5.3.tml
.
Then in the NewFileWizardAction you could build filename valid for your current project, and fallback to filename without suffix if the file doesn't exist.
Two problems with this approach:
TapestryContext
that only exposes related files of a page/component class in context.
But you can get current TapestryProject
of the workspace via Activator#getTapestryProject(window)
, just expect it could be null.TapestryProject
, so this needs to be implemented first.Here's how you can get a tapestry version string.
Having an instance of TapestryProject
you may get a list of its modules. One of the modules should return true
for TapestryModule#isTapestryCoreModule()
. This is the tapestry core module that should be from tapestry-core-x.y.x.jar
. This JAR should contain META-INF/gradle/org.apache.tapestry/tapestry-core/project.properties
file that holds tapestry version number:
I haven't tried this, but I hope that it would be possible to reuse JarTapestryModule#findClasspathFileCaseInsensitive()
to get that project.properties
file.
So my idea is you can get this version string and expose it via new TapestryProject#getTapestryVersion()
. I think returning null
should be fine here if you couldn't obtain version number.
Sorry, I made this change for my team and we use Tapestry 5.4 only. It's the first time I code on an eclipse plugin, thanks for the help, I'll try to do something better. Stay tuned.
Please check this with new version -- 2.5.0
Thank's we'll try the new version tomorow ;-)
It got even better in the latest release, see: https://github.com/anjlab/eclipse-tapestry5-plugin#edit-templates
tapestry_5_3.xsd => tapestry_5_4.xsd