| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
<project name="site" basedir="." default="help"> |
| 10 |
<property environment="env"/> |
| 11 |
<property name="build.directory" value="${basedir}/target"/> |
| 12 |
<property name="site.directory" value="${basedir}/site"/> |
| 13 |
|
| 14 |
<property name="gh-pages.directory" value="${build.directory}/gh-pages"/> |
| 15 |
<property name="gh-pages.javadoc.directory" value="${gh-pages.directory}/apidocs/latest"/> |
| 16 |
|
| 17 |
<property name="parent.project.directory" value="${basedir}/.." /> |
| 18 |
<property name="parent.project.javadoc.directory" value="${parent.project.directory}/target/site/apidocs"/> |
| 19 |
|
| 20 |
<target name="test-gh-pages"> |
| 21 |
<available file="${gh-pages.directory}" type="dir" property="gh-pages.available"/> |
| 22 |
</target> |
| 23 |
|
| 24 |
<target name="test-javadoc"> |
| 25 |
<available file="${parent.project.javadoc.directory}" type="dir" property="javadoc.available" /> |
| 26 |
</target> |
| 27 |
|
| 28 |
<target name="clone" depends="test-gh-pages" unless="gh-pages.available"> |
| 29 |
<mkdir dir="${build.directory}"/> |
| 30 |
<git dir="${build.directory}" command="clone [email protected]:lviggiano/owner --branch gh-pages gh-pages"/> |
| 31 |
</target> |
| 32 |
|
| 33 |
<target name="pull" depends="clone" if="gh-pages.available"> |
| 34 |
<git dir="${gh-pages.directory}" command="pull origin gh-pages"/> |
| 35 |
</target> |
| 36 |
|
| 37 |
<target name="copy-site"> |
| 38 |
<copy todir="${gh-pages.directory}" overwrite="true"> |
| 39 |
<fileset dir="${site.directory}" /> |
| 40 |
</copy> |
| 41 |
</target> |
| 42 |
|
| 43 |
<target name="copy-javadoc" depends="test-javadoc" if="javadoc.available"> |
| 44 |
<copy todir="${gh-pages.javadoc.directory}" overwrite="true"> |
| 45 |
<fileset dir="${parent.project.javadoc.directory}"/> |
| 46 |
</copy> |
| 47 |
</target> |
| 48 |
|
| 49 |
<target name="copy" depends="pull,copy-site,copy-javadoc"> |
| 50 |
<copy file="${site.directory}/.gitignore" todir="${gh-pages.directory}"/> |
| 51 |
</target> |
| 52 |
|
| 53 |
<target name="commit" depends="copy"> |
| 54 |
<git dir="${gh-pages.directory}" command="add ."/> |
| 55 |
<git-hash dir="${basedir}" property="sha"/> |
| 56 |
<git dir="${gh-pages.directory}" command="commit -m 'Updating to ${sha}.'"/> |
| 57 |
</target> |
| 58 |
|
| 59 |
<target name="push" depends="commit"> |
| 60 |
<git dir="${gh-pages.directory}" command="push origin gh-pages"/> |
| 61 |
</target> |
| 62 |
|
| 63 |
<target name="publish" depends="push"/> |
| 64 |
|
| 65 |
<target name="clean"> |
| 66 |
<delete dir="${gh-pages.directory}"/> |
| 67 |
</target> |
| 68 |
|
| 69 |
<target name="run-drafts"> |
| 70 |
<jekyll-serve options="-w --drafts" /> |
| 71 |
</target> |
| 72 |
|
| 73 |
<target name="run"> |
| 74 |
<jekyll-serve options="-w" /> |
| 75 |
</target> |
| 76 |
|
| 77 |
<target name="javadoc"> |
| 78 |
<mvn dir="${parent.project.directory}" command="javadoc:aggregate" /> |
| 79 |
</target> |
| 80 |
|
| 81 |
<target name="build"> |
| 82 |
<property name="site.destination.directory" value="${build.directory}/www"/> |
| 83 |
<tempfile deleteonexit="true" destdir="${site.directory}" prefix="_build-" suffix=".yml" property="build.file"/> |
| 84 |
<echo file="${build.file}" message="url: file://${site.destination.directory}"/> |
| 85 |
<jekyll dir="${site.directory}" command="build" options="--destination ${site.destination.directory} --config _config.yml,${build.file}" /> |
| 86 |
</target> |
| 87 |
|
| 88 |
<target name="help"> |
| 89 |
<echo> |
| 90 |
ant clean - cleans up the target dir |
| 91 |
ant build - generates the website in the _site dir (it's not necessary to publish) |
| 92 |
ant javadoc - generates javadocs |
| 93 |
ant publish - publish site to gh-pages |
| 94 |
ant run-drafts - run jekyll serve (with '-w --drafts' options) |
| 95 |
ant run - run jekyll serve (with '-w' option) |
| 96 |
|
| 97 |
Use `ant javadoc publish`, to publish javadocs and the documentation website on http://owner.aeonbits.org |
| 98 |
</echo> |
| 99 |
</target> |
| 100 |
|
| 101 |
<macrodef name="git"> |
| 102 |
<attribute name="dir"/> |
| 103 |
<attribute name="command"/> |
| 104 |
<element name="elements" optional="true" implicit="true"/> |
| 105 |
<sequential> |
| 106 |
<exec dir="@{dir}" executable="git" taskname="git"> |
| 107 |
<arg line="@{command}"/> |
| 108 |
<elements/> |
| 109 |
</exec> |
| 110 |
</sequential> |
| 111 |
</macrodef> |
| 112 |
|
| 113 |
<macrodef name="git-hash"> |
| 114 |
<attribute name="dir"/> |
| 115 |
<attribute name="property"/> |
| 116 |
<sequential> |
| 117 |
<git dir="@{dir}" command="log -1 --pretty=%h"> |
| 118 |
<redirector outputproperty="@{property}"/> |
| 119 |
</git> |
| 120 |
</sequential> |
| 121 |
</macrodef> |
| 122 |
|
| 123 |
<macrodef name="jekyll-serve"> |
| 124 |
<attribute name="options"/> |
| 125 |
<sequential> |
| 126 |
<tempfile deleteonexit="true" destdir="${site.directory}" prefix="_serve-" suffix=".yml" property="serve.file"/> |
| 127 |
<echo file="${serve.file}" message="url: http://localhost:4000"/> |
| 128 |
<jekyll dir="${site.directory}" command="serve" options="@{options} --config _config.yml,${serve.file}"/> |
| 129 |
</sequential> |
| 130 |
</macrodef> |
| 131 |
|
| 132 |
<macrodef name="jekyll"> |
| 133 |
<attribute name="dir"/> |
| 134 |
<attribute name="command"/> |
| 135 |
<attribute name="options"/> |
| 136 |
<sequential> |
| 137 |
<exec dir="@{dir}" executable="jekyll" taskname="jekyll"> |
| 138 |
<arg line="@{command} @{options} ${env.JEKYLL_OPTS}"/> |
| 139 |
</exec> |
| 140 |
</sequential> |
| 141 |
</macrodef> |
| 142 |
|
| 143 |
<macrodef name="mvn"> |
| 144 |
<attribute name="dir"/> |
| 145 |
<attribute name="command"/> |
| 146 |
<attribute name="options" default=""/> |
| 147 |
<sequential> |
| 148 |
<exec dir="@{dir}" executable="mvn" taskname="mvn"> |
| 149 |
<arg line="@{command} @{options}" /> |
| 150 |
</exec> |
| 151 |
</sequential> |
| 152 |
</macrodef> |
| 153 |
|
| 154 |
</project> |