Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RPM using Ant scripting

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I know a very little about ANT commands and I do not know whther this will be an appropriate forum for me or not. I am developing a web project. All the compilation and build stuff is done through ANT tool. Now my client has asked me to do a strange thing. He has asked me to make an rpm package of the source code so whenever the rpm package is run on a Linux machine, a war file is made and that war file is deployed to a tomcat server. Now, honestly speaking, I do not know anything about linux or rpm. I was surfing through the internet and I found that rpm packages can be used to install software but I didnt find anything about the deployment of a web project. Then I found that ANT is also providing an rpm command
http://ant.apache.org/manual/Tasks/rpm.html

Now, although I do not know much about ant scripting but I can work in that. So I prefer Ant's RPM over Linux RPM packaing. So my question is if there is any support in ANT for making an RPM which would make a war file and deploy it to a tomcat server? If yes what would be the proper steps to follow in the ant file.

An example will help me out of a big mess.

Thanks in advance.
 
Saloon Keeper
Posts: 22256
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RPM is the RedHat Package Manager. Windows has ".MSI" packages, but Linux has RPM, DEB, and several other packaging systems, depending on which distro you favor. RPM is the standard for Red Hat, Fedora, CentOS, SuSe and several other major distros.

Loosely speaking, an RPM package is sort of like a ZIPFILE full of installable files plus scripts plus an overall set of directions and specifications. That can also be said of the Debian/Ubuntu DEB package format, although they're actually more like a ZIP file and less into package management details.

RPMS were designed to allow people to:

1. Take generic source code from a site on the Internet and download their source archives (tarballs).
2. Apply patches to make the application specific to the target distro
3. Run a build from source
4. Gather the results of the build and make a pair of RPM files, one for application source, one for binary distribution.

The RPM can then be installed, queried, managed, and validated on the target machine. Information goes into a central RPM database to assist in keeping inventory on what packages are installed on that machine.

RPM was not designed for Java or J2EE. You usually don't get much benefit from a source RPM, and you almost never patch Java code, so RPMs built for Java apps downplay those features. However, RPMs are so useful as general package installations that I make almost all of my Linux-deployed project builds into RPMs. WARs and EARs are great, but they only concern the internals of a Java app. RPMs can also manage the external supporting files such as config files, setting up directories to hold files uploaded through the webaapp and other specialized OS-type non-Java functions.

The Ant rpm task is not a different process than the standard RPM build task. The Ant RPM task is in fact, a wrapper for the rpmbuild program, so if rpmbuild is not installed on your machine, the Ant RPM task will fail.

Details on how to build RPMS are available elsewhere - their home site is rpm.org. However, the main points are that you have to setup an RPMbuild directory and you have to provide a ".spec" file which will describe the RPM, list which files will be installed (and where), hold the install/uninstall scripts and do various other things.

It's actually easier to build Java RPMs using Maven than Ant, but I had a lot of practice building RPMs with Ant before I learned to love Maven.
 
Fawad Ali
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
Thanks you are again here for my rescue. I hate maven, as I do not know it(Obviously). So if I want to make an rpms package of my web application, which is when executed make a war file and then deploy the war file to a tomcat server, what steps should I follow in both the cases 1)With ant rpm and 2) with rpm utility of linux? If you can suggest me with a tutorial or something which may guide me through the very basics of this problem, it will be great.


And thanks again Tim.
 
Tim Holloway
Saloon Keeper
Posts: 22256
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since Ant's RPM task calls the rpmbuild utility anyway, I'd recommend making Ant do it. After all, Ant's already creating the WAR. Might as well make it finish the job. You can test the rpmbuild stand-alone if Ant gets in your way.

The definitive docs on designing and creating RPMs are at rpm.org, although they weren't doing a good job of keeping them up to date. Which most notably showed in their use of the "rpm -ba" command in examples instead of the the newer "rpmbuild" command. Mainly, you have to set up the RPM directories and create a specfile. You can use the rpm command itself to query an RPM for information about itself.
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic