<project name="evo-app-build-obfuscate-common">

	<target name="obfuscate">
		<taskdef resource="proguard/ant/task.properties" classpath="${app.dir}/lib.tools/proguard.jar" />

		<delete file="${app.deploy.dist.dir}/${evolute.jar.name}" failonerror="false" />

		<proguard printmapping="${app.dir}/${app.name}.map">

			<injar file="${app.lib.dir}/evologger.jar" />
			<outjar file="${app.deploy.dist.lib.dir}/evologger.jar" />
			
			<injar file="${app.lib.dir}/evolute.jar" />
			<outjar file="${app.deploy.dist.lib.dir}/evolute.jar" />

			<injar file="${app.deploy.dist.dir}/${app.jar.name}" />
			<outjar file="${app.deploy.dist.dir}/${app.jar.name}_guard.jar" />

			<libraryjar file="${evolute.lib.dir}" />
			<libraryjar file="${app.lib.dir}" />
			<libraryjar file="${java.home}/lib/jce.jar" />
			<libraryjar file="${java.home}/lib/jsse.jar" />
			<libraryjar file="${java.home}/lib/rt.jar" />
					
					-printseeds
					-verbose
					-dontskipnonpubliclibraryclasses
					
					-keepclasseswithmembers public class * {
								        public static void main(java.lang.String[]);
								    }
			</proguard>
		<delete file="${app.deploy.dist.dir}/${app.jar.name}" failonerror="true" />
		<move file="${app.deploy.dist.dir}/${app.jar.name}_guard.jar" tofile="${app.deploy.dist.dir}/${app.jar.name}" />
	</target>

	<target name="ProguardTask">
		<property file="${app.version.file}" prefix="version" />
		<typedef classpathref="lib.tools.classpath" resource="net/jtools/classloadertask/antlib.xml">
			<classpath>
				<path refid="lib.tools.classpath"/>
			</classpath>
		</typedef>
		<classloader loader="project">
			<classpath>
				<fileset dir="${lib.tools.dir}" includes="*.jar"/>
				<fileset dir="${app.lib.dir}" includes="*.jar"/>
			</classpath>
		</classloader>
		<taskdef name="proguardtask" classpathref="lib.tools.classpath" classname="com.evolute.ant.ProguardTask" />

		<proguardtask filePath="${app.dir}/${app.name}.map" version="${version.major}.${version.minor}.${version.build}" fileName="${app.name}.map" projectName="${app.name}" />
	</target>

	<target name="pre-deploy">
		<antcall target="obfuscate" />
		<antcall target="ProguardTask" />
	</target>

</project>