Permalink
Browse files

make giraph-site.xml configurable with Make and xsl

  • Loading branch information...
1 parent ef8251b commit 0bf29fec269b060bc96e3de582f39ea1954a66ab @ekoontz committed Apr 14, 2012
Showing with 45 additions and 1 deletion.
  1. +10 −0 conf/Makefile
  2. +1 −1 conf/{giraph-site.xml → giraph-site.template.xml}
  3. +34 −0 conf/giraph-site.xsl
View
@@ -0,0 +1,10 @@
+.PHONY: all clean
+all: giraph-site.xml
+clean:
+ -rm giraph-site.xml
+
+giraph-site.xml: giraph-site.xsl giraph-site.template.xml
+ xsltproc --stringparam HOME $(HOME) $^ > $@
+
+
+
@@ -30,7 +30,7 @@ under the License.
</property>
<property>
<name>giraph.zkJar</name>
- <value>/Users/ekoontz/.m2/repository/org/apache/zookeeper/zookeeper/3.3.3/zookeeper-3.3.3.jar:/Users/ekoontz/.m2/repository/org/slf4j/slf4j-log4j12-1.6.1.jar:/Users/ekoontz/.m2/repository/org/slf4j/slf4j-api-1.6.1.jar:/Users/ekoontz/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar:/Users/ekoontz/giraph/src/test/resources</value>
+ <value>$HOME/.m2/repository/org/apache/zookeeper/zookeeper/3.3.3/zookeeper-3.3.3.jar:$HOME/.m2/repository/org/slf4j/slf4j-log4j12-1.6.1.jar:$HOME/.m2/repository/org/slf4j/slf4j-api-1.6.1.jar:$HOME/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar:$HOME/giraph/src/test/resources</value>
</property>
<property>
<name>hadoop.mapreduce.framework.name</name>
View
@@ -0,0 +1,34 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:output method="xml"/>
+
+ <xsl:param name="HOME"/>
+
+ <xsl:template match="configuration">
+ <configuration>
+ <xsl:copy select="@*"/>
+ <xsl:apply-templates/>
+ </configuration>
+ </xsl:template>
+
+ <xsl:template match="property[name='giraph.zkJar']">
+ <property><xsl:text>
+ </xsl:text>
+ <name><xsl:value-of select="name"/></name><xsl:text>
+ </xsl:text><value><xsl:call-template name="subst"><xsl:with-param name="string" select="value"/></xsl:call-template></value>
+ </property>
+ </xsl:template>
+
+ <xsl:template match="property">
+ <xsl:copy-of select="."/>
+ </xsl:template>
+
+ <xsl:template name="subst">
+ <xsl:param name="string"/>
+ <xsl:variable name="first" select="substring-before($string, '$HOME')" />
+ <xsl:variable name="rest" select="substring-after($string, '$HOME')" />
+ <xsl:variable name="untilcolon"><xsl:value-of select="substring-before($rest,':')"/></xsl:variable>
+ <xsl:variable name="end"><xsl:choose><xsl:when test="$untilcolon = ''"><xsl:value-of select="$rest"/></xsl:when><xsl:otherwise><xsl:value-of select="$untilcolon"/></xsl:otherwise></xsl:choose></xsl:variable>
+ <xsl:if test="$rest != ''"><xsl:value-of select="$HOME"/><xsl:value-of select="$end"/>:<xsl:call-template name="subst"><xsl:with-param name="string" select="$rest"/></xsl:call-template></xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>

0 comments on commit 0bf29fe

Please sign in to comment.