简体   繁体   中英

packaging & deploying Java EE webapp without ANT

We are going to develop a huge webapp coded in Java EE technology for our client. My client doesn't support ANT and Eclipse which are OSS in their servers.

So our requirement is to code and develop the application in our local system and test it, then we need to supply the source code in the client server where we will run a deployment script which will compile the required java files from the source files and deploy the .class files and other resource files to Tomcat running on that server (HP-UX).

Is it possible to use just javac, jar or other commands available in JAVA_HOME/bin to deploy an application with out using ANT scripts? If there is any such implementation could you please guide us? I wonder before ANT was developed, how JAVA developers used to deploy big applications. I came to know that MAKE command (available in our server) is not good for java applications.

Note: We will be having complex package hierarchy (up to 4 levels)

UPDATE: It looks like I dont have a straight forward answer. I would like to persuade our client to use ANT. If not I will develop a cross platform custom build tool for my client based up on the comments below... Thanks guys.. I dont think building that type of tool is not that difficult if we know the proper steps in packaging and deployments...

I think the whole setup is pretty strange but anyhow...

A .war file is pretty simple. It's a ZIP file with a given directory structure. You can easily create this with a shell script that first runs javac to compile the source code, then copies the file to the correct directory and finally packs it into a ZIP file with the .war extension.

You'll find the specification for .war files on the net. Or you can build one in your environment, open it with a ZIP tool and have a look which files need to go where.

Update: If your application is big, then you can split it into modules. Each module will be compiled and packaged into a separate .jar file (basically a ZIP file as well). If a module depends on another then, then just pass the required .jar files as the class path argument to the compiler.

If you really must accept the client requirements then this is probably how I would do it.

To avoid having to modify dependencies for each and every file you add I would introduce a convention of where to put source code, jar files and output files. Then I would create a script with a few settings:

  1. Name of war.
  2. List of library locations.
  3. List of source roots, maybe letting the folder name of the root be the jar file name.

Then when running the script it would create a class path including all jar files presented in the library locations list. Then it would for each source location compile the java files, build a jar and add the jar file to the class path (in case later modules needs it).

Finally it would build a web app structure with the external libraries, the newly created jars, copy over the asp files (possibly precompiled) and then using zip package the web app structure into a war file.

Find out which shells are acceptable by the customers so you don't use any shell specific features. I don't think you need anything fancy, so that should not be too hard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM