Skip to content

Instantly share code, notes, and snippets.

@chrisdennis
Created February 12, 2020 15:56
Show Gist options
  • Save chrisdennis/71ee4623ce1c6700efbe286fd4db9c12 to your computer and use it in GitHub Desktop.
Save chrisdennis/71ee4623ce1c6700efbe286fd4db9c12 to your computer and use it in GitHub Desktop.
Maven Toolchain XML Goodness
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/plist">
<toolchains>
<xsl:for-each select="array/dict">
<toolchain>
<type>jdk</type>
<provides>
<version>
<xsl:value-of select="key[text()='JVMPlatformVersion']/following-sibling::string[1]"/>
</version>
<architecture>
<xsl:value-of select="key[text()='JVMArch']/following-sibling::string[1]"/>
</architecture>
<vendor>
<xsl:value-of select="key[text()='JVMVendor']/following-sibling::string[1]"/>
</vendor>
</provides>
<configuration>
<jdkHome>
<xsl:value-of select="key[text()='JVMHomePath']/following-sibling::string[1]"/>
</jdkHome>
</configuration>
</toolchain>
</xsl:for-each>
<xsl:comment>Stupid ZULU/Oracle Mandate Nonsense</xsl:comment>
<xsl:for-each
select="array/dict[key[text()[normalize-space(.)='JVMVersion']]/following-sibling::string[text()[starts-with(normalize-space(.), '1.8')]]]">
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<architecture>
<xsl:value-of select="key[text()='JVMArch']/following-sibling::string[1]"/>
</architecture>
<vendor>zulu</vendor>
</provides>
<configuration>
<jdkHome>
<xsl:value-of select="key[text()='JVMHomePath']/following-sibling::string[1]"/>
</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
<architecture>
<xsl:value-of select="key[text()='JVMArch']/following-sibling::string[1]"/>
</architecture>
<vendor>Oracle Corporation</vendor>
</provides>
<configuration>
<jdkHome>
<xsl:value-of select="key[text()='JVMHomePath']/following-sibling::string[1]"/>
</jdkHome>
</configuration>
</toolchain>
</xsl:for-each>
</toolchains>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment