build.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <project name="ConsoleApp" default="exe" basedir=".">
  2. <property name="src" location="src" />
  3. <property name="lib" location="lib" />
  4. <property name="build" location="build" />
  5. <property name="launch4j.dir" location="../.." />
  6. <path id="dist.classpath">
  7. <pathelement path="${build}" />
  8. <fileset dir="${lib}">
  9. <include name="**/*.jar" />
  10. </fileset>
  11. </path>
  12. <target name="init">
  13. <tstamp />
  14. <mkdir dir="${build}" />
  15. </target>
  16. <target name="compile" depends="init" description="compile the source">
  17. <javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" source="1.8" debug="on" includeantruntime="false" />
  18. </target>
  19. <target name="jar" depends="compile" description="create the jar">
  20. <fileset dir="${lib}" id="lib.dist.fileset">
  21. <include name="**/*.jar" />
  22. </fileset>
  23. <pathconvert pathsep=" " property="dist.classpath" refid="lib.dist.fileset">
  24. <map from="${lib}" to=".\lib" />
  25. </pathconvert>
  26. <!-- Put everything in ${build} into a jar file -->
  27. <jar jarfile="${ant.project.name}.jar">
  28. <fileset dir="${build}" includes="**/*" />
  29. <manifest>
  30. <!-- SET YOUR MAIN CLASS HERE -->
  31. <attribute name="Main-Class" value="net.sf.launch4j.example.ConsoleApp" />
  32. <attribute name="Class-Path" value=". ${dist.classpath}" />
  33. </manifest>
  34. </jar>
  35. </target>
  36. <target name="exe" depends="jar">
  37. <taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar
  38. :${launch4j.dir}/lib/xstream.jar" />
  39. <launch4j>
  40. <config headerType="console" jarPath="ConsoleApp.jar" dontWrapJar="true" outfile="ConsoleApp.exe" errTitle="ConsoleApp" chdir="." icon="l4j/ConsoleApp.ico">
  41. <singleInstance mutexName="net.sf.launch4j.example.ConsoleApp" />
  42. <jre path="%JAVA_HOME%;%PATH%" minVersion="1.8.0" />
  43. </config>
  44. </launch4j>
  45. </target>
  46. <target name="clean" description="clean up">
  47. <delete dir="${build}" />
  48. <delete file="${ant.project.name}.jar" />
  49. <delete file="${ant.project.name}.exe" />
  50. </target>
  51. </project>