I want to create a .war file in maven. in the war file's lib directory I need to put some jar files too(which I have to create at the time of creating war).
How can I do that through maven.Pease give an example.
I am not too sure how to add jar files to this war.
What you can do is install any jars you need on your local repsitory using:
mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14 -Dpackaging=jar -Dfile=D:\ojdbc14.jar
This installs the ojdbc14.jar file located in the D drive on your local repository.
Actually I dont have any jar files so far which I can add in WAR task.
When this war file will be created then the jar files will also be created. I want to know how can I create those jar files and put those into the war file altogether.
You need to create a Maven project for each of the jar files that you're creating. Each of those Maven projects will create its corresponding JAR. Build the JARs using the "mvn install" goal for each jar.
Construct dependency elements in the WAR file. Once dependency element for each constructed JAR. Then when you build the WAR, Maven will retrieve the installed jars and place them in the WAR - assuming you used one of the dependency scopes that copies. Which is practically any scope except "provided".
Ant can produce multiple artifacts from a single build.xml, but Maven is different. Each POM is intended to produce one and only one artifact. You can define a master POM with dependent POMs for each of the JARS and the WAR, but no one single POM can produce multiple artifacts.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.