3

I have a war(built using Struts 1.x jars) which has been deployed on server but do not have the corresponding source code so I have basically extracted the .class files from the jar and de-compiled them and trying to build the source code(project) and commit to repository.

So, I want to create a Struts 1.x project using Ant tool, import it into Eclipse IDE and then generate a war.

I tried the following:

1. Created a dynamic web project & added struts jars

New -> Other -> Web - >Dynamic Web Project
Updated web.xml & created struts-config.xml under WEB-INF
Then struts jars were added to build path

2. Created an Ant build file for existing project

Select File > Export from main menu<br/> 

In the Export dialog, select General > Ant Buildfilesas follows:

Click Next. In the Generate Ant Buildfilesscreen:
Check the project in list.
Uncheck the option "Create target to compile project using Eclipse compiler" because we want to create a build file which is independent of Eclipse.
Leave the Name for Ant buildfile as default: build.xml
Click Finish, Eclipse will generate the build.xmlfile 

3. Run Ant build to build a war.

Is this the correct way of building war using ant tool? Or is there any other way?

Karthik
  • 1,302
  • 5
  • 25
  • 56
  • I tried the following steps 1) created a dynamic web project & added struts jars 2) created an ant build file for existing project 3) run ant build to build a war. – Karthik Jul 10 '15 at 05:28
  • I did not face any issue. I want to know how can one create a struts project using ANT tool. I am new to ANT tool(In maven, we specify struts-archetype to build the project, it creates the entire project structure and downloads required jars). So, how to create a struts project using ant tool? – Karthik Jul 10 '15 at 13:28
  • You've got to show us what you've tried. With this info, I couldn't even write you an Ant `build.xml` file itself. There's simply not enough information. Ant is a complex piece of software. Entire books have been written on it. I can't give you a complete tutorial in a single StackOverflow answer. Go to the [Ant](http://ant.apache.org) page and try the tutorial. Read a few books about [Ant](http://shop.oreilly.com/product/9780596006099.do). Try a few things, and then ask something a bit more specific. – David W. Jul 10 '15 at 14:31
  • Struts 1.3.x is officially abandoned for years. And you're starting a new project with Struts 1.0? Why? – JB Nizet Jul 13 '15 at 07:29
  • I have a war(built using Struts 1.x jars) which has been deployed on production server but do not have the corresponding source code so I have basically extracted the .class files from the jar and de-compiled them and trying to build the source code(project) and commit to repository – Karthik Jul 13 '15 at 07:48

1 Answers1

0

You need to create Target for bulding war file:

see this link http://www.tutorialspoint.com/ant/ant_creating_war_files.htm

for how to create target for building war file.

Shridutt Kothari
  • 7,326
  • 3
  • 41
  • 61