<project name="helloA-wrapper" xmlns:ivy="antlib:org.apache.ivy.ant">
	<property file="build-wrapper.properties"/>
	
	<property name="module.builder.antfile" value="build.xml"/>
		
	<!-- Properties derived from ivy properties -->
	<condition property="ivy-file.error" value="ivy file undefined or not found: ${ivy-file.filename}">
		<or>
			<not><isset property="ivy-file.filename"/></not>
			<not><available file="${ivy-file.filename}"/></not>
		</or>
	</condition>
	
	<fail message="${ivy-file.error}" if="ivy-file.error"/>
	<xmlproperty file="${ivy-file.filename}" collapseAttributes="true"/>
	<property name="module.name" value="${ivy-module.info.module}"/>
	<property name="organisation.name" value="${ivy-module.info.organisation}"/>
	
	<property file="${version.filepath}"/>
	
	<!-- Ivy-related properties -->
	<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
	<condition property="skip.ivy.download" value="true">
		<and>
			<available file="${ivy.jar.file}"/>
			<not>
				<isset property="force.ivy.download"/>
			</not>
		</and>

	</condition>
	
    <target name="download-ivy" unless="skip.ivy.download">
    	<mkdir dir="${ivy.jar.dir}"/>
		<!-- download Ivy from web site for bootstrapping -->
		<echo message="retrieving ivy..."/>
    	<get src="${ivy.download.url}"
    	    dest="${ivy.jar.file}" usetimestamp="true"/>
    </target>
	
    <target name="bootstrap-ivy" depends="download-ivy">
    	<path id="ivy.lib.path">
    	    <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
    	</path>
    	<taskdef resource="org/apache/ivy/ant/antlib.xml"
    	          uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    	<!-- IVY-771:  change the override behavior here or remove the attribute and see what you get -->
		<ivy:settings file="${ivy-settings.filename}" id="module-settings"/>
    </target>

	<target name="resolve-dependencies" depends="bootstrap-ivy">
		<!-- pull all dependencies described in ${ivy-file.filename} into ivy cache -->
    	<ivy:resolve file="${ivy-file.filename}"
    		settingsRef="module-settings"/>
		<echo message="ivy.deps.changed is ${ivy.deps.changed}"/>
	</target>

	<target name="retrieve-dependencies" depends="resolve-dependencies">
		<!-- copy (map) all dependencies described in ${ivy-file.filename} into ${retrieved.lib.subdir} -->
		<ivy:retrieve pattern="${basedir}/${retrieved.lib.subdir}/[organisation]/[artifact]-[revision].[ext]" type="jar"/>
	</target>
	
	<target name="build-module" depends="retrieve-dependencies">
		<ant antfile="${module.builder.antfile}" target="jar-all"/>
	</target>
	
	<target name="clean">
		<ant antfile="${module.builder.antfile}" target="clean"/>
	</target>
	
	<target name="stage-local" depends="build-module">
		<antcall target="stage-local-impl"/>
	</target>
	
	<target name="make-pom" depends="bootstrap-ivy">
		<ivy:makepom ivyfile="${ivy-file.filename}" pomfile="${pom.output.subdir}/${module.name}.pom"/>
	</target>
	
	<target name="stage-local-impl" depends="bootstrap-ivy,make-pom">
		<ivy:resolve file="${ivy-file.filename}"
	    		settingsRef="module-settings"/>
		<ivy:publish settingsRef="module-settings"
			resolver="local-staging"
			organisation="${organisation.name}"
			module="${module.name}"
			update="true"
			overwrite="true"
			publishivy="true"
			revision="${version.number}">
			<artifacts pattern="${basedir}/${module.output.subdir}/[artifact].[ext]"/>
		</ivy:publish>
	</target>
	
	<target name="stage-central" depends="bootstrap-ivy,make-pom">
		<ivy:resolve file="${ivy-file.filename}"
	    		settingsRef="module-settings"/>
		<ivy:publish settingsRef="module-settings"
			resolver="rm-central-fs"
			organisation="${organisation.name}"
			module="${module.name}"
			update="true"
			overwrite="true"
			publishivy="true"
			revision="${version.number}">
			<artifacts pattern="${basedir}/${module.output.subdir}/[artifact].[ext]"/>
		</ivy:publish>
	</target>
	
	<target name="clean-retrieved-libs">
		<delete includeemptydirs="true" failonerror="false" verbose="true">
			<fileset dir="${retrieved.lib.subdir}"/>
		</delete>
	</target>
	
	<target name="clean-ivycache" depends="bootstrap-ivy" 
		description="--> clean the ivy cache">
	<ivy:cleancache settingsRef="module-settings"/>
	</target>
</project>