Skip to main content
summaryrefslogtreecommitdiffstats
blob: 01b1e7868e06f9acdb9ad350285ec541ef0fbc28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!--
	This build script is an adoption of the build script being use for Eclipse.org Articles.
	Original authors: 	Chris Aniszczyk <zx@eclipsesource.com>,
						Lawrence Mandel <lmandel@ca.ibm.com>
						
	Other authors:		Peter Friese <peter.friese@itemis.com>
-->

<project name="org.eclipse.xpand.doc" default="docbook2html" basedir=".">
	
	<!-- ========== Properties: User Defined Options ========================= -->
	
	<property name="eclipse.plugin.id" value="org.eclipse.xpand.doc" />
	<property name="eclipse.plugin.name" value="Xpand core documentation (Incubation)" />
	<property name="eclipse.plugin.provider" value="Eclipse.org" />
	
	<property name="src.dir" value="src/5.0/content"/>
	<property name="article.name" value="xpand_reference"/>
	<property name="article.stylesheet" value="src/styles/xslt/custom_eclipse.xsl"/>
	
	<property name="dest.dir" value="."/>
	<property name="download.dir" value="${java.io.tmpdir}${file.separator}downloads"/>
	
	<property name="docbook.version" value="1.73.2" />
	<property name="docbook.dir" value="${download.dir}${file.separator}docbook-xsl-${docbook.version}"/>
	<property name="docbookxsl.url" value="http://internap.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-${docbook.version}.zip"/>
	<property name="fop.dir" value="${download.dir}${file.separator}fop-0.20.5"/>
	<property name="fop.url" value="http://archive.apache.org/dist/xmlgraphics/fop/binaries/fop-0.20.5-bin.zip"/>
	<property name="jai.dir" value="ENTER_JAI_DIRECTORY"/>
	
	<property name="build.home" value="build"/>
		
	<!-- ========== Macro Definition =================================================== -->	
	
    <macrodef name="docbook2pdf">
        <attribute name="source"/>
    	<attribute name="target"/>
        <sequential>
        	<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
        		<classpath>
        			<pathelement location="${fop.dir}${file.separator}build${file.separator}fop.jar" />
        			<pathelement location="${fop.dir}${file.separator}lib${file.separator}avalon-framework-cvs-20020806.jar" />
        			<pathelement location="${fop.dir}${file.separator}lib${file.separator}batik.jar" />
        			<pathelement location="${jai.dir}${file.separator}lib${file.separator}jai_core.jar" />
        			<pathelement location="${jai.dir}${file.separator}lib${file.separator}jai_codec.jar" />
        		</classpath>
        	</taskdef>
        	<fop 
        		format="application/pdf" 
        		fofile="@{source}" 
        		outfile="@{target}"
        		messagelevel="info"/>
        </sequential>
    </macrodef>
	
	<!-- ========== Targets =================================================== -->	
		
	<target name="init">
		<mkdir dir="${download.dir}"/>
		
		<available file="${jai.dir}" property="jai.exists"/>
		<antcall target="notifyJAI"/>
	</target>

	  <target name="build.update.jar" depends="init"
	    description="Build the plug-in: ${plugin} for an update site.">
	    <delete dir="${temp.folder}"/>
	    <mkdir dir="${temp.folder}"/>
	    <antcall target="build.jars"/>
	    <antcall target="gather.bin.parts">
	      <param name="destination.temp.folder" value="${temp.folder}/"/>
	    </antcall>
	    <zip destfile="${plugin.destination}/${docPlugin}_${pluginVersion}.jar"
	      basedir="${temp.folder}/${docPlugin}_${pluginVersion}" filesonly="false"
	      whenempty="skip" update="false"/>
	    <delete dir="${temp.folder}"/>
	  </target>
	  
	  <target name="build.jars" depends="init"
	    description="Build all the jars for the plug-in: ${docPlugin}.">
	    
	    <!-- Execute a shell script that will create an ant javadoc script and then run it for us -->
	    <exec executable="sh">
	      <arg value="build/antJavadoc.sh"/>
	      <arg value="${eclipse.home}/../eclipse"/>
	    </exec>
	    
	    <antcall target="build.index"/>
	    
	  </target>
	  
	  <target name="build.index" depends="init"
	    description="Builds search index for the plug-in" if="eclipse.running">
	    <help.buildHelpIndex manifest="plugin.xml" destination="."/>
	  </target>
	  
	  <target name="build.sources" depends="init">
	  </target>

	<target name="notifyJAI" unless="jai.exists">
		<echo message="The Java Advanced Imaging (JAI) library is not available."/>
		<echo message="JAI is required if you want to use PNG images in your article."/>
		<echo message="You can download JAI from http://java.sun.com/products/java-media/jai/downloads/download-1_1_2_01.html."/>
		<echo message="Specify the JAI installation directory to the article build by providing the parameter jai.dir to this build script."/>
	</target>
	
	<target name="build-doc" depends="init, get-docbook-xsl, get-fop">
		<echo>Building Help...</echo>
		<antcall target="docbook2html"/>
		<antcall target="docbook2pdf"/>
		<antcall target="dist"/>
	</target>
		
	<target name="check-docbook">
		<available file="${download.dir}${file.separator}docbook.zip" property="hasDocbook"/>
	</target>
	
	<target name="check-fop">
		<available file="${download.dir}${file.separator}fop.zip" property="hasFOP"/>
	</target>
		
	<target name="get-docbook-xsl" description="Downloads docbook xsl" depends="check-docbook" unless="hasDocbook">
		<echo>Downloading DocBook XSL...</echo>
		<get dest="${download.dir}${file.separator}docbook.zip" src="${docbookxsl.url}"/>
		<unzip src="${download.dir}${file.separator}docbook.zip" dest="${download.dir}"/>
	</target>
	
	<target name="get-fop" description="Downloads FOP" depends="check-fop" unless="hasFOP">
		<echo>Downloading FOP...</echo>
		<get dest="${download.dir}${file.separator}fop.zip" src="${fop.url}"/>
		<unzip src="${download.dir}${file.separator}fop.zip" dest="${download.dir}"/>
	</target>
	
	<target name="docbook2html">
		<echo>Converting article to HTML...</echo>
		<delete file="${dest.dir}${file.separator}${article.name}.html"/>
		<xslt in="${src.dir}${file.separator}${article.name}.xml" extension="xml" out="${dest.dir}${file.separator}${article.name}.html" style="${article.stylesheet}">
			<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
				<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
			</factory>
			<xmlcatalog>
				<entity 
					publicId="docbook.xsl"
					location="${docbook.dir}${file.separator}html${file.separator}docbook.xsl"/>
				<entity 
					publicId="eclipse.xsl"
					location="${docbook.dir}${file.separator}eclipse${file.separator}eclipse.xsl"/>
			</xmlcatalog>
			<param name="header.rule" expression="1" />
			<param name="admon.graphics.extension" expression=".gif"/>
			<param name="admon.textlabel" expression="0"/>
			<param name="ulink.target" expression="_new"/>
			<param name="eclipse.plugin.id" expression="${eclipse.plugin.id}" />
			<param name="eclipse.plugin.name" expression="${eclipse.plugin.name}" />
			<param name="eclipse.plugin.provider" expression="${eclipse.plugin.provider}" />
		</xslt>
	</target>
	
	<target name="docbook2pdf">
		<echo>Converting article to PDF...</echo>

		<delete file="${dest.dir}${file.separator}${article.name}.pdf"/>
		<delete file="${dest.dir}${file.separator}${article.name}.fo"/>
		<xslt in="${src.dir}${file.separator}${article.name}.xml" extension="xml" out="${dest.dir}${file.separator}${article.name}.fo" style="${docbook.dir}${file.separator}fo${file.separator}docbook.xsl">
			<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
				<attribute name="http://xml.apache.org/xalan/features/optimize" value="true"/>
			</factory>
			<xmlcatalog>
				<entity 
					publicId="docbook.xsl"
					location="${docbook.dir}${file.separator}fo${file.separator}docbook.xsl"/>
			</xmlcatalog>
			<param name="generate.toc" expression="book toc" />
			<param name="show.comments" expression="0" />
			<param name="header.rule" expression="1" />
			<param name="admon.graphics.extension" expression=".gif"/>
			<param name="admon.textlabel" expression="0"/>
			<param name="admon.graphics" expression="1"/>
		</xslt>
		
		<docbook2pdf 
			source="${dest.dir}${file.separator}${article.name}.fo"
			target="${dest.dir}${file.separator}${article.name}.pdf"/>
		
		<!-- Remove the resulting formatting object. This object isn't necessary in the
		     result of this build. -->
		<delete file="${dest.dir}${file.separator}${article.name}.fo"/>
	</target>
	
	<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
	    <mkdir dir="${destination.temp.folder}/${docPlugin}_${pluginVersion}"/>
	    <copy todir="${destination.temp.folder}/${docPlugin}_${pluginVersion}"
	      failonerror="false" overwrite="false">
	      <fileset dir="${basedir}" includes="${filesToInclude}"/>
	    </copy>
	    <eclipse.versionReplacer
	      path="${destination.temp.folder}/${docPlugin}_${pluginVersion}"
	      version="${pluginVersion}"/>
	  </target>
	  
	  <target name="build.zips" depends="init">
	  </target>
	  
	  <target name="gather.sources" depends="init" if="destination.temp.folder">
	  </target>
	  
	  <target name="gather.logs" depends="init" if="destination.temp.folder">
	  </target>
	  
	<!-- ================================= 
          target: clean              
         ================================= -->
    <target name="clean" description="Cleanup task">
    </target>

	<target name="dist">
		<echo>Building article zip file...</echo>
		<delete file="${dest.dir}${file.separator}${article.name}.zip"/>
		<zip basedir="${dest.dir}" destfile="${dest.dir}${file.separator}${article.name}.zip"
			 excludes="${article.name}.fo, ${article.name}.zip, .project">
		</zip>
		<echo>If you're done with your article, please post the zip file on the related bugzilla entry.</echo>
	</target>

</project>

Back to the top