How to create rpm using Maven

Include in your POM the following:

	 <build>
...
            <finalName>GreatApp</finalName>
...	
               <plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>buildnumber-maven-plugin</artifactId>
			<version>1.0-beta-2</version>
			<executions>
				<execution>
					<phase>validate</phase>
					<goals>
						<goal>create</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<doCheck>false</doCheck>
				<doUpdate>false</doUpdate>
				<format>{0,number,#}</format>
				<items>
					<item>buildNumber</item>
				</items>
				<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
			</configuration>
		</plugin>
		<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>rpm-maven-plugin</artifactId>
				<version>2.0-beta-2</version>
				<configuration>
					<copyright>2010 - dimitrisli</copyright>
					<group>Application/Collectors</group>
					<release>${buildNumber}</release>
					<mappings>
						<mapping>
							<directoryIncluded>false</directoryIncluded>
							<directory>/usr/share/tomcat5/webapps</directory>
							<username>tomcat</username>
							<groupname>tomcat</groupname>
							<sources>
								<source>
									<location>${project.build.directory}/${finalWarName}.war</location>
								</source>
							</sources>
						</mapping>
					</mappings>
				</configuration>
			</plugin>
  </plugins>
...
  </build>
...
  <properties>
		<finalWarName>GreatFinalWarName</finalWarName>
  </properties>

And in the UNIX box where the rpm tool is installed run:

mvn package rpm:rpm
Advertisements