Skip to content

Instantly share code, notes, and snippets.

@lusis
Created December 17, 2012 06:20
Show Gist options
  • Select an option

  • Save lusis/4316165 to your computer and use it in GitHub Desktop.

Select an option

Save lusis/4316165 to your computer and use it in GitHub Desktop.
"integrating" fpm with maven

LOLUsage

package.sh lives at the same level as your pom. Honestly you could put it all inline with the exec plugin.

The reason I don't is it's easier to edit the shell script. It doesn't HAVE to live at the same level as the pom but that's in the search path for the exec plugin.

I also wanted to have the conditional logic for SNAPSHOT builds (appending the timestamp). There are obviously many ways the shell script could blow up at this point.

The rest of this pom actually does some stuff to package up a copy of our component with a customized distribution of Jetty8 similar to what the hightide distribution does. We basically vendor the container with the application.

The only thing missing that I can see right now is attaching the generated deb artifact and pushing it to artifactory. Well...that and making sure it doesn't blow up on me for stupid reasons.

#!/usr/bin/env bash
if [ -z ${CURRENT_ITERATION} ]; then
CURRENT_ITERATION=0enstratus1
fi
case "${PKG_VERSION}" in
*-SNAPSHOT)
echo "Packaging a snapshot version!"
CURRENT_TSTAMP=`date +%s`
#CURRENT_SHA=`git rev-parse HEAD`
#CURRENT_ITERATION="${CURRENT_TSTAMP}-${CURRENT_SHA}"
CURRENT_ITERATION="${CURRENT_TSTAMP}"
;;
*)
echo "Not packaging a snapshot version"
;;
esac
echo "Current iteration: ${CURRENT_ITERATION}"
EXTRACT_DIR=fpm/extract/
WORKSPACE=fpm/workspace/
SOURCE=${APPNAME}-${PKG_VERSION}.tar.gz
mkdir -p ${EXTRACT_DIR}
mkdir -p ${WORKSPACE}
echo "Extracting ${APPNAME}-${PKG_VERSION}"
tar zxf ${APPNAME}-${PKG_VERSION}.tar.gz -C ${EXTRACT_DIR} --strip-components=1
echo "chown -R enstratus:enstratus /services/${SHORTNAME}" > postinst
fpm \
--workdir ${WORKSPACE} \
-C ${EXTRACT_DIR} \
--prefix services/${SHORTNAME}/ \
-t deb \
-s dir \
--category non-free \
-d enstratus-base \
--after-install postinst \
--iteration ${CURRENT_ITERATION} \
--vendor "enStratus Networks Inc" \
-m "John E. Vincent <[email protected]>" \
--url "https://enstratus.com" \
--description "${DESCRIPTION}" \
-a all \
-n ${APPNAME} \
-v ${PKG_VERSION} \
.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.enstratus</groupId>
<artifactId>enstratus-api-webapp</artifactId>
<version>2012.2.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>enStratus API Web Application</name>
<description>Web service for the enstratus API.</description>
<properties>
<enstratus.component.name>api</enstratus.component.name>
<!-- other properties -->
</properties>
<dependencies>
<!-- deps -->
</dependencies>
<build>
<plugins>
<!-- other plugins -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>fpm</id>
<phase>package</phase>
<goals><goal>exec</goal></goals>
</execution>
</executions>
<configuration>
<executable>package.sh</executable>
<workingDirectory>target</workingDirectory>
<environmentVariables>
<PKG_VERSION>${project.version}</PKG_VERSION>
<APPNAME>${project.artifactId}</APPNAME>
<SHORTNAME>${enstratus.component.name}</SHORTNAME>
<DESCRIPTION>${project.description}</DESCRIPTION>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
<!-- other stuff -->
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment