2.1 --- a/tools/JavaServlet/webstack_java_build.py Fri Oct 05 22:30:40 2007 +0000
2.2 +++ b/tools/JavaServlet/webstack_java_build.py Fri Oct 05 22:32:08 2007 +0000
2.3 @@ -75,14 +75,17 @@
2.4 def get_appname(handler):
2.5 return os.path.split(os.path.splitext(handler)[0])[1]
2.6
2.7 -def make_app(handler, webstack_home, jython_cachedir, web_xml_template_name, packages):
2.8 +def make_app(handler, root_resources, webstack_tools_home, webstack_package_home,
2.9 + jython_cachedir, web_xml_template_name, packages, libraries):
2.10
2.11 """
2.12 - Make the application directory from the given 'handler', the 'webstack_home'
2.13 - where the WebStack package can be found, the 'jython_cachedir' where Jython
2.14 - classes are cached, the deployment descriptor with the given
2.15 - 'web_xml_template_name', and the specified 'packages' (locations of
2.16 - application packages).
2.17 + Make the application directory from the given 'handler' and
2.18 + 'root_resources', the 'webstack_tools_home' where the tools directory is
2.19 + found, the 'webstack_package_home' where the WebStack package is found, the
2.20 + 'jython_cachedir' where Jython classes are cached, the deployment descriptor
2.21 + with the given 'web_xml_template_name', and the specified 'packages'
2.22 + (locations of application packages) and 'libraries' (locations of required
2.23 + library files).
2.24 """
2.25
2.26 appname = get_appname(handler)
2.27 @@ -101,12 +104,12 @@
2.28
2.29 # Copy the special PyServlet classes.
2.30
2.31 - copy_directory(os.path.join(webstack_home, "tools", "JavaServlet", "classes"),
2.32 + copy_directory(os.path.join(webstack_tools_home, "tools", "JavaServlet", "classes"),
2.33 os.path.join(appname, "WEB-INF"))
2.34
2.35 # Copy the WebStack package.
2.36
2.37 - copy_directory(os.path.join(webstack_home, "WebStack"),
2.38 + copy_directory(os.path.join(webstack_package_home, "WebStack"),
2.39 os.path.join(appname, "WEB-INF", "jython"))
2.40
2.41 # Copy the application packages.
2.42 @@ -114,11 +117,25 @@
2.43 for appdir in packages:
2.44 copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython"))
2.45
2.46 + # Copy the libraries.
2.47 +
2.48 + if libraries:
2.49 + for library in libraries:
2.50 + library_dir, library_name = os.path.split(library)
2.51 + library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
2.52 + copy_file(library, library_dest)
2.53 +
2.54 # Copy the handler.
2.55
2.56 handler_filename = os.path.split(handler)[1]
2.57 copy_file(handler, os.path.join(appname, handler_filename))
2.58
2.59 + # Copy the root resources.
2.60 +
2.61 + for root_resource in root_resources:
2.62 + root_resource_filename = os.path.split(root_resource)[1]
2.63 + copy_file(root_resource, os.path.join(appname, root_resource_filename))
2.64 +
2.65 # Find additional Jython paths.
2.66
2.67 jython_paths = []
2.68 @@ -135,7 +152,7 @@
2.69
2.70 # Configure the deployment descriptor.
2.71
2.72 - f = open(os.path.join(webstack_home, "tools", "JavaServlet", web_xml_template_name))
2.73 + f = open(os.path.join(webstack_tools_home, "tools", "JavaServlet", web_xml_template_name))
2.74 web_xml = f.read()
2.75 f.close()
2.76 web_xml = web_xml % (jython_home, jython_path, jython_cachedir, handler_filename)
2.77 @@ -148,15 +165,32 @@
2.78
2.79 if __name__ == "__main__":
2.80 import sys
2.81 - if len(sys.argv) < 5:
2.82 + if len(sys.argv) < 8:
2.83 + print "Syntax:"
2.84 + print
2.85 + print "jython webstack_java_build.py <handler> [ <resource>... ] \\"
2.86 + print " --webstack <home> <tools> <cachedir> <descriptor> <app> \\"
2.87 + print " [ --libraries <library>... ]"
2.88 + print
2.89 print "Please specify..."
2.90 print
2.91 print "The location of the application handler. For example:"
2.92 print
2.93 print " .../WebStack-x.y/examples/JavaServlet/SimpleApp.py"
2.94 print
2.95 - print "The location of the WebStack package distribution or where WebStack"
2.96 - print "documentation and extras have been installed. For example:"
2.97 + print "Any other top-level resources, such as JSP templates. For example:"
2.98 + print
2.99 + print " .../WebStack-x.y/examples/JavaServlet/test.jsp"
2.100 + print
2.101 + print "After the --webstack marker, the details of the WebStack distribution"
2.102 + print "are required, such as..."
2.103 + print
2.104 + print "The location of the WebStack package distribution. For example:"
2.105 + print
2.106 + print " .../WebStack-x.y"
2.107 + print " /usr/lib/python2.4/site-packages"
2.108 + print
2.109 + print "The location of the WebStack tools have been installed. For example:"
2.110 print
2.111 print " .../WebStack-x.y"
2.112 print " /usr/share/doc/python2.4-webstack"
2.113 @@ -168,6 +202,8 @@
2.114 print "The name of the deployment descriptor template. For example:"
2.115 print
2.116 print " web.xml"
2.117 + print " jsp-web.xml"
2.118 + print " protected-web.xml"
2.119 print
2.120 print "The location of the application packages. For example:"
2.121 print
2.122 @@ -178,28 +214,36 @@
2.123 print
2.124 print " $CATALINA_HOME/common/lib/activation.jar"
2.125 print " $CATALINA_HOME/common/lib/mail.jar"
2.126 + print
2.127 + print "With Apache Tomcat 4.1.x, activation.jar and mail.jar are usually"
2.128 + print "required."
2.129 sys.exit(1)
2.130
2.131 - handler, webstack_home, jython_cachedir, web_xml = sys.argv[1:5]
2.132 + webstack_index = sys.argv.index("--webstack")
2.133
2.134 try:
2.135 libraries_index = sys.argv.index("--libraries")
2.136 - packages = sys.argv[5:libraries_index]
2.137 - libraries = sys.argv[libraries_index+1:]
2.138 except ValueError:
2.139 - packages = sys.argv[5:]
2.140 - libraries = []
2.141 + libraries_index = len(sys.argv)
2.142 +
2.143 + print "Handler, root resources are..."
2.144 + handler, root_resources = sys.argv[1], sys.argv[2:webstack_index]
2.145 + print handler, root_resources
2.146 +
2.147 + print "WebStack distribution details are..."
2.148 + webstack_package_home, webstack_tools_home, jython_cachedir, web_xml = sys.argv[webstack_index+1:webstack_index+5]
2.149 + print webstack_package_home, webstack_tools_home
2.150 +
2.151 + print "Packages..."
2.152 + packages = sys.argv[webstack_index+5:libraries_index]
2.153 + print packages
2.154 +
2.155 + print "Libraries..."
2.156 + libraries = sys.argv[libraries_index+1:]
2.157 + print libraries
2.158
2.159 print "Making application directory..."
2.160 - make_app(handler, webstack_home, jython_cachedir, web_xml, packages)
2.161 -
2.162 - if libraries:
2.163 - print "Copying additional libraries..."
2.164 - appname = get_appname(sys.argv[1])
2.165 - for library in libraries:
2.166 - library_dir, library_name = os.path.split(library)
2.167 - library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
2.168 - copy_file(library, library_dest)
2.169 + make_app(handler, root_resources, webstack_package_home, webstack_tools_home, jython_cachedir, web_xml, packages, libraries)
2.170
2.171 print "Now copy or move the application directory to your servlet container."
2.172