|
1 | | -<project default="gh-pages"> |
| 1 | +<project default="gh-pages" xmlns="antlib:org.apache.tools.ant" xmlns:if="ant:if" xmlns:unless="ant:unless"> |
2 | 2 |
|
3 | 3 | <!-- |
4 | 4 | DON'T run this file in order to push gh-pages. Instead run: |
5 | | - mvn site -N -P gh-pages |
| 5 | + mvn clean javadoc:javadoc -P gh-pages |
| 6 | + mvn antrun:run -N -P gh-pages |
6 | 7 | Javadoc will be generated and sync for sure |
7 | 8 | --> |
8 | 9 | <target name="gh-pages"> |
|
21 | 22 | <arg value="." /> |
22 | 23 | </exec> |
23 | 24 |
|
24 | | - <echo file="${workdir}/index.md" message="--- layout: index --- " /> |
25 | | - |
26 | | - <concat destfile="${workdir}/index.md" append="true"> |
27 | | - <fileset file="README.md" /> |
28 | | - </concat> |
| 25 | + <antcall target="md.generator" /> |
29 | 26 |
|
30 | 27 | <delete dir="${workdir}/apidocs" failonerror="false" /> |
31 | 28 |
|
|
35 | 32 | <fileset dir="target/site/apidocs" /> |
36 | 33 | </copy> |
37 | 34 |
|
| 35 | + <!-- move README.md --> |
| 36 | + <move file="${workdir}/README.md" tofile="README.md" overwrite="true" /> |
| 37 | + |
| 38 | + <!-- Override javadoc stylesheet --> |
| 39 | + <copy file="${workdir}/stylesheets/apidoc.css" tofile="${workdir}/apidocs/stylesheet.css" overwrite="true" /> |
| 40 | + |
| 41 | + <!-- --> |
38 | 42 | <exec executable="git" dir="${workdir}"> |
39 | 43 | <arg value="add" /> |
40 | | - <arg value="--all" /> |
| 44 | + <arg value="-A" /> |
41 | 45 | </exec> |
42 | 46 |
|
43 | 47 | <exec executable="git" dir="${workdir}"> |
|
53 | 57 | </exec> |
54 | 58 |
|
55 | 59 | </target> |
| 60 | + |
| 61 | + <target name="md.generator"> |
| 62 | + <!-- / --> |
| 63 | + <antcall target="md.processor"> |
| 64 | + <param name="inputmd" value="README.md" /> |
| 65 | + </antcall> |
| 66 | + |
| 67 | + <!-- /quickstart --> |
| 68 | + <antcall target="md.processor"> |
| 69 | + <param name="inputmd" value="quickstart/index.md" /> |
| 70 | + </antcall> |
| 71 | + |
| 72 | + <!-- /doc --> |
| 73 | + <antcall target="md.processor"> |
| 74 | + <param name="inputmd" value="doc/index.md" /> |
| 75 | + </antcall> |
| 76 | + |
| 77 | + <!-- /faq --> |
| 78 | + <antcall target="md.processor"> |
| 79 | + <param name="inputmd" value="faq/index.md" /> |
| 80 | + </antcall> |
| 81 | + |
| 82 | + <!-- /modules --> |
| 83 | + <antcall target="md.processor"> |
| 84 | + <param name="inputmd" value="modules/index.md" /> |
| 85 | + </antcall> |
| 86 | + </target> |
| 87 | + |
| 88 | + <!-- |
| 89 | + Replace expressions like {{file.md}} from an input file. The expression: {{file.md}} is replaced |
| 90 | + by the content of the file.md, so file.md must exists. |
| 91 | +
|
| 92 | + A table of content (toc) is generated too using the content of the generated file. |
| 93 | +
|
| 94 | + @param inputmd The file to process |
| 95 | + --> |
| 96 | + <target name="md.processor"> |
| 97 | + |
| 98 | + <antcall target="md.merger"> |
| 99 | + <param name="inputmd" value="${inputmd}" /> |
| 100 | + </antcall> |
| 101 | + |
| 102 | + <script language="javascript" src="md/toc.js" /> |
| 103 | + </target> |
| 104 | + |
| 105 | + <!-- |
| 106 | + Replace expressions like {{file.md}} from an input file. The expression: {{file.md}} is replaced |
| 107 | + by the content of the file.md, so file.md must exists. |
| 108 | +
|
| 109 | + @param inputmd The file to process |
| 110 | + --> |
| 111 | + <target name="md.merger"> |
| 112 | + <macrodef name="iterate"> |
| 113 | + <attribute name="list" /> |
| 114 | + <element name="call" implicit="yes" /> |
| 115 | + <sequential> |
| 116 | + <local name="md" /> |
| 117 | + <local name="md.value" /> |
| 118 | + <local name="tail" /> |
| 119 | + <local name="hasMoreElements" /> |
| 120 | + |
| 121 | + <!-- unless to not get a error on empty lists --> |
| 122 | + <loadresource property="md" unless:blank="@{list}"> |
| 123 | + <concat>@{list}</concat> |
| 124 | + <filterchain> |
| 125 | + <replaceregex pattern="([^;]*).*" replace="\1" /> |
| 126 | + </filterchain> |
| 127 | + </loadresource> |
| 128 | + |
| 129 | + <loadfile property="md.value" srcfile="target/md/${md}" /> |
| 130 | + |
| 131 | + <!-- recursion --> |
| 132 | + <condition property="hasMoreElements"> |
| 133 | + <contains string="@{list}" substring=";" /> |
| 134 | + </condition> |
| 135 | + |
| 136 | + <loadresource property="tail" if:true="${hasMoreElements}"> |
| 137 | + <concat>@{list}</concat> |
| 138 | + <filterchain> |
| 139 | + <replaceregex pattern="[^;]*;(.*)" replace="\1" /> |
| 140 | + </filterchain> |
| 141 | + </loadresource> |
| 142 | + |
| 143 | + <call /> |
| 144 | + |
| 145 | + <sequential if:true="${hasMoreElements}"> |
| 146 | + <iterate list="${tail}"> |
| 147 | + <call /> |
| 148 | + </iterate> |
| 149 | + </sequential> |
| 150 | + </sequential> |
| 151 | + </macrodef> |
| 152 | + |
| 153 | + <copy todir="target/md"> |
| 154 | + <fileset dir="md"> |
| 155 | + <include name="**/*.md" /> |
| 156 | + </fileset> |
| 157 | + </copy> |
| 158 | + |
| 159 | + <fileset id="docfiles" dir="target/md"> |
| 160 | + <include name="*.md" /> |
| 161 | + </fileset> |
| 162 | + |
| 163 | + <pathconvert property="docfiles" refid="docfiles" pathsep=";"> |
| 164 | + <mapper> |
| 165 | + <flattenmapper /> |
| 166 | + </mapper> |
| 167 | + </pathconvert> |
| 168 | + |
| 169 | + <property name="finmd" value="target/gh-pages/${inputmd}" /> |
| 170 | + <copy file="target/md/${inputmd}" tofile="${finmd}" overwrite="true" /> |
| 171 | + |
| 172 | + <echo message="processing: ${finmd}" /> |
| 173 | + <iterate list="${docfiles}"> |
| 174 | + <echo message=" replacing: {{${md}}}" /> |
| 175 | + <replace file="${finmd}" token="{{${md}}}" value="${md.value}" /> |
| 176 | + </iterate> |
| 177 | + </target> |
| 178 | + |
56 | 179 | </project> |
0 commit comments