I created a project in maven.I have a folder structure created .Please note,i have client related java files in one folder,Servlet related java files in another folder and so on in my project.So In src/main/java ,i copied all the jave files(with the folder structure such as client ,servlet etc) i have in my project and placed it there.Now in src/main/java,i have nearly 6 folders having java files.I have run it using ant.Now i asked to do the same in Maven.In ant,i have dependency written for each a every thing required in a xml file and finally will call all the xml files in build.xml. How should i do this using maven?Also i read in a article as : maven will download the the dependency required for our project.How can i add my own dependencies in maven?please help.
In Maven, each build should have a single output. Thus one project would build the WAR file, another would build the client. If you have a library of classes shared by both, that would be a third project.
So let's assume that you have a project that creates mycommon.jar - the JAR file used by both the web app and your client. The first thing you have to do is get that jar file into your local repository. You can do this by running the maven build for the mycommon.jar file as follows:
This will compile the class, build the jar, and place the jar in the repository.
Then in you client and war projects, you can refer to your jar exactly the same way you refer to other jar files:
Where your.group.id is the value of "groupId" in the mycommon.jar pom.xml, and 1.0-SNAPSHOT is the value of "version" in the mycommon.jar pom.xml.