build.xml 5.44 KB
Newer Older
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

<project name="ConfigFileEditor" default="release" basedir=".">

  <!-- we want to use the existing project properties -->
  <property file="nbproject/project.properties"/>

  <!-- uncomment to get compile-single, etc. for NetBeans
  <import file="nbproject/build-impl.xml"/>
  -->

	<target name="init">
		<property name="deprecation" value="yes"/>
		<property name="debug" value="yes"/>
		<property name="optimize" value="no"/>
		<property file="build.props"/>

		<property name="resources.dir" value="resources"/>
		<property name="lib.dir" value="lib"/>
		<property name="release_dir" value="release"/>
		<property name="dist.lib.dir" value="${dist.dir}/lib"/>
		<property name="dist.resources.dir" value="${dist.dir}/resources"/>

		<property name="aboutfile" value="${src.views.dir}/AboutTEIKACE.java"/>
		<property name="mainfile" value="${src.views.dir}/TeikaceMainWindowForm.java"/>
		<property name="cfe_mf" value="MANIFEST.MF"/>

		<property name="dist.jsfile" value="${dist.dir}/CableLabsCFE.jsmooth"/>
		<property name="dist.install.exe" value="${dist.dir}/CableLabsCFE-${cfeversion}.exe"/>
		<property name="izpack_install_xml" value="${dist.dir}/install.xml"/>
		<property name="dist.install.jar"
			value="${dist.dir}/CableLabsCFE-${cfeversion}.jar"/>

		<!--  setclasspath to external libs -->
		<path id="cfe_classpath">
			<pathelement location="${build.classes.dir}"/>
			<fileset dir="${lib.dir}">
				<include name="*.jar"/>
			</fileset>
		</path>
	</target>

	<target name="jar" depends="init,compile">
		<jar destfile="${dist.jar}" manifest="${src.dir}/META-INF/${cfe_mf}" compress="yes">
			<fileset dir="${build.classes.dir}">
				<include name="com/cablelabs/**/*.class"/>
			</fileset>
			<fileset dir="${src.dir}">
				<include name="images/**"/>
			</fileset>
		</jar>
	</target>

	<target name="jsmooth_cfe" depends="init,jar,init_js_iz">
		<taskdef name="jsmoothgen"
			classpath="${jsant_jar}"
			classname="net.charabia.jsmoothgen.ant.JSmoothGen"/>
		<taskdef name="izpack"
			classpath="${izant_jar}"
			classname="com.izforge.izpack.ant.IzPackTask"/>
		<izpack input="${izpack_install_xml}"
			output="${dist.install.jar}"
			basedir="${dist.dir}"/>
		<jsmoothgen project="${dist.jsfile}"
			skeletonroot="${jshome}/skeletons"/>
	</target>

67
	<target name="compile" depends="init,copyfiles">
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
		<echo message="Compiling sources ... "/>
		<copy file="${aboutfile}" toFile="${aboutfile}.bak" preservelastmodified="true"/>
		<copy file="${mainfile}" toFile="${mainfile}.bak" preservelastmodified="true"/>
		<replace file="${aboutfile}">
			<replacefilter token="CFE_VERSION" value="${cfeversion}"/>
			<replacefilter token="CFE_YEAR" value="${currentyear}"/>
		</replace>
		<replace file="${mainfile}" token="CFE_YEAR" value="${currentyear}"/>
		<javac srcdir="${basedir}" destdir="${build.classes.dir}"
			debug="${debug}" optimize="${optimize}"
			deprecation="${deprecation}">
			<include name="src/**/*.java"/>
			<include name="MMH/**/*.java"/>
			<classpath refid="cfe_classpath"/>
		</javac>
		<move file="${aboutfile}.bak" tofile="${aboutfile}"/>
		<move file="${mainfile}.bak" tofile="${mainfile}"/>
	</target>

	<target name="copyfiles" depends="init,release.version">
		<echo message="Creating directories ..."/>
		<mkdir dir="${dist.resources.dir}"/>
		<mkdir dir="${dist.lib.dir}"/>
		<mkdir dir="${build.classes.dir}"/>

		<echo message="Copying files ..."/>
		<copy todir="${dist.resources.dir}" overwrite="true">
			<fileset dir="${resources.dir}">
				<include name="**/*"/>
				<exclude name="**/.svn/**"/>
			</fileset>
		</copy>
		<copy todir="${dist.lib.dir}" overwrite="true">
			<fileset dir="${lib.dir}">
				<include name="**/*"/>
				<exclude name="**/.svn/**"/>
			</fileset>
		</copy>
		<copy todir="${dist.dir}" overwrite="true">
			<fileset dir="${release_dir}">
				<include name="**/*"/>
				<exclude name="**/.svn/**"/>
				<exclude name="**/${cfe_mf}"/>
			</fileset>
		</copy>
		<copy todir="${src.dir}/META-INF" overwrite="true">
			<fileset dir="${release_dir}">
				<include name="**/${cfe_mf}"/>
			</fileset>
		</copy>

		<echo message="Patching files ..."/>
		<replace file="${dist.dir}/install.xml" token="CFE_VERSION" value="${cfeversion}"/>
		<replace file="${dist.dir}/create.bat" token="CFE_VERSION" value="${cfeversion}"/>
		<replace file="${dist.jsfile}" token="CFE_VERSION" value="${cfeversion}"/>
		<replace file="${src.dir}/META-INF/${cfe_mf}" token="CFE_VERSION" value="${cfeversion}"/>
	</target>

	<target name="init_js_iz" depends="init">
		<property name="jshome" value="external/js0.9.9-7"/>
		<property name="jsant_jar" value="${jshome}/lib/jsmoothgen-ant.jar"/>
		<property name="izant_jar" value="${basedir}/external/standalone-compiler.jar"/>
	</target>

	<target name="release.version" depends="init">
		<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask">
			<classpath>
				<fileset dir="${basedir}/external/svn">
					<include name="*.jar"/>
				</fileset>
			</classpath>
		</taskdef>

		<fail message="Please provide release version, either edit build.props or run ant as 'ant -Dcfeversion=1.3.0'"
			unless="cfeversion"/>
		<echo message="Building release version ${cfeversion}"/>
	</target>

	<target name="clean" depends="init">
		<delete dir="${build.dir}"/>
		<delete dir="${dist.dir}"/>
		<move file="${aboutfile}.bak" tofile="${aboutfile}" quiet="true" failonerror="false"/>
		<move file="${mainfile}.bak" tofile="${mainfile}" quiet="true" failonerror="false"/>
	</target>

	<target name="release" depends="init,jar,jsmooth_cfe"/>
</project>