|
974 | 974 | <else>
|
975 | 975 | <if>
|
976 | 976 | <!-- Then check for availability if unix -->
|
977 |
| - <available file="optipng" filepath="${ENV.PATH}"/> |
| 977 | + <available file="optipng" filepath="${ENV.PATH}"/> |
978 | 978 | <var name="optipng.executable" value="optipng"/>
|
979 | 979 | <if>
|
980 | 980 | <equals arg1="${images.optipng.newer}" arg2="true"/>
|
981 | 981 | <var name="optipng.available" value="true"/>
|
982 | 982 | </if>
|
| 983 | + <else> |
| 984 | + <var name="optipng.available.older" value="true"/> |
| 985 | + </else> |
983 | 986 | </if>
|
| 987 | + <else> |
| 988 | + <!-- Print out message if optipng is not available --> |
| 989 | + <echo message="*** optipng NOT INSTALLED. SKIPPING OPTIMIZATION OF PNGs." /> |
| 990 | + <echo message="*** Install optipng to enable png optimization." /> |
| 991 | + <echo message="*** For instructions see 'Dependencies' at: https://github.com/h5bp/ant-build-script/wiki/Platform" /> |
| 992 | + </else> |
984 | 993 | </else>
|
985 | 994 | </if>
|
986 |
| - |
987 |
| - <!-- Now check for availability --> |
| 995 | + |
988 | 996 | <if>
|
989 | 997 | <equals arg1="${optipng.available}" arg2="true"/>
|
990 | 998 | <then>
|
|
1018 | 1026 | </then>
|
1019 | 1027 | </if>
|
1020 | 1028 |
|
1021 |
| - <apply executable="${optipng.executable}" dest="./${dir.publish}/${relative.image.dir}/" osfamily="${os.family}"> |
| 1029 | + <apply executable="${optipng.executable}" dest="./${dir.publish}/${relative.image.dir}/"> |
1022 | 1030 | <fileset dir="./${dir.source}/${relative.image.dir}/" includes="**/*.png" excludes="${images.bypass}, ${images.default.bypass}"/>
|
1023 | 1031 | <arg value="-quiet"/>
|
1024 | 1032 | <arg value="-o7"/>
|
|
1033 | 1041 | </for>
|
1034 | 1042 | </then>
|
1035 | 1043 | <else>
|
1036 |
| - <!-- Print out message if optipng is not available --> |
1037 |
| - <echo message="*** optipng NOT INSTALLED. SKIPPING OPTIMIZATION OF PNGs." /> |
1038 |
| - <echo message="*** Install optipng to enable png optimization." /> |
1039 |
| - <echo message="*** For instructions see 'Dependencies' at: https://github.com/h5bp/ant-build-script/wiki/Platform" /> |
| 1044 | + <if> |
| 1045 | + <equals arg1="optipng.available.older" arg2="true"/> |
| 1046 | + <then> |
| 1047 | + <!-- work around https://sourceforge.net/tracker/?func=detail&aid=2671422&group_id=151404&atid=780916 --> |
| 1048 | + <if> |
| 1049 | + <available file="./${dir.publish}/${dir.images}/" type="dir" /> |
| 1050 | + <then> |
| 1051 | + <delete> |
| 1052 | + <fileset dir="./${dir.publish}/${dir.images}/"> |
| 1053 | + <include name="**/*.png"/> |
| 1054 | + </fileset> |
| 1055 | + </delete> |
| 1056 | + </then> |
| 1057 | + </if> |
| 1058 | + <!-- Run if available --> |
| 1059 | + <for param="image-dir"> |
| 1060 | + <path> |
| 1061 | + <dirset dir="${dir.source}" includes="${dir.images}"/> |
| 1062 | + </path> |
| 1063 | + <sequential> |
| 1064 | + <property name="relative.image.dir" location="@{image-dir}" relative="yes"/> |
| 1065 | + |
| 1066 | + <if> |
| 1067 | + <not> |
| 1068 | + <available file="${basedir}/${dir.publish}/${relative.image.dir}"/> |
| 1069 | + </not> |
| 1070 | + <then> |
| 1071 | + <copy todir="${dir.publish}/${relative.image.dir}"> |
| 1072 | + <dirset dir="${dir.source}/${relative.image.dir}"/> |
| 1073 | + </copy> |
| 1074 | + </then> |
| 1075 | + </if> |
| 1076 | + |
| 1077 | + <apply executable="${optipng.executable}" dest="./${dir.publish}/${relative.image.dir}/"> |
| 1078 | + <fileset dir="./${dir.source}/${relative.image.dir}/" includes="**/*.png" excludes="${images.bypass}, ${images.default.bypass}"/> |
| 1079 | + <arg value="-quiet"/> |
| 1080 | + <arg value="-o7"/> |
| 1081 | + <arg value="-out"/> |
| 1082 | + <targetfile/> |
| 1083 | + <srcfile/> |
| 1084 | + <mapper type="identity"/> |
| 1085 | + </apply> |
| 1086 | + <var name="relative.image.dir" unset="true"/> |
| 1087 | + </sequential> |
| 1088 | + </for> |
| 1089 | + </then> |
| 1090 | + </if> |
1040 | 1091 | </else>
|
| 1092 | + |
1041 | 1093 | </if>
|
1042 | 1094 | <!-- Let's do ADVPNG -->
|
1043 | 1095 | <!-- On *nix's and OS X, check for advpng and give a helpful message if it's not installed -->
|
|
1086 | 1138 | </then>
|
1087 | 1139 | </if>
|
1088 | 1140 |
|
1089 |
| - <apply executable="${advpng.executable}" dest="./${dir.publish}/${relative.image.dir}/" osfamily="${os.family}"> |
| 1141 | + <apply executable="${advpng.executable}" dest="./${dir.publish}/${relative.image.dir}/"> |
1090 | 1142 | <fileset dir="./${dir.publish}/${relative.image.dir}/" includes="**/*.png" excludes="${images.bypass}, ${images.default.bypass}"/>
|
1091 | 1143 | <arg line="-z"/>
|
1092 | 1144 | <arg line="-4"/>
|
|
1161 | 1213 | </then>
|
1162 | 1214 | </if>
|
1163 | 1215 |
|
1164 |
| - <apply executable="${jpegtran.executable}" dest="./${dir.publish}/${relative.image.dir}" osfamily="${os.family}"> |
| 1216 | + <apply executable="${jpegtran.executable}" dest="./${dir.publish}/${relative.image.dir}"> |
1165 | 1217 | <fileset dir="${dir.source}/${relative.image.dir}" includes="**/*.jpg" excludes="${images.bypass}, ${images.default.bypass}"/>
|
1166 | 1218 | <arg value="-copy"/>
|
1167 | 1219 | <arg value="${retain-meta-tags}"/>
|
|
0 commit comments