File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes New to maven - need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "New to maven - need help" Watch "New to maven - need help" New topic

New to maven - need help

Jano Balakrishnan

Joined: Sep 01, 2008
Posts: 27
I will explain in detail what i have in my hand.

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.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

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:

mvn install

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 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.

I also recommend you read Better Builds with Maven

JBoss In Action
I agree. Here's the link:
subject: New to maven - need help
jQuery in Action, 3rd edition