Domanda

I have,

   build/classes - compiled java codes

   libs - some jar files

   src - java codes

   WebContent - all the .jsp files, WEB-INF/lib and META-INF

i create some build files but they did not work. How to create a build.xml file for this folder structure.

È stato utile?

Soluzione

Detailed Example of Ant for War File

All the classes inside the src directory should be compiled and placed in a separate build/classes directory. The created war file will be placed inside the dist directory.

  1. So first we create the build/classes and the dist directory. The init target does this job.

  2. The next step is to compile all the classes in the src directory and place them in the build/classes directory. To do this first you need to add all the lib files inside the "WebContent/WEB-INF/lib" directory to the classpath.

  3. The target compile uses the javac task to compile the java classes and it depends on the target init, because only when you have the directory ready you can place the classes inside them.The path we created earlier will be refered here using the element.

  4. Now we can create the war file using the war task. To create the war file you need to specify the web directory, lib directory and the classes directory. The destfile attribute specifies the war file location and the webxml attribute specifies the web.xml file location

  5. You can use the clean target to clean the project. The clean target deletes the build and the dist directory.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top