<!--
 * ========================================================================
 * 
 * Copyright 2004 Acegi Technology Pty Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * ========================================================================
-->

<project
   xmlns:j="jelly:core"
   xmlns:ant="jelly:ant"
   xmlns:util="jelly:util"
   xmlns:maven="jelly:maven"
  >

    <postGoal name="sdocbook:prepare-filesystem">
        <j:set var="unzipped" value="false" />
        <util:available file="${maven.sdocbook.generated.fo}">
            <j:set var="unzipped" value="true" />
            <echo>Using previusly unzipped docbook files</echo>
        </util:available>
        <j:if test="${!unzipped}">
            <!-- unzip docbook files -->
            <ant:unzip dest="${maven.build.dir}"
                src="${pom.getDependencyPath('docbook:docbook-xsl')}"/>
                
            <!-- use a custom fo stylesheet -->
            <move file="${maven.sdocbook.stylesheets.dir}/fo/docbook.xsl"
                tofile="${maven.sdocbook.stylesheets.dir}/fo/docbook-bak.xsl"/>
            <copy todir="${maven.sdocbook.stylesheets.dir}/fo">
                <fileset dir="${maven.sdocbook.src.dir}/styles/fo"/>
            </copy>

            <!-- use a custom html stylesheet -->
            <move file="${maven.sdocbook.stylesheets.dir}/html/docbook.xsl"
                tofile="${maven.sdocbook.stylesheets.dir}/html/docbook-bak.xsl"/>
            <copy todir="${maven.sdocbook.stylesheets.dir}/html">
                <fileset dir="${maven.sdocbook.src.dir}/styles/html"/>
            </copy>

            <!-- copy images -->
            <copy todir="${maven.sdocbook.stylesheets.dir}/images">
                <fileset dir="${maven.sdocbook.src.dir}/images"/>
            </copy>
        </j:if>

    </postGoal>

    <preGoal name="site">
        <attainGoal name="sdocbook"/>
    </preGoal>

</project>
