There was an xslt file written by at some point. I just created the wiki
page http://wiki.apache.org/jakarta-tapestry/Tapestry3ToTapestry4
pointing to it and I linked this page from the main page (in the
Tapestry 4 section).
JPB
James Carman wrote:
Wouldn't this be better as an XSLT file? Just a thought.
-----Original Message-----
From: Paul Fisher [mailto:[EMAIL PROTECTED]
Sent: Monday, April 10, 2006 2:07 AM
To: [email protected]
Subject: Magic Tapestry Upgrade Ant Script
I decided to try to upgrade our Tapestry 3.03 Application to Tapestry
4.01 this weekend, and in the process wrote up a simple Ant Task that
converts the .page and .jwc files to be Tapestry 4 compliant. The
task uses Regex Replace and group substitution to somewhat
intelligently find the changed items in the XML files and replace
them accordingly. It should also figure out whether a binding
expression starts with listeners, beans, or is a static-binding and
replace that with the appropriate binding expression using either the
literal, listener, or bean prefix.
I whipped this up fairly quickly, so please use this at your own
risk. I would highly recommend checking in all your current work, or
doing a back-up before giving this task a whirl. By default, it
attempts to change all .page and .jwc files that exist under any
subdirectory from the ${web.root} directory : you'll need to specify
web.root as your root web directory to get this to work.
Anyway, here it is. If you have any suggestions, please let me know.
I really am thinking this could be a good starting point that might
prove helpful to those wanting to upgrade to Tapestry 4, but don't
want to spend a lot of time doing it (of course, the existing 3.0 xml
files should still work in 4, but if you want to take advantage of 4
features, you'll need to upgrade the xml files at some point!).
Ant Task (place in your build script):
<!--Start -->
<target name="upgradeTapestry4">
<replaceregexp byline="true">
<regexp pattern="(binding name="\w+")
expression="listeners\."/>
<substitution expression="\1 value="listener:"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="(binding name="\w+")
expression="beans\."/>
<substitution expression="\1 value="bean:"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="(binding name="\w+")
expression=""/>
<substitution expression="\1 value="ognl:"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="persistent="yes""/>
<substitution expression="persist="session""/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="Tapestry Specification 3.0//EN"/>
<substitution expression="Tapestry Specification 4.0//EN"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="tapestry/dtd/Tapestry_3_0.dtd"/>
<substitution expression="tapestry/dtd/Tapestry_4_0.dtd"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="(static-binding name=)("\w+")
(value=")"/>
<substitution expression="binding name=\2 \3literal:"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="<set-property (name="\w+")
(expression=)"/>
<substitution expression="<set \1 value="/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="<context-asset"/>
<substitution expression="<asset"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="<property-specification (name="\w
+") (type=".*?")(.*?>)"/>
<substitution expression="<property \1 \3"/>
<fileset dir="${web.root}">
<include name="**/*.page" />
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="<parameter (name="\w+")
(direction="\w") (type="\w")(.*?>)"/>
<substitution expression="<parameter \1 \4"/>
<fileset dir="${web.root}">
<include name="**/*.jwc" />
</fileset>
</replaceregexp>
</target>
<!-- Finish -->
Please let me know your thoughts!
Thanks,
Paul
Paul Fisher
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]