Get your CodeRanch badge!*
The moose likes Ant, Maven and Other Build Tools and the fly likes How to add a war file to a tar  through build file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to add a war file to a tar  through build file" Watch "How to add a war file to a tar  through build file" New topic
Author

How to add a war file to a tar through build file

rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
I have built an application and I wanted my tar file to contain my application.war and few more directories in the same heirarachy

I am able to create my war file correctly with the help of war tag in the build file and a tar file as well. But I am not able to get those war files and the other rdirectories in my tar file..

I am confused using the fileset or I tried with a move tag.

Can anyone advise how to do this
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Does the tar file exist or are you trying to create it? If the former, I think you have to untar it first, add the file to the directory and then retar.

The tar task and untar tasks are helpful with this.

Can you post some code using the tar task so we can give more concrete pointers?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
I have created a war file with my full application excluding few directories and I wanted to move this to a tar along with 2 more directories..

<war destfile="../${name.war}" webxml="WEB-INF/web.xml">
<fileset dir="${basedir}">
<exclude name="${src}/**" />
<exclude name=".**" />
<exclude name="*.**" />
</fileset>

</war>

By this I am able to war. For tar, I just wanted to know how to include this war and other directories while tarring..
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Have you tried the 2 tasks that Jeanne mentioned above?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Manish Doomra
Greenhorn

Joined: Sep 05, 2008
Posts: 21
Originally posted by rahulJ james:
I have created a war file with my full application excluding few directories and I wanted to move this to a tar along with 2 more directories..

<war destfile="../${name.war}" webxml="WEB-INF/web.xml">
<fileset dir="${basedir}">
<exclude name="${src}/**" />
<exclude name=".**" />
<exclude name="*.**" />
</fileset>

</war>

By this I am able to war. For tar, I just wanted to know how to include this war and other directories while tarring..


Hello Rahul,

Let's assume the directory structure of "war.basedir" is as follows:-

war.basedir--
|__${name.war} ---- (The war file which got created)
|
|__dir1
|
|__dir2
|
|__docs

and the directory "root.basedir" is the parent directory of "war.basedir"

Now, assume you want to tar all the contents of "war.basedir" at root.basedir but ignoring docs folder which is sub directory of "war.basedir"

The code for the same would be like this:-



For other options of tar task
[ November 19, 2008: Message edited by: Manish Doomra ]

Manish Doomra
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
Yeah I could tar the file. Thanks..

How will I be able to read a property file and replace the values in the build.xml file before it is kciked off..

I mean I have 3 property files(test, dev and prod), based on reading this file I have to change few values in build.xml file..

How do I do this?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

A simple way is to pass a -D parameter into your Ant script, e.g. -Denv=dev for development and then use that to choose which properties file to load.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add a war file to a tar through build file
 
Similar Threads
Can we run Apache Tomcat in Sun Solaris 8.0?
Unable to create the tar file in the dist directory.
.classpath entry to build war out using dependent war file
How to change directory with ant ?
Creating WAR file directories (maintain fullpath)