Skip to content

Instantly share code, notes, and snippets.

@gargoyle
Created October 24, 2016 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gargoyle/e9fba82a87978983484a7eb9da23dd3b to your computer and use it in GitHub Desktop.
Save gargoyle/e9fba82a87978983484a7eb9da23dd3b to your computer and use it in GitHub Desktop.
Split out 3 section version number in Phing
<target name="loadVersion">
<loadfile property="version.full" file="VERSION.txt"/>
<php expression="count(explode('.','${version.full}',3))" returnProperty="version.segments"/>
<if>
<not><equals arg1="${version.segments}" arg2="3" /></not>
<then><fail message="Bad version number!"/></then>
</if>
<php expression="(int)explode('.','${version.full}',3)[0]" returnProperty="version.major"/>
<php expression="(int)explode('.','${version.full}',3)[1]" returnProperty="version.minor"/>
<php expression="(int)explode('.','${version.full}',3)[2]" returnProperty="version.rev"/>
</target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment