1.1 --- a/tools/JavaServlet/webstack_java_build.py Fri Oct 05 22:30:40 2007 +0000
1.2 +++ b/tools/JavaServlet/webstack_java_build.py Fri Oct 05 22:32:08 2007 +0000
1.3 @@ -75,14 +75,17 @@
1.4 def get_appname(handler):
1.5 return os.path.split(os.path.splitext(handler)[0])[1]
1.6
1.7 -def make_app(handler, webstack_home, jython_cachedir, web_xml_template_name, packages):
1.8 +def make_app(handler, root_resources, webstack_tools_home, webstack_package_home,
1.9 + jython_cachedir, web_xml_template_name, packages, libraries):
1.10
1.11 """
1.12 - Make the application directory from the given 'handler', the 'webstack_home'
1.13 - where the WebStack package can be found, the 'jython_cachedir' where Jython
1.14 - classes are cached, the deployment descriptor with the given
1.15 - 'web_xml_template_name', and the specified 'packages' (locations of
1.16 - application packages).
1.17 + Make the application directory from the given 'handler' and
1.18 + 'root_resources', the 'webstack_tools_home' where the tools directory is
1.19 + found, the 'webstack_package_home' where the WebStack package is found, the
1.20 + 'jython_cachedir' where Jython classes are cached, the deployment descriptor
1.21 + with the given 'web_xml_template_name', and the specified 'packages'
1.22 + (locations of application packages) and 'libraries' (locations of required
1.23 + library files).
1.24 """
1.25
1.26 appname = get_appname(handler)
1.27 @@ -101,12 +104,12 @@
1.28
1.29 # Copy the special PyServlet classes.
1.30
1.31 - copy_directory(os.path.join(webstack_home, "tools", "JavaServlet", "classes"),
1.32 + copy_directory(os.path.join(webstack_tools_home, "tools", "JavaServlet", "classes"),
1.33 os.path.join(appname, "WEB-INF"))
1.34
1.35 # Copy the WebStack package.
1.36
1.37 - copy_directory(os.path.join(webstack_home, "WebStack"),
1.38 + copy_directory(os.path.join(webstack_package_home, "WebStack"),
1.39 os.path.join(appname, "WEB-INF", "jython"))
1.40
1.41 # Copy the application packages.
1.42 @@ -114,11 +117,25 @@
1.43 for appdir in packages:
1.44 copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython"))
1.45
1.46 + # Copy the libraries.
1.47 +
1.48 + if libraries:
1.49 + for library in libraries:
1.50 + library_dir, library_name = os.path.split(library)
1.51 + library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
1.52 + copy_file(library, library_dest)
1.53 +
1.54 # Copy the handler.
1.55
1.56 handler_filename = os.path.split(handler)[1]
1.57 copy_file(handler, os.path.join(appname, handler_filename))
1.58
1.59 + # Copy the root resources.
1.60 +
1.61 + for root_resource in root_resources:
1.62 + root_resource_filename = os.path.split(root_resource)[1]
1.63 + copy_file(root_resource, os.path.join(appname, root_resource_filename))
1.64 +
1.65 # Find additional Jython paths.
1.66
1.67 jython_paths = []
1.68 @@ -135,7 +152,7 @@
1.69
1.70 # Configure the deployment descriptor.
1.71
1.72 - f = open(os.path.join(webstack_home, "tools", "JavaServlet", web_xml_template_name))
1.73 + f = open(os.path.join(webstack_tools_home, "tools", "JavaServlet", web_xml_template_name))
1.74 web_xml = f.read()
1.75 f.close()
1.76 web_xml = web_xml % (jython_home, jython_path, jython_cachedir, handler_filename)
1.77 @@ -148,15 +165,32 @@
1.78
1.79 if __name__ == "__main__":
1.80 import sys
1.81 - if len(sys.argv) < 5:
1.82 + if len(sys.argv) < 8:
1.83 + print "Syntax:"
1.84 + print
1.85 + print "jython webstack_java_build.py <handler> [ <resource>... ] \\"
1.86 + print " --webstack <home> <tools> <cachedir> <descriptor> <app> \\"
1.87 + print " [ --libraries <library>... ]"
1.88 + print
1.89 print "Please specify..."
1.90 print
1.91 print "The location of the application handler. For example:"
1.92 print
1.93 print " .../WebStack-x.y/examples/JavaServlet/SimpleApp.py"
1.94 print
1.95 - print "The location of the WebStack package distribution or where WebStack"
1.96 - print "documentation and extras have been installed. For example:"
1.97 + print "Any other top-level resources, such as JSP templates. For example:"
1.98 + print
1.99 + print " .../WebStack-x.y/examples/JavaServlet/test.jsp"
1.100 + print
1.101 + print "After the --webstack marker, the details of the WebStack distribution"
1.102 + print "are required, such as..."
1.103 + print
1.104 + print "The location of the WebStack package distribution. For example:"
1.105 + print
1.106 + print " .../WebStack-x.y"
1.107 + print " /usr/lib/python2.4/site-packages"
1.108 + print
1.109 + print "The location of the WebStack tools have been installed. For example:"
1.110 print
1.111 print " .../WebStack-x.y"
1.112 print " /usr/share/doc/python2.4-webstack"
1.113 @@ -168,6 +202,8 @@
1.114 print "The name of the deployment descriptor template. For example:"
1.115 print
1.116 print " web.xml"
1.117 + print " jsp-web.xml"
1.118 + print " protected-web.xml"
1.119 print
1.120 print "The location of the application packages. For example:"
1.121 print
1.122 @@ -178,28 +214,36 @@
1.123 print
1.124 print " $CATALINA_HOME/common/lib/activation.jar"
1.125 print " $CATALINA_HOME/common/lib/mail.jar"
1.126 + print
1.127 + print "With Apache Tomcat 4.1.x, activation.jar and mail.jar are usually"
1.128 + print "required."
1.129 sys.exit(1)
1.130
1.131 - handler, webstack_home, jython_cachedir, web_xml = sys.argv[1:5]
1.132 + webstack_index = sys.argv.index("--webstack")
1.133
1.134 try:
1.135 libraries_index = sys.argv.index("--libraries")
1.136 - packages = sys.argv[5:libraries_index]
1.137 - libraries = sys.argv[libraries_index+1:]
1.138 except ValueError:
1.139 - packages = sys.argv[5:]
1.140 - libraries = []
1.141 + libraries_index = len(sys.argv)
1.142 +
1.143 + print "Handler, root resources are..."
1.144 + handler, root_resources = sys.argv[1], sys.argv[2:webstack_index]
1.145 + print handler, root_resources
1.146 +
1.147 + print "WebStack distribution details are..."
1.148 + webstack_package_home, webstack_tools_home, jython_cachedir, web_xml = sys.argv[webstack_index+1:webstack_index+5]
1.149 + print webstack_package_home, webstack_tools_home
1.150 +
1.151 + print "Packages..."
1.152 + packages = sys.argv[webstack_index+5:libraries_index]
1.153 + print packages
1.154 +
1.155 + print "Libraries..."
1.156 + libraries = sys.argv[libraries_index+1:]
1.157 + print libraries
1.158
1.159 print "Making application directory..."
1.160 - make_app(handler, webstack_home, jython_cachedir, web_xml, packages)
1.161 -
1.162 - if libraries:
1.163 - print "Copying additional libraries..."
1.164 - appname = get_appname(sys.argv[1])
1.165 - for library in libraries:
1.166 - library_dir, library_name = os.path.split(library)
1.167 - library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
1.168 - copy_file(library, library_dest)
1.169 + make_app(handler, root_resources, webstack_package_home, webstack_tools_home, jython_cachedir, web_xml, packages, libraries)
1.170
1.171 print "Now copy or move the application directory to your servlet container."
1.172