Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to maven - need help

 
Jano Balakrishnan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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.

I also recommend you read Better Builds with Maven
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic