1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-05 17:05:04 -05:00
filebot/build.xml
2018-06-14 13:56:52 +07:00

985 lines
38 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<project name="filebot" default="jar" xmlns:if="ant:if" xmlns:unless="ant:unless" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- define source dirs -->
<property name="dir.source" location="${basedir}/source" />
<property name="dir.build" location="${basedir}/build" />
<property name="dir.dist" location="${basedir}/dist" />
<property name="dir.lib" location="${basedir}/lib" />
<property name="dir.website" location="${basedir}/website" />
<property name="dir.installer" location="${basedir}/installer" />
<!-- import property files -->
<property file="${basedir}/profile.properties" />
<property file="${basedir}/app.properties" />
<property name="release" value="${application.name}_${application.version}" />
<!-- define output paths -->
<property name="dir.cache" location="${basedir}/cache" />
<property name="dir.release" location="${basedir}/release/${release}" />
<property name="path.fatjar" location="${dir.dist}/${release}.jar" />
<!-- timestamp variables -->
<tstamp prefix="tstamp">
<format property="date" pattern="yyyy-MM-dd" />
<format property="year" pattern="yyyy" />
</tstamp>
<!-- copy and replace ant variables macro -->
<macrodef name="copy-replace">
<attribute name="todir" />
<element name="filesets" implicit="yes" />
<sequential>
<copy todir="@{todir}" encoding="utf-8" overwrite="yes" verbose="yes">
<filesets />
<filterset begintoken="@{" endtoken="}">
<propertyset>
<propertyref builtin="all" />
</propertyset>
</filterset>
</copy>
</sequential>
</macrodef>
<!-- sign with gpg macro -->
<macrodef name="gpg-sign">
<attribute name="detach" default="no" />
<element name="filesets" implicit="yes" />
<sequential>
<apply executable="gpg" verbose="yes">
<arg line="--verbose --batch --yes --local-user ${package.maintainer} --compress-level 0" />
<arg line="--armor --detach-sign" if:true="@{detach}" />
<arg line="--sign" unless:true="@{detach}" />
<srcfile />
<filesets />
</apply>
</sequential>
</macrodef>
<!-- deploy release artifacts -->
<macrodef name="release-deploy">
<attribute name="todir" />
<element name="filesets" implicit="yes" />
<sequential>
<scp todir="@{todir}" trust="yes" verbose="true" sftp="true" keyfile="${deploy.keyfile}">
<filesets />
</scp>
</sequential>
</macrodef>
<!-- fetch and unpack JRE bundle (64-bit Windows) -->
<macrodef name="get-windows-jre">
<attribute name="dest" />
<sequential>
<exec executable="powershell" dir="${dir.cache}" failonerror="yes">
<arg line="get-java" />
</exec>
<untar src="${dir.cache}/jre-${jre.version}_windows-x64_bin.tar.gz" dest="@{dest}" compression="gzip">
<patternset>
<exclude name="**/dtplugin/**" />
<exclude name="**/plugin2/**" />
<!-- reduce MSI size by ~20 MB -->
<exclude name="**/jfxwebkit.dll" />
</patternset>
<cutdirsmapper dirs="1" />
</untar>
</sequential>
</macrodef>
<!-- fetch and unpack JRE bundle (64-bit Mac) -->
<macrodef name="get-macos-jre">
<attribute name="dest" />
<sequential>
<exec executable="get-java.sh" dir="${dir.cache}" failonerror="yes" />
<!-- MAS validation does not like certain files included in the JRE -->
<untar src="${dir.cache}/jre-${jre.version}_osx-x64_bin.tar.gz" dest="@{dest}" compression="gzip">
<patternset>
<exclude name="**/deploy/**" />
<exclude name="**/nibs/**" />
<exclude name="**/shortcuts/**" />
<!-- libjfxwebkit.dylib has many dependencies to deprecated librararies that cause issues with MAS review -->
<exclude name="**/libjfxwebkit.dylib" />
</patternset>
<cutdirsmapper dirs="1" />
</untar>
</sequential>
</macrodef>
<!-- fetch and unpack JRE bundle (64-bit Linux) -->
<macrodef name="get-linux-jre">
<attribute name="dest" />
<sequential>
<exec executable="get-java.sh" dir="${dir.cache}" failonerror="yes" />
<!-- MAS validation does not like certain files included in the JRE -->
<untar src="${dir.cache}/jre-${jre.version}_linux-x64_bin.tar.gz" dest="@{dest}" compression="gzip">
<cutdirsmapper dirs="1" />
</untar>
</sequential>
</macrodef>
<target name="resolve" description="Retrieve dependencies with Apache Ivy">
<delete dir="${dir.lib}/ivy" />
<ivy:retrieve pattern="${dir.lib}/ivy/[type]/[artifact].[ext]" />
<antcall target="resolve-import-native">
<param name="arch" value="mac-x86_64" />
<param name="arch.jna" value="darwin" />
<param name="arch.7zj" value="Mac-x86_64" />
</antcall>
<antcall target="resolve-import-native">
<param name="arch" value="win32-x64" />
<param name="arch.jna" value="win32-x86-64" />
<param name="arch.7zj" value="Windows-amd64" />
</antcall>
<antcall target="resolve-import-native">
<param name="arch" value="win32-x86" />
<param name="arch.jna" value="win32-x86/" />
<param name="arch.7zj" value="Windows-x86" />
</antcall>
<antcall target="resolve-import-native">
<param name="arch" value="linux-amd64" />
<param name="arch.jna" value="linux-x86-64" />
<param name="arch.7zj" value="Linux-amd64" />
</antcall>
<antcall target="resolve-import-native">
<param name="arch" value="linux-i686" />
<param name="arch.jna" value="linux-x86" />
<param name="arch.7zj" value="Linux-i386" />
</antcall>
<antcall target="resolve-import-native">
<param name="arch" value="linux-armv7l" />
<param name="arch.jna" value="linux-arm" />
<param name="arch.7zj" value="linux-arm" />
</antcall>
<antcall target="resolve-import-native">
<param name="arch" value="linux-armv8" />
<param name="arch.jna" value="linux-aarch64" />
<param name="arch.7zj" value="linux-aarch64" />
</antcall>
</target>
<target name="resolve-import-native">
<unzip src="${dir.lib}/ivy/jar/jna.jar" dest="${dir.lib}/native/${arch}" overwrite="yes">
<patternset>
<include name="**/${arch.jna}/*.dll" />
<include name="**/${arch.jna}/*.so" />
<include name="**/${arch.jna}/*.jnilib" />
</patternset>
<chainedmapper>
<flattenmapper />
<compositemapper>
<globmapper from="*.jnilib" to="*.dylib" />
<identitymapper />
</compositemapper>
</chainedmapper>
</unzip>
<unzip src="${dir.lib}/ivy/jar/sevenzipjbinding-all-platforms.jar" dest="${dir.lib}/native/${arch}" overwrite="yes">
<patternset>
<include name="**/${arch.7zj}/*.dll" />
<include name="**/${arch.7zj}/*.so" />
<include name="**/${arch.7zj}/*.dylib" />
</patternset>
<chainedmapper>
<flattenmapper />
<compositemapper>
<globmapper from="lib*.dll" to="*.dll" />
<identitymapper />
</compositemapper>
</chainedmapper>
</unzip>
</target>
<target name="jar" depends="build">
<jar destfile="${dir.dist}/lib/filebot.jar">
<fileset dir="${dir.build}" />
<manifest>
<attribute name="Build-Date" value="${tstamp.date}" />
<attribute name="Build-Revision" value="${revision}" />
</manifest>
</jar>
</target>
<target name="appbundle-maspkg-core">
<antcall target="appbundle-maspkg">
<param name="application.name" value="FileBot" />
<param name="application.executable" value="filebot.launcher" />
<param name="application.identifier" value="${package.identifier}.Rename" />
<param name="application.icon" value="${dir.installer}/appbundle/filebot.icns" />
<param name="application.cert.appbundle" value="3rd Party Mac Developer Application: ${package.company}" />
<param name="application.cert.installer" value="3rd Party Mac Developer Installer: ${package.company}" />
<!-- MAS does not allow subtitle apps -->
<param name="application.mode" value="Rename|Episodes|SFV|Filter|List" />
<!-- libjfxwebkit.dylib cannot be deployed on the MAS due to deprecated dependencies -->
<param name="application.help" value="ask" />
</antcall>
</target>
<target name="appbundle-maspkg-subtitles">
<antcall target="appbundle-maspkg">
<param name="application.name" value="FileBot Subtitles" />
<param name="application.executable" value="filebot.subtitles.launcher" />
<param name="application.identifier" value="${package.identifier}.Subtitles" />
<param name="application.icon" value="${dir.installer}/appbundle/subtitles.icns" />
<param name="application.cert.appbundle" value="Developer ID Application: ${package.company}" />
<param name="application.cert.installer" value="Developer ID Installer: ${package.company}" />
<param name="application.mode" value="Subtitles" />
<param name="application.help" value="skip" />
</antcall>
</target>
<target name="appbundle-maspkg" depends="revision">
<property name="path.app" location="${dir.dist}/${application.name}.app" />
<property name="path.pkg" location="${dir.dist}/${application.name}_${application.version}_r${revision}.pkg" />
<property name="path.app.jre" location="${path.app}/Contents/PlugIns/jre-${jre.version}.jre" />
<property name="jre.path" location="${dir.cache}/jre-${jre.version}.jre/Contents/Home" />
<!-- fetch latest JRE -->
<exec executable="get-java.sh" dir="${dir.cache}" failonerror="yes" />
<untar src="${dir.cache}/jre-${jre.version}_osx-x64_bin.tar.gz" dest="${dir.cache}" compression="gzip" />
<!-- MAS validation does not like certain files included in the JRE -->
<delete verbose="yes" includeEmptyDirs="yes">
<fileset dir="${jre.path}">
<include name="**/bin/**" />
<include name="**/deploy/**" />
<include name="**/nibs/**" />
<include name="**/shortcuts/**" />
<!-- webkit uses deprecate font libraries which is not allowed in the app store -->
<include name="**/libjfxwebkit.dylib" />
</fileset>
</delete>
<!-- MAS validation is a bit buggy and requires even libraries and frameworks to have a unique CFBundleIdentifier Collision -->
<replace file="${jre.path}/../Info.plist" token="com.oracle.java.${jre.version}.jre" value="${application.identifier}.jre" encoding="UTF-8" summary="true" />
<bundleapp jvmrequired="${jvm.version}" minimumsystemversion="${mac.version}" outputdirectory="${dir.dist}" executablename="${application.executable}" name="${application.name}" displayname="${application.name}" version="${revision}" shortversion="${application.version}" identifier="${application.identifier}" mainclassname="${main.class}" icon="${application.icon}" copyright="${tstamp.year} ${package.company}" applicationcategory="${mac.application.category}" highresolutioncapable="true" supportsautomaticgraphicsswitching="true" debug="true">
<classpath dir="${dir.dist}/lib" />
<librarypath dir="${dir.lib}/native/mac-x86_64" />
<arch name="x86_64" />
<runtime dir="${jre.path}">
<include name="**/*" />
</runtime>
<argument value="--mode" />
<argument value="${application.mode}" />
<!-- WORKING_DIR is sandbox data folder -->
<option value="-Dapplication.dir=Library/Application Support/User Data" />
<option value="-Dapplication.cache=Library/Caches/ehcache.disk.store" />
<option value="-Djava.io.tmpdir=Library/Caches/java.io.tmpdir" />
<option value="-Dnet.filebot.UserFiles.fileChooser=COCOA" />
<option value="-Dapplication.name=${application.name}" />
<option value="-Dapplication.help=${application.help}" />
<option value="-Dapplication.deployment=mas" />
<option value="-Dapplication.update=skip" />
<option value="-DuseExtendedFileAttributes=true" />
<option value="-DuseCreationDate=false" />
<option value="-Djava.net.useSystemProxies=true" />
<option value="-Dfile.encoding=UTF-8" />
<option value="-Djna.nosys=true" />
<option value="-Djna.nounpack=true" />
<option value="-Djna.boot.library.name=jnidispatch" />
<option value="-Djna.boot.library.path=$APP_ROOT/Contents/MacOS" />
<option value="-Djna.library.path=$APP_ROOT/Contents/MacOS" />
<option value="-Djava.library.path=$APP_ROOT/Contents/MacOS" />
<option value="-Dnet.filebot.AcoustID.fpcalc=$APP_ROOT/Contents/MacOS/fpcalc" />
<option value="-Dapple.laf.useScreenMenuBar=true" />
<option value="-Dapple.awt.application.name=${application.name}" />
<bundledocument role="viewer" handlerRank="none" contentTypes="public.movie" name="Video file" />
<bundledocument role="viewer" handlerRank="none" contentTypes="public.audio" name="Audio file" />
<bundledocument role="viewer" handlerRank="none" contentTypes="public.folder" name="Media folder" />
</bundleapp>
<!-- remove unused language resources -->
<delete verbose="yes" includeEmptyDirs="yes">
<fileset dir="${path.app}/Contents/Resources">
<include name="**.lproj/**" />
<exclude name="en.lproj/**" />
</fileset>
</delete>
<!-- fix broken symlink -->
<copy file="${jre.path}/lib/jli/libjli.dylib" tofile="${path.app.jre}/Contents/MacOS/libjli.dylib" overwrite="yes" verbose="yes" failonerror="yes" />
<!-- fix permissions (fpcalc and jspawnhelper be executable and signed with inherit entitlements) -->
<chmod perm="+x">
<fileset dir="${path.app}">
<include name="**/jspawnhelper" />
<include name="**/fpcalc" />
<include name="**/*.sh" />
</fileset>
</chmod>
<!-- JRE sign all jars, dylibs and executables -->
<property name="sign" value="--verbose --force --sign '${application.cert.appbundle}'" />
<property name="entitlements" value="--entitlements '${dir.installer}/appbundle/FileBot.entitlements'" />
<property name="entitlements.inherit" value="--entitlements '${dir.installer}/appbundle/inherit.entitlements'" />
<!-- sign helper tools with inherit entitlements -->
<apply executable="codesign" parallel="yes" failonerror="yes">
<arg line="${sign} ${entitlements.inherit}" />
<fileset dir="${path.app}">
<include name="**/jspawnhelper" />
<include name="**/fpcalc" />
<include name="**/*.dylib" />
<include name="**/*.jar" />
<include name="**/*.sh" />
</fileset>
</apply>
<!-- sign frameworks -->
<exec executable="codesign" failonerror="yes">
<arg line="${sign} ${entitlements.inherit} '${path.app.jre}'" />
</exec>
<!-- sign app -->
<exec executable="codesign" failonerror="yes">
<arg line="${sign} ${entitlements} '${path.app}'" />
</exec>
<!-- verify signature -->
<exec executable="codesign" failonerror="yes">
<arg line="--verbose --deep --verify '${path.app}'" />
</exec>
<!-- build package -->
<exec executable="productbuild" failonerror="yes">
<arg line="--component '${path.app}' /Applications '${path.pkg}' --sign '${application.cert.installer}'" />
</exec>
<!-- store as release build-->
<copy todir="${dir.release}" file="${path.pkg}" verbose="yes" />
</target>
<target name="app" depends="revision" description="Build Mac app package">
<property name="dir.staging" location="${dir.dist}/app" />
<copy-replace todir="${dir.staging}/bin">
<fileset dir="${dir.installer}/app" includes="*.sh" />
</copy-replace>
<!-- fetch latest JRE -->
<get-macos-jre dest="${dir.staging}" />
<bundleapp jvmrequired="${jvm.version}" minimumsystemversion="${mac.version}" outputdirectory="${dir.staging}" executablename="filebot.launcher" name="${application.name}" displayname="${application.name}.launcher" version="${revision}" shortversion="${application.version}" identifier="${package.identifier}" mainclassname="${main.class}" icon="${dir.installer}/icons/filebot.icns" copyright="${tstamp.year} ${package.company}" applicationcategory="${mac.application.category}" highresolutioncapable="true" supportsautomaticgraphicsswitching="true">
<arch name="x86_64" />
<runtime dir="${dir.staging}/jre-${java.version}.jre/Contents/Home">
<include name="**/*" />
</runtime>
<classpath dir="${dir.dist}/lib" />
<librarypath dir="${dir.staging}/bin" />
<librarypath dir="${dir.lib}/native/mac-x86_64" />
<bundledocument role="viewer" handlerRank="none" contentTypes="public.movie" name="Video file" />
<bundledocument role="viewer" handlerRank="none" contentTypes="public.audio" name="Audio file" />
<bundledocument role="viewer" handlerRank="none" contentTypes="public.folder" name="Media folder" />
<bundledocument extensions="${license.extension}" icon="${dir.installer}/icons/filebot.icns" name="${license.description}" role="viewer" handlerRank="owner" contentTypes="net.filebot.license" />
<typedeclaration extensions="${license.extension}" icon="${dir.installer}/icons/filebot.icns" description="${license.description}" conformsTo="public.plain-text" identifier="net.filebot.license" mimeTypes="${license.mimetype}" />
<option value="-Dapple.laf.useScreenMenuBar=true" />
<option value="-Dapple.awt.application.name=${application.name}" />
<option value="-Dunixfs=false" />
<option value="-DuseExtendedFileAttributes=true" />
<option value="-DuseCreationDate=false" />
<option value="-Djava.net.useSystemProxies=true" />
<option value="-Djna.nosys=true" />
<option value="-Djna.nounpack=true" />
<option value="-Dnet.filebot.UserFiles.fileChooser=COCOA" />
<option value="-Dapplication.deployment=app" />
<option value="-Dapplication.help=ask" />
<option value="-Djna.boot.library.name=jnidispatch" />
<option value="-Djna.boot.library.path=$APP_ROOT/Contents/MacOS" />
<option value="-Djna.library.path=$APP_ROOT/Contents/MacOS" />
<option value="-Djava.library.path=$APP_ROOT/Contents/MacOS" />
<option value="-Dnet.filebot.AcoustID.fpcalc=$APP_ROOT/Contents/MacOS/fpcalc" />
<option value="--illegal-access=permit" />
<option value="--add-opens=java.base/java.lang=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.lang.invoke=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.util=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.util.function=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.util.regex=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.net=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.io=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.nio.file=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.nio.file.attribute=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.nio.channels=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.nio.charset=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.time=ALL-UNNAMED" />
<option value="--add-opens=java.base/java.time.chrono=ALL-UNNAMED" />
<option value="--add-opens=java.logging/java.util.logging=ALL-UNNAMED" />
<option value="--add-opens=java.desktop/java.awt=ALL-UNNAMED" />
</bundleapp>
<tar destfile="${dir.dist}/${release}.app.tar.xz" compression="${tar.compression}" longfile="posix" encoding="utf-8">
<tarfileset dir="${dir.staging}">
<include name="*.app/**" />
<exclude name="*.app/**/MacOS/filebot.*" />
<exclude name="*.app/**/MacOS/fpcalc" />
<exclude name="*.app/**/lib/jspawnhelper" />
<exclude name="*.app/**/bin/*" />
</tarfileset>
<tarfileset dir="${dir.staging}" filemode="755">
<include name="*.app/**/MacOS/filebot.*" />
<include name="*.app/**/MacOS/fpcalc" />
<include name="*.app/**/lib/jspawnhelper" />
<include name="*.app/**/bin/*" />
</tarfileset>
</tar>
</target>
<target name="snap" depends="revision">
<property name="dir.staging" location="${dir.dist}/snap" />
<property name="dir.root" location="${dir.staging}/root" />
<get-linux-jre dest="${dir.root}/usr/lib/jre" />
<!-- copy files and resolve ant variables -->
<copy-replace todir="${dir.staging}">
<fileset dir="${dir.installer}/snap" />
</copy-replace>
<chmod perm="+x" verbose="yes">
<fileset dir="${dir.root}" includes="**/bin/**" />
</chmod>
<copy todir="${dir.root}/usr/lib/filebot/jar">
<fileset dir="${dir.dist}/lib" includes="*.jar" />
</copy>
<!-- include native binaries that are not available via apt -->
<copy todir="${dir.root}/usr/lib/filebot/lib">
<fileset dir="${dir.lib}/native/linux-amd64">
<include name="*.so" />
</fileset>
</copy>
<exec executable="snapcraft" dir="${dir.staging}" failonerror="yes">
<arg line="cleanbuild" />
</exec>
</target>
<target name="deb" description="Build Debian Linux package" depends="revision">
<antcall target="deb-arch">
<param name="arch" value="amd64" />
<param name="deb.arch" value="amd64" />
</antcall>
<!-- arch i686 not allowed by deb specification, must be i386 for 32-bit x86 systems -->
<!--
<antcall target="deb-arch">
<param name="arch" value="i686" />
<param name="deb.arch" value="i386" />
</antcall>
-->
<!-- arch armv7l not allowed by deb specification, must be armhf for 32-bit armv7l systems -->
<!--
<antcall target="deb-arch">
<param name="arch" value="armv7l" />
<param name="deb.arch" value="armhf" />
</antcall>
-->
</target>
<target name="deb-arch">
<property name="dir.staging" location="${dir.dist}/deb/${arch}" />
<copy-replace todir="${dir.staging}">
<fileset dir="${dir.installer}/deb" />
</copy-replace>
<jdeb destfile="${dir.dist}/${package.name}_${application.version}_${deb.arch}.deb" control="${dir.staging}/control" compression="${tar.compression}" verbose="true">
<tarfileset prefix="/usr/share/filebot/bin" dir="${dir.staging}" includes="*.sh" filemode="755" />
<tarfileset prefix="/usr/share/filebot/jar" dir="${dir.dist}/lib" />
<tarfileset prefix="/usr/share/filebot/lib" dir="${dir.lib}/native/linux-${arch}" includes="fpcalc" filemode="755" />
<tarfileset prefix="/usr/share/filebot/lib" dir="${dir.lib}/native/linux-${arch}" includes="*.so" />
<tarfileset prefix="/usr/share/icons/hicolor/scalable/apps" dir="${dir.installer}/icons" includes="filebot.svg" />
<tarfileset prefix="/usr/share" dir="${dir.staging}/share" />
</jdeb>
</target>
<target name="appx" description="Build Windows 10 package" depends="revision">
<antcall target="appx-arch">
<param name="arch" value="x64" />
<param name="arch.env" value="AMD64" />
<param name="arch.jre" value="x64" />
</antcall>
<!-- 32-bit Windows is not supported by Oracle JDK so there are no JRE builds -->
<!--
<antcall target="appx-arch">
<param name="arch" value="x86" />
<param name="arch.env" value="x86" />
<param name="arch.jre" value="i586" />
</antcall>
-->
</target>
<target name="appx-arch">
<property name="dir.staging" location="${dir.dist}/appx/${arch}" />
<copy todir="${dir.staging}">
<fileset dir="${dir.installer}/appx" includes="*.exe, **/*.png" />
</copy>
<copy todir="${dir.staging}/lib">
<fileset dir="${dir.lib}/native/win32-${arch}" />
</copy>
<copy todir="${dir.staging}/jar">
<fileset dir="${dir.dist}/lib" includes="*.jar" />
</copy>
<!-- copy files and resolve ant variables -->
<copy-replace todir="${dir.staging}">
<fileset dir="${dir.installer}/appx" includes="*.xml, *.ini" excludes="*.l4j.xml" />
</copy-replace>
<!-- fetch latest JRE -->
<get-windows-jre dest="${dir.staging}/jre" />
<!-- Workaround for VS2013 / CoInitialize hack (see http://mail.openjdk.java.net/pipermail/swing-dev/2018-February/008323.html) -->
<delete verbose="yes">
<fileset dir="${dir.staging}/jre" includes="**/*120*.dll" />
</delete>
<!-- package APPX -->
<exec executable="makepri" dir="${dir.staging}" failonerror="yes">
<arg line="createconfig /o /pv 10.0.0 /cf priconfig.xml /dq en-US" />
</exec>
<exec executable="makepri" dir="${dir.staging}" failonerror="yes">
<arg line="new /o /pr . /cf priconfig.xml /in ${microsoft.application.name}" />
</exec>
<exec executable="makeappx" dir="${dir.dist}" failonerror="yes">
<arg line="pack /v /o /d ${dir.staging} /p ${release}_r${revision}_${arch}.appx" />
</exec>
</target>
<target name="msi" description="Build Windows Installer package" depends="revision">
<property name="dir.staging" location="${dir.dist}/msi/x64" />
<!-- 1. prepare application files for heat harvest -->
<get-windows-jre dest="${dir.staging}/base/jre" />
<copy todir="${dir.staging}/base/jar">
<fileset dir="${dir.dist}/lib" includes="*.jar" />
</copy>
<copy todir="${dir.staging}/base/lib">
<fileset dir="${dir.lib}/native/win32-x64" />
</copy>
<exec executable="heat" dir="${dir.staging}" failonerror="true">
<arg line="dir base -v -srd -gg -dr ApplicationBase -cg ApplicationBase -template fragment -sreg -sfrag -scom -out base.wxs" />
</exec>
<exec executable="candle" dir="${dir.staging}" failonerror="true">
<arg line="base.wxs -out base.wixobj" />
</exec>
<!-- 2. prepare installer files and application stub for candle light -->
<copy-replace todir="${dir.staging}">
<fileset dir="${dir.installer}/msi" includes="*.wix, *.ini" />
</copy-replace>
<exec executable="candle" dir="${dir.staging}" failonerror="true">
<arg line="filebot.wix -out filebot.wixobj" />
</exec>
<!-- 3. compile MSI package (use -b to add additional resource folders) -->
<exec executable="light" dir="${dir.staging}" failonerror="true">
<arg line="filebot.wixobj base.wixobj -b base -b ${dir.installer}/msi -sval -ext WixUIExtension -out ${dir.dist}/${release}_x64.msi" />
</exec>
</target>
<target name="portable" description="Build portable package" depends="revision">
<property name="dir.staging" location="${dir.dist}/portable" />
<copy-replace todir="${dir.staging}">
<fileset dir="${dir.installer}/portable" includes="*.sh" />
</copy-replace>
<tar destfile="${dir.dist}/${release}-portable.tar.xz" compression="${tar.compression}" longfile="posix" encoding="utf-8">
<tarfileset dir="${dir.staging}" includes="*.sh" filemode="755" />
<tarfileset prefix="jar" dir="${dir.dist}/lib" />
<!-- include native libraries for all supported platforms -->
<tarfileset prefix="lib/armv7l" dir="${dir.lib}/native/linux-armv7l" includes="*.so" />
<tarfileset prefix="lib/aarch64" dir="${dir.lib}/native/linux-armv8" includes="*.so" />
<tarfileset prefix="lib/i686" dir="${dir.lib}/native/linux-i686" includes="*.so" />
<tarfileset prefix="lib/x86_64" dir="${dir.lib}/native/linux-amd64" includes="*.so" />
<!-- include maintainer public key -->
<tarfileset dir="${dir.installer}/gpg" includes="maintainer.pub" />
</tar>
</target>
<target name="spk" description="Build Synology NAS package" depends="revision">
<spk destdir="${dir.dist}" name="${package.name}" version="${application.version}" arch="noarch" compression="${tar.compression}">
<info name="displayname" value="${application.name}" />
<info name="description" value="${package.description}" />
<info name="maintainer" value="${package.project}" />
<info name="maintainer_url" value="${package.homepage}" />
<info name="distributor" value="${package.project}" />
<info name="distributor_url" value="${package.homepage}" />
<info name="support_url" value="${link.help.synology}" />
<info name="helpurl" value="${link.help.manpage}" />
<info name="firmware" value="6.0" />
<info name="startable" value="no" />
<info name="silent_install" value="yes" />
<info name="silent_uninstall" value="yes" />
<info name="silent_upgrade" value="yes" />
<info name="thirdparty" value="yes" />
<!-- Dependencies are troublesome for some users because they cannot be skipped or ignored (i.e. DSM does not support optional or recommended dependencies) -->
<!-- <info name="start_dep_services" value="ssh" /> -->
<!-- <info name="install_dep_packages" value="oracle-java" /> -->
<icon size="72" file="${dir.installer}/icons/icon72.png" />
<icon size="256" file="${dir.installer}/icons/icon256.png" />
<scripts dir="${dir.installer}/spk/scripts" filemode="755" />
<package dir="${dir.installer}/spk/package" includes="*.sh" filemode="755" />
<package file="${path.fatjar}" fullpath="FileBot.jar" />
<!-- include native libraries for all supported platforms -->
<package prefix="lib/armv7l" dir="${dir.lib}/native/linux-armv7l" includes="*.so" />
<package prefix="lib/armv8" dir="${dir.lib}/native/linux-armv8" includes="*.so" />
<package prefix="lib/i686" dir="${dir.lib}/native/linux-i686" includes="*.so" />
<package prefix="lib/x86_64" dir="${dir.lib}/native/linux-amd64" includes="*.so" />
<codesign secring="${dir.installer}/gpg/secring.gpg" keyid="${gpg.key}" password="${gpg.pwd}" />
</spk>
</target>
<target name="build" depends="revision">
<!-- copy dependencies -->
<copy todir="${dir.dist}/lib" flatten="yes" verbose="yes">
<fileset dir="${dir.lib}/ivy/jar">
<include name="ehcache.jar" />
<include name="miglayout-core.jar" />
<include name="miglayout-swing.jar" />
<include name="glazedlists_java16.jar" />
<include name="controlsfx.jar" />
<include name="rsyntaxtextarea.jar" />
<include name="lanterna.jar" />
<include name="xz.jar" />
<include name="sevenzipjbinding.jar" />
<include name="commons-io.jar" />
<include name="commons-vfs2.jar" />
<include name="jaxb-api.jar" />
<include name="jaxb-impl.jar" />
<include name="junrar.jar" />
<include name="jna.jar" />
<include name="jna-platform.jar" />
<include name="streamex.jar" />
<include name="icu4j.jar" />
<include name="language-detector.jar" />
<include name="metadata-extractor.jar" />
<include name="xmpcore.jar" />
<include name="commons-logging.jar" />
<include name="slf4j-api.jar" />
<include name="slf4j-jdk14.jar" />
<include name="groovy.jar" />
<include name="groovy-ant.jar" />
<include name="groovy-bsf.jar" />
<include name="groovy-datetime.jar" />
<include name="groovy-dateutil.jar" />
<include name="groovy-json.jar" />
<include name="groovy-jsr223.jar" />
<include name="groovy-nio.jar" />
<include name="groovy-sql.jar" />
<include name="groovy-swing.jar" />
<include name="groovy-xml.jar" />
<include name="ivy.jar" />
<include name="jsoup.jar" />
<include name="ant.jar" />
<include name="ant-launcher.jar" />
<include name="ant-commons-net.jar" />
<include name="ant-jsch.jar" />
<include name="ant-javamail.jar" />
<include name="commons-net.jar" />
<include name="jsch.jar" />
<include name="javax.mail.jar" />
<include name="activation.jar" />
<include name="bcprov-jdk15on.jar" />
<include name="bcpg-jdk15on.jar" />
</fileset>
<fileset dir="${dir.lib}/ivy/bundle">
<include name="args4j.jar" />
<include name="json-io.jar" />
<include name="guava.jar" />
</fileset>
<fileset dir="${dir.lib}/jars">
<include name="xmlrpc.jar" />
<include name="ObjCBridge.jar" />
<include name="simmetrics.jar" />
<include name="jacksum.jar" />
</fileset>
</copy>
<!-- compile -->
<javac srcdir="${dir.source}" destdir="${dir.build}" release="${jvm.version}" encoding="utf-8" debug="yes" debuglevel="lines,vars,source" includeAntRuntime="no">
<classpath>
<fileset dir="${dir.dist}/lib" />
</classpath>
</javac>
<!-- copy property files -->
<copy-replace todir="${dir.build}">
<fileset dir="${dir.source}" includes="**/*.properties" />
</copy-replace>
<!-- copy resources -->
<copy todir="${dir.build}">
<fileset dir="${dir.source}">
<exclude name="**/*.java" />
<exclude name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="clean" description="Delete build artifacts">
<delete dir="${dir.dist}" />
<delete dir="${dir.build}" />
</target>
<target name="website-docs" depends="revision">
<javadoc destdir="${dir.dist}/website/docs" linksource="yes" access="public" classpathref="lib.classpath" encoding="UTF-8" charset="UTF-8" windowtitle="${application.name}" noindex="yes" nohelp="yes" notree="yes" nodeprecated="yes" nonavbar="yes">
<fileset dir="${dir.source}" includesfile="${dir.website}/docs/includes.fileset" />
<doctitle>${application.name} ${application.version}</doctitle>
<bottom>${application.name} ${application.version} (r${revision}) built on ${tstamp.date}</bottom>
<link href="http://docs.oracle.com/javase/${jre.version}/docs/api/" />
<link href="http://docs.groovy-lang.org/latest/html/api/" />
</javadoc>
</target>
<target name="revision" depends="init">
<exec executable="git" outputproperty="revision" failonerror="true">
<arg line="rev-list --count master" />
</exec>
<echo>Revision: ${revision}</echo>
</target>
<target name="init">
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.dist}" />
<mkdir dir="${dir.release}" />
<mkdir dir="${dir.cache}" />
<path id="lib.classpath">
<fileset dir="${dir.lib}" includes="**/*.jar" excludes="**/*-jdk14.jar" />
</path>
<taskdef resource="net/filebot/ant/spk/antlib.xml" classpathref="lib.classpath" />
<taskdef resource="org/vafer/jdeb/ant/antlib.xml" classpathref="lib.classpath" />
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpathref="lib.classpath" />
</target>
<target name="stage-release">
<!-- ensure clean release dir -->
<delete dir="${dir.release}" />
<mkdir dir="${dir.release}" />
<!-- prepare release packages -->
<copy todir="${dir.release}" verbose="yes">
<fileset dir="${dir.dist}">
<include name="*.tar.xz" />
<include name="*.msi" />
<include name="*.deb" />
<include name="*.spk" />
</fileset>
</copy>
<!-- require gpg signatures for all installer packages -->
<gpg-sign>
<fileset dir="${dir.release}">
<exclude name="*.spk" />
</fileset>
</gpg-sign>
<checksum algorithm="SHA-256" pattern="{0} {1}" todir="${dir.cache}/${release}/sha">
<fileset dir="${dir.release}">
<include name="*.gpg" />
<include name="*.spk" />
</fileset>
</checksum>
<concat destfile="${dir.release}/README.md" overwrite="true" eol="unix" outputencoding="utf-8">
<fileset file="${dir.installer}/ant/digest.head.md" />
<fileset dir="${dir.cache}/${release}/sha" />
<fileset file="${dir.installer}/ant/digest.tail.md" />
</concat>
<!-- include source tarball -->
<tar destfile="${dir.release}/${package.name}-${application.version}-src.tar.xz" compression="${tar.compression}" longfile="posix" encoding="utf-8">
<tarfileset dir="${dir.source}" />
</tar>
</target>
<target name="deploy-release" depends="stage-release" description="Upload release files to SourceForge.net FRS">
<property name="mirror" location="${dir.cache}/${release}/FRS" />
<copy todir="${mirror}/${package.name}/${release}" verbose="yes">
<fileset dir="${dir.release}">
<include name="*.gpg" />
<include name="*.spk" />
<include name="*-src.tar.xz" />
<include name="*.md" />
</fileset>
</copy>
<release-deploy todir="${deploy.release.mirror}">
<fileset dir="${mirror}" includes="**/*.md" />
<fileset dir="${mirror}" includes="**/*-src.tar.xz" />
<fileset dir="${mirror}" includes="**/*.spk" />
<fileset dir="${mirror}" includes="**/*.gpg" />
</release-deploy>
</target>
<target name="deploy-jar" description="Build and deploy the latest jar">
<xz src="${path.fatjar}" destfile="${dir.release}/FileBot.jar.xz" />
<gpg-sign>
<fileset dir="${dir.release}" includes="*.jar.xz" />
</gpg-sign>
<release-deploy todir="${deploy.release}/${package.name}/latest">
<fileset dir="${dir.release}" includes="*.jar.xz.gpg" />
</release-deploy>
</target>
<target name="deploy-synology" description="Update Synology Package Source" depends="init">
<mkdir dir="${dir.dist}/syno" />
<!-- merge all filebot related packages into a single package source file -->
<package-source file="${dir.dist}/syno/index.json">
<keyring file="${dir.installer}/gpg/FileBot.pub" />
<spk file="${dir.release}/${package.name}-${application.version}-noarch.spk">
<info name="link" value="https://downloads.sourceforge.net/project/filebot/filebot/${release}/${package.name}-${application.version}-noarch.spk" />
<thumbnail url="https://www.filebot.net/syno/filebot-thumbnail.png" />
<snapshot url="https://www.filebot.net/syno/filebot-snapshot.png" />
</spk>
<source url="https://raw.githubusercontent.com/filebot/filebot-node/master/spksrc.json" />
<source url="https://raw.githubusercontent.com/rednoah/java-installer/master/spksrc.json" />
<source url="https://raw.githubusercontent.com/rednoah/ant-installer/master/spksrc.json" />
</package-source>
<!-- upload -->
<release-deploy todir="${deploy.release}">
<fileset dir="${dir.dist}" includes="syno/**" />
</release-deploy>
</target>
<target name="deploy-website" description="Upload website resources" depends="revision">
<!-- copy image resources -->
<copy todir="${dir.dist}/website/resources" preservelastmodified="yes" verbose="yes" flatten="true">
<fileset dir="${dir.source}/net/filebot/resources">
<include name="*.png" />
</fileset>
</copy>
<!-- copy static website resources -->
<copy todir="${dir.dist}/website" preservelastmodified="yes" verbose="yes">
<fileset dir="${dir.website}">
<include name=".htaccess" />
<include name="*.html" />
<include name="*.php" />
<include name="*.json" />
<include name="*.xml" />
<include name="*.css" />
<include name="*.js" />
<include name="*.png" />
<include name="*.ico" />
<include name="*.txt" />
<include name="syno/**" />
<include name="images/**" />
<include name="screenshots/**" />
<include name="getting-started/**" />
</fileset>
</copy>
<!-- copy files and resolve ant variables -->
<copy-replace todir="${dir.dist}/website">
<fileset dir="${dir.website}">
<include name="*.html" />
<include name="*.php" />
</fileset>
</copy-replace>
<!-- upload -->
<release-deploy todir="${deploy.website}">
<fileset dir="${dir.dist}/website">
<modified>
<param name="cache.cachefile" value="${dir.cache}/scp.cache" />
</modified>
</fileset>
</release-deploy>
</target>
<target name="eclipse-properties-builder">
<exec executable="git" outputproperty="revision" failonerror="true">
<arg line="rev-list --count master" />
</exec>
<copy-replace todir="bin">
<fileset dir="source" includes="**/*.properties" />
</copy-replace>
</target>
</project>