mindmapping_to_opale.ant 9.58 KB
Newer Older
1 2 3
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="default">
    <property name="module" value="default"/>
4 5
    <property name="in" location="${basedir}/input"/>
    <property name="out" value="${basedir}/result"/>
6 7
    <property name="resultFile" value="${basedir}/result"/>
    
8 9 10 11 12 13 14 15 16 17 18 19
    <taskdef resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="${basedir}/lib/ant-contrib.jar"/>
        </classpath>
    </taskdef>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
        <classpath>
            <pathelement location="${basedir}/lib/ant-contrib.jar"/>
        </classpath>
    </taskdef>
    
    
20
    <target name="default" depends="preparation">
21 22 23 24 25
        <echo>----------------------------Begin of
            conversion----------------------------------</echo>
        
        <antcall target="conversion"/>
        
26 27 28
        <echo>----------------------------End of conversion----------------------------------</echo>
    </target>
    
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
    <target depends="ifOSWindows, ifOSUnix" name="conversion"/>
    
    <condition property="isOSUnix">
        <os family="unix" />
    </condition>
    
    <condition property="isOSWindows">
        <os family="windows" />
    </condition>
    
    <!-- if the OS is windows call the target run.script.windows -->
    <target name="ifOSWindows" if="isOSWindows">
        <echo>is Windows........</echo>
        <echo>InputPath : ${inputPath}</echo>
        <if>
            <isset property="inputPath"/>
            <then>
                <antcall target="conversion.windows.input-path"/>
            </then>
            <else>
                <antcall target="conversion.windows.no-input-path"/>
            </else>
        </if>
    </target>
    
    <!-- if the OS is not windows call the target run.script.unix-->
    <target name="ifOSUnix" if="isOSUnix">
        <echo>is Unix........</echo>
        <echo>InputPath : ${inputPath}</echo>
        <if>
            <isset property="inputPath"/>
            <then>
                <antcall target="conversion.linux.input-path"/>
            </then>
            <else>
                <antcall target="conversion.linux.no-input-path"/>
            </else>
        </if>
    </target>
    
    <target name="conversion.windows.input-path">
        <basename property="filename" file="${inputPath}" suffix=".mm"/>
        <echo>There is an input path in parameter : conversion of this file</echo>
        <!-- Conversion from mm to hdoc -->
        <exec dir="${basedir}/../mindmapping_to_hdoc" executable="cmd">
            <arg value="${basedir}/../mindmapping_to_hdoc/run.bat"/>
            <arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
        </exec>
        <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
        <!-- Conversion from hdoc to scar -->
        <!-- Files have to be copied in hdoc_to_opale in order to be treated -->
        <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
        <exec dir="${basedir}/../hdoc_to_opale" executable="cmd">
            <arg value="${basedir}/../hdoc_to_opale/run.bat"/>
        </exec>
        <copy todir="${resultFile}/scar/${filename}">
            <fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
        </copy>
    </target>
    
    <target name="conversion.windows.no-input-path">
        <echo>There is no input path in parameter : conversion of all the files in ./input</echo>
        <for param="inputFile">
            <path>
                <fileset dir="${in}" includes="**/*.mm"/>
            </path>
            <sequential>
                <local name="filename"/>
                <basename property="filename" file="@{inputFile}" suffix=".mm"/>
                <!-- Conversion from mm to hdoc -->
                <!-- Conversion script is call with the file in parameter (no copy of files in minmapping_to_hdoc) -->
                <exec dir="${basedir}/../mindmapping_to_hdoc" executable="cmd">
                    <arg value="${basedir}/../mindmapping_to_hdoc/run.bat"/>
                    <arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
                </exec>
                <property name="filename" value="${filename}"/>
                <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
                <!-- Conversion from hdoc to scar -->
                <!-- Files have to be copied in hdoc_to_opale in order to be treated -->
                <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
                <exec dir="${basedir}/../hdoc_to_opale" executable="cmd">
                    <arg value="${basedir}/../hdoc_to_opale/run.bat"/>
                </exec>
                <copy todir="${resultFile}/scar/${filename}">
                    <fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
                </copy>
            </sequential>
        </for>
    </target>
    
    <target name="conversion.linux.input-path">
        <basename property="filename" file="${inputPath}" suffix=".mm"/>
        <echo>There is an input path in parameter : conversion of the file ${inputPath}</echo>
        <!-- Conversion from mm to hdoc -->
        <exec dir="${basedir}/../mindmapping_to_hdoc" executable="/bin/sh">
            <arg value="${basedir}/../mindmapping_to_hdoc/run.sh"/>
            <arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
        </exec>
        <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
        <!-- Conversion from hdoc to scar -->
        <!-- Files have to be copied in hdoc_to_opale in order to be treated -->
        <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
        <exec dir="${basedir}/../hdoc_to_opale" executable="/bin/sh">
            <arg value="${basedir}/../hdoc_to_opale/run.sh"/>
        </exec>
        <copy todir="${resultFile}/scar/${filename}">
            <fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
        </copy>
    </target>
    
    <target name="conversion.linux.no-input-path">
        <echo>There is no input path in parameter : conversion of all the files in ./input</echo>
        <for param="inputFile">
            <path>
                <fileset dir="${in}" includes="**/*.mm"/>
            </path>
            <sequential>
                <local name="filename"/>
                <basename property="filename" file="@{inputFile}" suffix=".mm"/>
                <!-- Conversion from mm to hdoc -->
                <!-- Conversion script is call with the file in parameter (no copy of files in minmapping_to_hdoc) -->
                <exec dir="${basedir}/../mindmapping_to_hdoc" executable="/bin/sh">
                    <arg value="${basedir}/../mindmapping_to_hdoc/run.sh"/>
                    <arg line="-DinputPath ./../mindmapping_to_opale/input/${filename}.mm"/>
                </exec>
                <property name="filename" value="${filename}"/>
                <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${resultFile}/hdoc"/>
                <!-- Conversion from hdoc to scar -->
                <!-- Files have to be copied in hdoc_to_opale in order to be treated -->
                <copy file="${basedir}/../mindmapping_to_hdoc/result/${filename}.hdoc" todir="${basedir}/../hdoc_to_opale/input"/>
                <exec dir="${basedir}/../hdoc_to_opale" executable="/bin/sh">
                    <arg value="${basedir}/../hdoc_to_opale/run.sh"/>
                </exec>
                <copy todir="${resultFile}/scar/${filename}">
                    <fileset dir="${basedir}/../hdoc_to_opale/output/${filename}"/>
                </copy>
            </sequential>
        </for>
    </target>
    
    <!--<target name="hdoc_conversion" depends="hdoc_conversion.input-path, hdoc_conversion.no-input-path" />
	-->
    
172 173
    <target name="preparation">
        <echo>Setting up the conversion</echo>
174 175 176 177
        <delete dir="${basedir}/temp"/>
        <mkdir dir="${basedir}/temp"/>
        <delete dir="${basedir}/result"/>
        <mkdir dir="${basedir}/result"/>
178 179 180 181 182 183 184
        <delete dir="${resultFile}/hdoc"></delete>
        <mkdir dir="${resultFile}/hdoc" />
        <delete dir="${resultFile}/scar"></delete>
        <mkdir dir="${resultFile}/scar" />
        <echo>--- End ----</echo>
    </target>
    
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
    <!-- Convert a mindMap file into a hdoc, with a xsl schema specified in the parameter -->
    <target name="Makehdoc">
        <echo>Begin data conversion</echo>
        <mkdir dir="${basedir}/temp/${hdocName}"/>
        <mkdir dir="${basedir}/temp/${hdocName}/META-INF"/>
        <copy file="${basedir}/mimetype" tofile="${basedir}/temp/${hdocName}/mimetype"/>
        <!-- create the container file with an XSLT transformation -->
        <xslt classpath="lib/saxon9he.jar" in="${basedir}/${inputPath}"
            out="${basedir}/temp/${hdocName}/META-INF/container.xml"
            xslresource="${basedir}/xslt/makeContainer.xsl"/>
        <!-- create the file which contains the freemind data converted-->
        <xslt classpath="lib/saxon9he.jar" in="${basedir}/${inputPath}"
            out="${basedir}/temp/${hdocName}/content.xml" xslresource="${basedir}/xslt/${myXSLT}"/>
        
        <!-- zipping files as the hdoc format -->
        <zip destfile="${resultFile}/${hdocName}.hdoc" basedir="${basedir}/temp/${hdocName}"/>
        <!-- </condition> -->
        
        <echo>end data conversion</echo>
    </target>
    
</project>