• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to put jar after creating it in war file's lib through Maven

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

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.


 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi

From what I understood, you would need to specify packaging type in your pom.xml.

<project>
.......
<packaging>war</packaging>
....
</project>

This would make a war file of your project.

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.

Hope this helps.

Praneet
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The WAR task will populate the WEB-INF/lib with the dependent libraries.
 
Kousik Majumder
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's your use case for that? In other words, why bother?
 
Saloon Keeper
Posts: 27879
197
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Kousik Majumder
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thank you Tim. Your explanation cleared my concept.
Thank you again.
 
reply
    Bookmark Topic Watch Topic
  • New Topic