Mercurial > cgi-bin > hgweb.cgi > JpegWasher
view build.xml @ 46:5de364cb2847
Doc tweaks.
author | David Barts <davidb@stashtea.com> |
---|---|
date | Mon, 04 May 2020 11:06:14 -0700 |
parents | 6999afa6fff3 |
children | fb407182ba76 |
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?> <project name="JpegWasher" default="help" basedir="." xmlns:launch4j="antlib:net.sf.launch4j.ant"> <!-- import all environment variables as env.* --> <property environment="env"/> <!-- ensure required environment variables are set --> <macrodef name="env-require"> <attribute name="name"/> <sequential> <fail message="Environment variable @{name} not set!"> <condition> <not><isset property="env.@{name}"/></not> </condition> </fail> </sequential> </macrodef> <env-require name="JRE_HOME"/> <env-require name="KOTLIN_HOME"/> <env-require name="OSDEP_HOME"/> <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property --> <scriptdef language="javascript" name="toLowerCase"> <attribute name="value" /> <attribute name="target" /> <![CDATA[ "use strict"; project.setProperty( attributes.get( "target" ), attributes.get( "value" ).toLowerCase() ); ]]> </scriptdef> <!-- estimate disk usage --> <scriptdef language="javascript" name="du"> <attribute name="path" /> <attribute name="target" /> <![CDATA[ "use strict"; var File = Java.type('java.io.File'); function du(fp) { if (fp.isDirectory()) { var files = fp.listFiles(); if (!files) return 0; var total = 0; for (var i=0; i<files.length; i++) total += du(files[i]); return total; } else { return fp.length(); } } var path = new File(attributes.get("path")); project.setProperty(attributes.get("target"), Math.round(du(path) / 1024) + ""); ]]> </scriptdef> <!-- launch4j demands 4-part version numbers, grumble... --> <scriptdef language="javascript" name="l4jversion"> <attribute name="value" /> <attribute name="target" /> <![CDATA[ "use strict"; var IllegalArgumentException = Java.type('java.lang.IllegalArgumentException'); var value = attributes.get("value"); var ret = null; if (value.match(/\d+\.\d+\.\d+\.\d+/)) ret = value; else if(value.match(/\d+\.\d+\.\d+/)) ret = value + ".0"; else if(value.match(/\d+\.\d+/)) ret = value + ".0.0"; else throw new IllegalArgumentException("invalid version: " + value); project.setProperty(attributes.get("target"), ret); ]]> </scriptdef> <!-- Define the properties used by the build --> <property name="app.name" value="${ant.project.name}"/> <property name="app.version" value="1.03"/> <property name="app.domain" value="name.blackcap.exifwasher"/> <property name="app.entry" value="${app.domain}.MainKt"/> <property name="app.copyright" value="Copyright © 2020, David W. Barts."/> <toLowerCase target="lc.app.name" value="${app.name}"/> <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/> <property name="work.jar" value="${basedir}/work.jar"/> <property name="lib.home" value="${basedir}/lib"/> <property name="src.home" value="${basedir}/src"/> <property name="dist.home" value="${basedir}/dist"/> <property name="pf.home" value="${basedir}/package-files"/> <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/> <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/> <property name="jvm.version" value="1.8"/> <!-- define the kotlin task --> <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/> <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/> <!-- help message --> <target name="help"> <echo>You can use the following targets:</echo> <echo> </echo> <echo> help : (default) Prints this message </echo> <echo> all : Cleans, compiles, and stages application</echo> <echo> clean : Deletes work directories</echo> <echo> compile : Compiles servlets into class files</echo> <echo> jar : Make JAR file.</echo> <echo> </echo> <echo>For example, to clean, compile, and package all at once, run:</echo> <echo>prompt> ant all </echo> </target> <!-- Determine OS type --> <condition property="os.type" value="mac"> <os family="mac"/> </condition> <condition property="os.type" value="windows"> <os family="windows"/> </condition> <condition property="os.type" value="linux"> <!-- notes: 1) XXX not all non-mac UNIX systems are Linux, but this assumes so; 2) this clause MUST appear AFTER the "mac" one --> <os family="unix"/> </condition> <property name="os.type" value="unknown"/> <!-- Define the CLASSPATH --> <target name="classpath"> <path id="compile.classpath"> <pathelement location="${src.home}"/> </path> </target> <!-- make needed directories --> <target name="mkdirs"> <mkdir dir="${bin.dir}/${os.type}"/> <mkdir dir="${dist.home}"/> </target> <!-- remove old cruft --> <target name="clean"> <delete includeEmptyDirs="true" failonerror="false"> <fileset dir="${dist.home}" includes="**/*"/> <fileset dir="${bin.dir}"/> </delete> </target> <!-- rename files containing OS-dependant code --> <target name="osdep"> <exec executable="${env.JRE_HOME}/bin/java" failonerror="true"> <arg value="-jar"/> <arg file="${env.OSDEP_HOME}/osdep.jar"/> <arg value="${src.home}"/> </exec> </target> <!-- do everything but install --> <target name="all" depends="jar" description="Clean work dirs, compile, make JAR."/> <!-- compile *.kt to *.class --> <target name="compile" depends="mkdirs,osdep,classpath" description="Compile Java sources to ${work.home}"> <kotlinc src="${src.home}" output="${work.jar}" classpathref="compile.classpath"> <compilerarg line="-jvm-target ${jvm.version}"/> </kotlinc> </target> <!-- make .jar file --> <target name="jar" depends="compile" description="Create JAR file."> <jar destfile="${jar.name}"> <manifest> <attribute name="Main-Class" value="${app.entry}"/> </manifest> <zipgroupfileset dir="${lib.home}" includes="*.jar"/> <zipfileset src="${work.jar}"/> <zipfileset dir="${src.home}" includes="**/*.properties,**/*.dll,**/*.so,**/*.dylib"/> <zipfileset file="${pf.home}/linux/icon_48x48.png" fullpath="name/blackcap/exifwasher/icon_48x48.png"/> </jar> </target> <!-- the packaging logic here is cribbed from what jEdit does --> <target name="macapp" depends="jar" description="Create MacOS app bundle."> <fail message="Macintosh packages can only be built on a Mac."> <condition> <not><os family="mac"/></not> </condition> </fail> <sequential> <property name="mac.disk.image.filename" value="${lc.app.name}_${app.version}.dmg"/> <property name="app.bundle" value="${dist.home}/${app.name}.app"/> <mkdir dir="${app.bundle}/Contents"/> <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true"> <fileset file="${pf.home}/osx/Info.plist"/> <!-- XXX will break if any tokens contain <, >, or & --> <filterset> <filter token="app.copyright" value="${app.copyright}"/> <filter token="app.domain" value="${app.domain}"/> <filter token="app.entry" value="${app.entry}"/> <filter token="app.name" value="${app.name}"/> <filter token="app.version" value="${app.version}"/> <filter token="jar.filename" value="${lc.app.name}.jar"/> <filter token="jvm.version" value="${jvm.version}"/> <filter token="lc.app.name" value="${lc.app.name}"/> </filterset> </copy> <mkdir dir="${app.bundle}/Contents/MacOS"/> <copy todir="${app.bundle}/Contents/MacOS" encoding="UTF-8" overwrite="true"> <fileset file="${pf.home}/osx/JavaApplicationStub"/> <filterset> <filter token="app.domain" value="${app.domain}"/> <filter token="app.name" value="${app.name}"/> </filterset> </copy> <chmod file="${app.bundle}/Contents/MacOS/JavaApplicationStub" perm="755"/> <mkdir dir="${app.bundle}/Contents/Resources"/> <copy file="${basedir}/${app.name}.icns" todir="${app.bundle}/Contents/Resources"/> <mkdir dir="${app.bundle}/Contents/Java"/> <copy file="${jar.name}" todir="${app.bundle}/Contents/Java"/> <echo file="${app.bundle}/Contents/PkgInfo" message="APPL????"/> <exec executable="hdiutil" failonerror="true"> <arg value="create"/> <arg value="-volname"/> <arg value="${app.name}"/> <arg value="-srcfolder"/> <arg file="${app.bundle}"/> <arg file="${dist.home}/orig-${mac.disk.image.filename}"/> </exec> <exec executable="hdiutil" failonerror="true"> <arg value="convert"/> <arg file="${dist.home}/orig-${mac.disk.image.filename}"/> <arg value="-format"/> <arg value="UDRW"/> <arg value="-o"/> <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/> </exec> <exec executable="hdiutil" failonerror="true"> <arg value="convert"/> <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/> <arg value="-format"/> <arg value="UDZO"/> <arg value="-imagekey"/> <arg value="zlib-level=9"/> <arg value="-o"/> <arg file="${dist.home}/${mac.disk.image.filename}"/> </exec> </sequential> </target> <target name="winapp" depends="jar" description="Create app bundle."> <fail message="The Windows application can only be built on Windows."> <condition> <not><os family="windows"/></not> </condition> </fail> <sequential> <env-require name="LAUNCH4J_HOME"/> <taskdef name="create" classname="net.sf.launch4j.ant.Launch4jTask" uri="antlib:net.sf.launch4j.ant"> <classpath> <fileset dir="${env.LAUNCH4J_HOME}" includes="launch4j.jar"/> </classpath> </taskdef> <l4jversion value="${app.version}" target="l4j.version"/> <copy todir="${dist.home}/" encoding="UTF-8" overwrite="true"> <fileset file="${pf.home}/windows/jpegwasher_l4j.xml"/> <filterset> <filter token="app.copyright" value="${app.copyright}"/> <filter token="app.entry" value="${app.entry}"/> <filter token="app.name" value="${app.name}"/> <filter token="app.version" value="${app.version}"/> <filter token="base.dir" value="${basedir}"/> <filter token="dist.home" value="${dist.home}"/> <filter token="jar.filename" value="${jar.name}"/> <filter token="l4j.version" value="${l4j.version}"/> <filter token="target.java.version" value="${jvm.version}"/> </filterset> </copy> <launch4j:create configFile="${dist.home}/jpegwasher_l4j.xml"/> </sequential> </target> <target name="deb" depends="jar" description="Create Debian package."> <fail message="Linux packages can only be built on Linux."> <condition> <not><os family="unix"/></not> </condition> </fail> <sequential> <mkdir dir="${dist.home}/data/usr/share/applications"/> <copy file="${pf.home}/linux/deb/jpegwasher.desktop" tofile="${dist.home}/data/usr/share/applications/jpegwasher.desktop"/> <mkdir dir="${dist.home}/data/usr/share/icons/hicolor/48x48/apps"/> <copy file="${pf.home}/linux/icon_48x48.png" tofile="${dist.home}/data/usr/share/icons/hicolor/48x48/apps/jpegwasher.png"/> <mkdir dir="${dist.home}/data/usr/share/jpegwasher"/> <copy file="${jar.name}" todir="${dist.home}/data/usr/share/jpegwasher"/> <mkdir dir="${dist.home}/data/usr/share/doc/jpegwasher"/> <copy todir="${dist.home}/data/usr/share/doc/jpegwasher"> <filelist dir="${basedir}" files="Readme.html,Readme.rst"/> </copy> <copy todir="${dist.home}/data/usr/share/doc/jpegwasher" encoding="UTF-8" overwrite="true"> <fileset file="${pf.home}/linux/deb/copyright"/> <filterset> <filter token="app.copyright" value="${app.copyright}"/> </filterset> </copy> <gzip src="${pf.home}/linux/deb/changelog" destfile="${dist.home}/data/usr/share/doc/jpegwasher/changelog.gz"/> <mkdir dir="${dist.home}/data/usr/share/man/man1"/> <gzip src="${pf.home}/linux/jpegwasher.1" destfile="${dist.home}/data/usr/share/man/man1/jpegwasher.1.gz"/> <mkdir dir="${dist.home}/data/usr/bin"/> <copy todir="${dist.home}/data/usr/bin" encoding="UTF-8" overwrite="true"> <fileset file="${pf.home}/linux/jpegwasher"/> <filterset> <filter token="jar.filename" value="${lc.app.name}.jar"/> </filterset> </copy> <chmod file="${dist.home}/data/usr/bin/jpegwasher" perm="755"/> <du path="${dist.home}/data" target="deb.installed.size"/> <mkdir dir="${dist.home}/control"/> <copy todir="${dist.home}/control" encoding="UTF-8" overwrite="true"> <fileset file="${pf.home}/linux/deb/control"/> <filterset> <filter token="app.version" value="${app.version}"/> <filter token="deb.installed.size" value="${deb.installed.size}"/> </filterset> </copy> <copy todir="${dist.home}/control"> <filelist dir="${pf.home}/linux/deb" files="postinst,postrm"/> </copy> <chmod perm="755"> <filelist dir="${dist.home}/control" files="postinst,postrm"/> </chmod> <exec executable="${basedir}/make-debian-package" failonerror="true"> <arg value="${dist.home}"/> <arg value="${lc.app.name}_${app.version}.deb"/> </exec> </sequential> </target> </project>