You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

precompile-jsp.build.xml 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!-- @author Wes Isberg -->
  2. <!-- START-SAMPLE j2ee-tomcat4-precompileJsp Precompile JSP's for Tomcat 4.x using AspectJ -->
  3. <project name="Precompile Tomcat JSPs" default="all" basedir=".">
  4. <target name="all" depends="jspc,compile"/>
  5. <target name="info">
  6. <echo>
  7. This Ant script precompiles deployed .jsp files in Tomcat
  8. using AspectJ 1.1.
  9. Usage:
  10. {ant} -f {this-script} \
  11. -Dtomcat.home=/home/tomcat \
  12. -Dwebapp.name=launchWeb \
  13. -DASPECTJ_HOME=/dev/tools/aspectj-1.1.0
  14. This defines the web application deployment $${webapp.dir} as
  15. $${tomcat.home}/webapps/$${webapp.name}
  16. , generates the Java source files to
  17. $${webapp.dir}/WEB-INF/src
  18. , uses iajc (AspectJ) to compile them to
  19. $${webapp.dir}/WEB-INF/classes,
  20. , and creates the mappings
  21. $${webapp.dir}/WEB-INF/generated_web.xml,
  22. which must be manually inserted into
  23. $${webapp.dir}/WEB-INF/generated_web.xml,
  24. at which point the web application can be reloaded.
  25. This assumes that aspectjrt.jar is already deployed in
  26. any of places on the Tomcat application classpath
  27. (the application, shared, or common classpath).
  28. If ASPECTJ_HOME is not defined, it assumes that
  29. aspectjtools.jar is in
  30. ${CATALINA_HOME}/common/lib
  31. </echo>
  32. </target>
  33. <target name="init">
  34. <!-- declare these two on command-line -->
  35. <property name="webapp.name"
  36. value="launchWeb"/>
  37. <property name="tomcat.home"
  38. location="i:/home/tomcat"/>
  39. <property name="webapp.path"
  40. location="${tomcat.home}/webapps/${webapp.name}"/>
  41. <property name="webapp.src.dir"
  42. location="${webapp.path}/WEB-INF/src"/>
  43. <property name="ASPECTJ_HOME"
  44. location="${tomcat.home}/common"/>
  45. </target>
  46. <target name="jspc" depends="init">
  47. <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
  48. <classpath id="jspc.classpath">
  49. <pathelement location="${java.home}/../lib/tools.jar"/>
  50. <fileset dir="${tomcat.home}/server/lib">
  51. <include name="*.jar"/>
  52. </fileset>
  53. <fileset dir="${tomcat.home}/common/lib">
  54. <include name="*.jar"/>
  55. </fileset>
  56. </classpath>
  57. </taskdef>
  58. <mkdir dir="${webapp.src.dir}"/>
  59. <jasper2
  60. validateXml="true"
  61. uriroot="${webapp.path}"
  62. webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
  63. outputDir="${webapp.src.dir}" />
  64. </target>
  65. <target name="compile" depends="init">
  66. <mkdir dir="${webapp.path}/WEB-INF/classes"/>
  67. <mkdir dir="${webapp.path}/WEB-INF/lib"/>
  68. <path id="iajc.classpath">
  69. <fileset dir="${ASPECTJ_HOME}/lib">
  70. <include name="aspectjtools.jar"/>
  71. </fileset>
  72. </path>
  73. <taskdef
  74. resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
  75. <classpath refid="iajc.classpath"/>
  76. </taskdef>
  77. <!-- forking compile so it runs in Eclipse -->
  78. <iajc destdir="${webapp.path}/WEB-INF/classes"
  79. sourceroots="${webapp.src.dir}"
  80. debug="on"
  81. verbose="true"
  82. fork="true"
  83. forkclasspathRef="iajc.classpath"
  84. failonerror="true"
  85. >
  86. <classpath>
  87. <pathelement location="${webapp.path}/WEB-INF/classes"/>
  88. <fileset dir="${webapp.path}/WEB-INF/lib">
  89. <include name="*.jar"/>
  90. </fileset>
  91. <pathelement location="${tomcat.home}/common/classes"/>
  92. <fileset dir="${tomcat.home}/common/lib">
  93. <include name="*.jar"/>
  94. </fileset>
  95. <pathelement location="${tomcat.home}/shared/classes"/>
  96. <fileset dir="${tomcat.home}/shared/lib">
  97. <include name="*.jar"/>
  98. </fileset>
  99. </classpath>
  100. </iajc>
  101. </target>
  102. </project>
  103. <!-- END-SAMPLE j2ee-tomcat4-precompileJsp -->