hdoc_to_optim.ant 3.18 KB
Newer Older
Drain's avatar
Drain committed
1
<project name="hdoc_to_optim" default="convert">
2
3

	<!-- Arguments properties -->
4
	<property name="InputFile" 			value="none" />
5
6
7
8
	<property name="InputPath" 			value="input" />
	<property name="OutputPath" 		value="output" />
	<property name="OutputScarPath" 			value="${OutputPath}/result.scar" />
	
9
    <target name="convert" depends="-condition, -noinput, -input"></target>
10
	
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
	<!--Check wether there is an input using command line or not-->
	<target name="-condition">
		<condition property="do.noinput">
            <equals arg1="${InputFile}" arg2="none" />
        </condition>
        <condition property="do.input">
            <not>
                <equals arg1="${InputFile}" arg2="none" />
            </not>
        </condition>
	</target>
	
	<!--There is no input, check the input folder-->
	<target name="-noinput" if="do.noinput">
        <echo message="The value of property InputFile is none... Checking the input folder" />
26
27
28
29
		<!-- get input hdoc file path -->
		<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
			<include name="*.hdoc"/>
		</fileset>
30
		<pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc" />
31
		
32
33
		<echo message="Executing conversion..." />
	
Drain's avatar
Drain committed
34
        <!--unzips the hdoc to be converted-->
35
        <unzip dest="hdoc" src ="${HdocFile}"/>
36
37
        
		<!--gives all rights to avoid bugs-->
Drain's avatar
Drain committed
38
        <chmod dir="hdoc" perm="777"/>
39
40
41
        
		<!--launches the XSLT find_content to retrieve the content path-->
        <xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl"/>
Drain's avatar
Drain committed
42
        <chmod file="get_content.ant" perm="777"/>
43
44

		<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
Drain's avatar
Drain committed
45
        <ant antfile="get_content.ant"/>
46
		<!--once the conversion is complete, the result is zipped-->
47
        <zip basedir="result" destfile="${OutputScarPath}" encoding="UTF-8"/>
48
49
        
		<!--temporary files and folders are deleted-->
50
51
        <!--<delete dir="hdoc"/>
        <delete dir="result"/>-->
Drain's avatar
Drain committed
52
53
        <delete file="get_content.ant"/>
        <delete file="get_ressources.ant"/>
54
55
56
57
58
    </target>
	
	<!--There is an input-->
	<target name="-input" if="do.input">
        <echo message="The value of property InputFile is ${InputFile}" />
59
		
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
		<echo message="Executing conversion..." />
	
        <!--unzips the hdoc to be converted-->
        <unzip dest="hdoc" src ="${InputFile}"/>
        
		<!--gives all rights to avoid bugs-->
        <chmod dir="hdoc" perm="777"/>
        
		<!--launches the XSLT find_content to retrieve the content path-->
        <xslt in="hdoc/META-INF/container.xml" out="get_content.ant" style="xsl/find_content.xsl"/>
        <chmod file="get_content.ant" perm="777"/>

		<!--launches the ANT get_content resulting from the previous XSLT in order to launch the conversion-->
        <ant antfile="get_content.ant"/>
		<!--once the conversion is complete, the result is zipped-->
        <zip basedir="result" destfile="${OutputScarPath}" encoding="UTF-8"/>
        
		<!--temporary files and folders are deleted-->
        <!--<delete dir="hdoc"/>
        <delete dir="result"/>-->
        <delete file="get_content.ant"/>
        <delete file="get_ressources.ant"/>
Drain's avatar
Drain committed
82
    </target>
83

Drain's avatar
Drain committed
84
</project>