<project>

	<!--
		This ANT build script is only there to upload JAVADOC to a web server so that they are publicly accessible
		from the internet.
	-->
	<property file="local_build.properties" />
	<property file="build.properties" />

	<taskdef classpath="lib/antology-2.0.7-SNAPSHOT-antlib.jar" resource="de/unkrig/antology/ant.xml" />

	<taskdef classpath="lib/ant-contrib-1.0b3.jar" resource="net/sf/antcontrib/antlib.xml" />

	<target name="publish.javadoc" description="Uploads '../de.unkrig.commons.*/target/apidocs' to a web site">

		<echo message="IMPORTANT: Notice that the links between the module's javadocs are generated correctly iff the" />
		<echo message="apidocs are generated by the aggregator (commons-parent)!" />

		<!-- Have the FTP parameters entered/confirmed by the user. -->
		<swingLookAndFeel system="true" />
		<swingDialog title="FTP upload to project site">
			<text label="Server:"           labelWidth="160" property="ftp.server"    defaultvalue="${ftp.server}"    />
			<text label="Port (optional):"  labelWidth="160" property="ftp.port"      defaultvalue="${ftp.port}"      />
			<text label="Remote directory:" labelWidth="160" property="ftp.remotedir" defaultvalue="${ftp.remotedir}" />
			<checkbox text="Use passive FTP"   property="ftp.passive" preselected="true" />
			<checkbox text="Verbose reporting" property="ftp.verbose" preselected="true" />
			<separator />
			<label text="FTP proxy (optional):" />
			<text label="Proxy server:"          labelWidth="160" property="ftp.proxy.server" defaultvalue="${ftp.proxy.server}" />
			<text label="Proxy port (optional):" labelWidth="160" property="ftp.proxy.port"   defaultvalue="${ftp.proxy.port}"   />
		</swingDialog>
		<setAuthenticator />

		<!-- Do the uploads. -->
		<forEach2 param="apidocs.dir">
			<dirset dir=".." includes="commons-*/target/apidocs" />
			<sequential>

				<var name="module-name" unset="true" />
				<basename file="@{apidocs.dir}/../.." property="module-name" />

				<ftp2
					server       ="${ftp.server}"
					port         ="${ftp.port}"
				    proxyServer  ="${ftp.proxy.server}"
				    proxyPort    ="${ftp.proxy.port}"
				    proxyUserid  ="${ftp.proxy.userid}"
				    proxyPassword="${ftp.proxy.password}"
					remotedir    ="${ftp.remotedir}/${module-name}/apidocs"
					passive      ="${ftp.passive}"
					verbose      ="${ftp.verbose}"
					action       ="put"
				>
					<fileset dir="@{apidocs.dir}" />
				</ftp2>
			</sequential>
		</forEach2>
	</target>
</project>
