• 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 include optional jars in Maven while building WAR

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

I need to make a war file of my project who is dependent on the spring . I have referred the dependency as

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>

The outcome i get is that in the lib folder of war file , I get two jars commons-logging.jar and spring-core.jar . I saw the pom.xml of spring-core module and it has also the dependency of commons-collections but that jar is not imported and included in my war file as <optional>true</optional> has bee set in spring-core pom.xml .

Is there any way to include all the jars whether optional , provided , test etc while building war
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, the only way to include it is to add it as a dependency in your POM and not mark it optional.

See this doc: http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
Here is a quote from that page:

MavenDocs wrote:If a user wants to use functionality related to an optional dependency, they will have to redeclare that optional dependency in their own project.

 
tanu dua
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But that just I want to avoid it though I am not sure how. To give you more context our project currently is on spring2.2.5 version and we don't use maven . We need to upgrade now our version from spring2.2.5 to spring 3.0.5.RELEASE . I searched through the net to know the dependency jars which this spring version would depen upon and could not find that . Instead I got the following thread in spring forum which says that you should use maven to get the dependent jars.

http://forum.springsource.org/showthread.php?t=103862

Now , since we can't upgrade to maven framework right away , I though to get the dependency jars by referring spring artifact assuming that all the dependencies jars would also come with it . But the optional one is left out.

Following is the link I refer to refer the spring artifacts in my pom.xml

http://blog.springsource.com/2009/12/02/obtaining-spring-3-artifacts-with-maven/

Is there any way to get them also else I need to go into each pom.xml of spring and copy the optional dependency from there and paste it into mine.

Thanks
Tanu

 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, so you are not using Maven to build your project, you are just trying to gather all of the dependent JARs. There might be hope! Try using either the Maven Assembly Plugin or the Maven Dependency Plugin. Both of those will gather transitive dependencies, and they are both highly configurable, and perhaps one of them will do what you need.
 
reply
    Bookmark Topic Watch Topic
  • New Topic