Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
468 lines (402 sloc) 22.3 KB
<?xml version="1.0" encoding="UTF-8" ?>
<project name="MyBB" default="full" basedir=".">
<!-- build settings -->
<property file="${project.basedir}/input/build.properties" />
<property name="sourceDirectory" value="${project.basedir}/input/source" />
<property name="previousSourceDirectory" value="${project.basedir}/input/previous-source" />
<property name="patchesDirectory" value="${project.basedir}/input/patches" />
<property name="packageAddendumDirectory" value="${project.basedir}/input/package-addendum" />
<property name="buildDirectory" value="${project.basedir}/build" />
<property name="gitDirectory" value="${buildDirectory}/git" />
<property name="previousSourceDirectoryInternal" value="${buildDirectory}/previous-source" />
<property name="outputDirectory" value="${project.basedir}/output" />
<!-- project settings -->
<propertyregex property="targetVersionCode" override="false" subject="${targetVersion}" pattern="[^0-9a-z]" replace="" match="$1" defaultValue="$0" />
<property name="installPackageSubdirectory" value="install" />
<property name="languageFilesPackageDirectory" value="inc/languages/english/" />
<property name="classCoreVersionRegex">public \$version = "([0-9a-zA-Z.-]+)";</property>
<property name="englishManifestVersionRegex">\$langinfo\['version'\] = "([0-9a-zA-Z.-]+)";</property>
<property name="masterThemeManifestVersionRegex"><![CDATA[<theme name="MyBB Master Style" version="([0-9a-zA-Z.-]+)">]]></property>
<property name="changedTemplatesRegex"><![CDATA[<template name="()" version="${targetVersionCode}">]]></property>
<property name="sourceGitRepository" value="https://github.com/mybb/mybb.git" />
<!-- output settings -->
<property name="distSetSourceSubdirectory" value="Upload" />
<property name="distSetPrefix" value="mybb_" />
<property name="updateSetPrefix" value="changed_files_" />
<property name="distChecksumsFilePrefix" value="checksums_" />
<property name="distChangedFilesFilePrefix" value="changed_files_list_" />
<property name="distRemovedFilesFilePrefix" value="removed_files_list_" />
<property name="distChangedTemplatesFilePrefix" value="changed_templates_list_" />
<property name="distPluginHooksFilePrefix" value="18_plugin_hooks" />
<!-- files to exclude when copying files for distribution packages -->
<patternset id="meta_files">
<exclude name="**/.git/**"></exclude>
<exclude name="**/.DS_Store"></exclude>
<exclude name="**/.DS_Store?"></exclude>
<exclude name="**/._*"></exclude>
<exclude name="**/.Spotlight-V100"></exclude>
<exclude name="**/.Trashes"></exclude>
<exclude name="**/ehthumbs.db"></exclude>
<exclude name="**/Thumbs.db"></exclude>
<exclude name=".gitignore"></exclude>
<exclude name="**/.gitkeep"></exclude>
<exclude name="CODE_OF_CONDUCT.md"></exclude>
<exclude name="CONTRIBUTING.md"></exclude>
<exclude name="SECURITY.md"></exclude>
<exclude name="LICENSE"></exclude>
<exclude name="readme.md"></exclude>
<exclude name="README.md"></exclude>
</patternset>
<!-- files with varying EOL encoding -->
<selector id="varying_eol_encoding_files">
<or>
<filename name="**/.htaccess" />
<filename name="**/LICENSE" />
<filename name="**/*.css" />
<filename name="**/*.html" />
<filename name="**/*.js" />
<filename name="**/*.php" />
<filename name="**/*.txt" />
<filename name="**/*.xml" />
</or>
</selector>
<!-- files which should be writable -->
<selector id="writable_files">
<or>
<filename name="inc/settings.php" />
<filename name="inc/config.default.php" />
</or>
</selector>
<!-- directories which should be writable -->
<selector id="writable_directories">
<or>
<filename name="cache" />
<filename name="cache/themes" />
<filename name="uploads" />
<filename name="uploads/avatars" />
</or>
</selector>
<!-- internal properties -->
<property name="distSetName" value="${distSetPrefix}${targetVersionCode}" />
<property name="updateSetName" value="${updateSetPrefix}${targetVersionCode}" />
<property name="distSetDirectory" value="${buildDirectory}/${distSetName}" />
<property name="updateSetDirectory" value="${buildDirectory}/${updateSetName}" />
<property name="distChecksumsFile" value="${buildDirectory}/${distChecksumsFilePrefix}${distSetName}" />
<property name="distChangedFilesFile" value="${buildDirectory}/${distChangedFilesFilePrefix}${targetVersionCode}" />
<property name="distRemovedFilesFile" value="${buildDirectory}/${distRemovedFilesFilePrefix}${targetVersionCode}" />
<property name="distChangedTemplatesFile" value="${buildDirectory}/${distChangedTemplatesFilePrefix}${targetVersionCode}" />
<property name="distPluginHooksFile" value="${buildDirectory}/${distPluginHooksFilePrefix}.yml" />
<property name="distVersionDataFile" value="${buildDirectory}/${targetVersion}.md" />
<property name="distSetSourceDirectory" value="${distSetDirectory}/${distSetSourceSubdirectory}" />
<!-- group tasks -->
<target name="dist-set" description="Executes tasks to build the distribution package" depends="remote-data,prepare,copy-clean,hardcoded-versions,chmod,patch,normalize-eol,dist-checksums,plugin-hooks,addendum,package,package-determinism,package-checksums,version-data,output" />
<target name="full" description="Executes tasks to build both distribution and update packages" depends="remote-data,prepare,copy-clean,hardcoded-versions,chmod,patch,normalize-eol,dist-checksums,plugin-hooks,updateset,updateset-install-directory,changed-templates,addendum,package,updateset-package,package-determinism,updateset-package-determinism,package-checksums,updateset-package-checksums,version-data,output" />
<!-- build process -->
<!-- build process: output preparation -->
<target name="prepare" description="Creates an empty directory for build files">
<delete dir="${buildDirectory}" quiet="true" />
<mkdir dir="${buildDirectory}" />
</target>
<!-- build process: input preparation -->
<target name="remote-data" description="Fetches additional build files from specified repository">
<if>
<not>
<equals arg1="${env.INPUT_FILES_REPOSITORY}" arg2="" />
</not>
<then>
<mkdir dir="${gitDirectory}" />
<exec dir="${gitDirectory}" command="git clone ${env.INPUT_FILES_REPOSITORY} --depth=1 --branch=${sourceRepositoryBranch} ./" checkreturn="true" />
<copy todir="${project.basedir}" preservelastmodified="true">
<fileset dir="${gitDirectory}">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
</copy>
<delete dir="${gitDirectory}" />
</then>
</if>
</target>
<target name="copy-clean" description="Copies files intended for distribution sets" depends="prepare">
<mkdir dir="${distSetDirectory}" />
<mkdir dir="${distSetSourceDirectory}" />
<mkdir dir="${previousSourceDirectoryInternal}" />
<if>
<isset property="sourceRepositoryBranch" />
<then>
<mkdir dir="${gitDirectory}" />
<property name="gitCloneCommand" value="git clone ${sourceGitRepository} --depth=1 --branch=${sourceRepositoryBranch} ./" override="true" />
<echo message="${gitCloneCommand}" />
<exec dir="${gitDirectory}" command="${gitCloneCommand}" checkreturn="true" />
<copy todir="${distSetSourceDirectory}" preservelastmodified="true">
<fileset dir="${gitDirectory}">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
</copy>
<delete dir="${gitDirectory}" />
</then>
<else>
<copy todir="${distSetSourceDirectory}" preservelastmodified="true">
<fileset dir="${sourceDirectory}">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
</copy>
</else>
</if>
<if>
<isset property="previousSourceRepositoryBranch" />
<then>
<mkdir dir="${gitDirectory}" />
<property name="gitCloneCommand" value="git clone ${sourceGitRepository} --depth=1 --branch=${previousSourceRepositoryBranch} ./" override="true" />
<echo message="${gitCloneCommand}" />
<exec dir="${gitDirectory}" command="${gitCloneCommand}" checkreturn="true" />
<copy todir="${previousSourceDirectoryInternal}" preservelastmodified="true">
<fileset dir="${gitDirectory}">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
</copy>
<delete dir="${gitDirectory}" />
</then>
<else>
<copy todir="${previousSourceDirectoryInternal}" preservelastmodified="true">
<fileset dir="${previousSourceDirectory}">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
</copy>
</else>
</if>
</target>
<!-- build process: input analysis -->
<target name="hardcoded-versions" description="Attempts to read versions hardcoded in source files">
<if>
<available file="${previousSourceDirectoryInternal}/inc/class_core.php" type="file" />
<then>
<loadfile property="previousCoreClassContent" file="${previousSourceDirectoryInternal}/inc/class_core.php" />
<propertyregex property="version" subject="${previousCoreClassContent}" pattern="${classCoreVersionRegex}" match="$1" defaultValue="Not found" override="true" />
<echo message="Version in previous inc/class_core.php: ${version}" />
</then>
</if>
<loadfile property="coreClassContent" file="${distSetSourceDirectory}/inc/class_core.php" />
<propertyregex property="version" subject="${coreClassContent}" pattern="${classCoreVersionRegex}" match="$1" defaultValue="Not found" override="true" />
<echo message="Version in inc/class_core.php: ${version}" />
<loadfile property="languageManifestContent" file="${distSetSourceDirectory}/inc/languages/english.php" />
<propertyregex property="version" subject="${languageManifestContent}" pattern="${englishManifestVersionRegex}" match="$1" defaultValue="Not found" override="true" />
<echo message="Version in inc/languages/english.php: ${version}" />
<loadfile property="themeManifestContent" file="${distSetSourceDirectory}/install/resources/mybb_theme.xml" />
<propertyregex property="version" subject="${themeManifestContent}" pattern="${masterThemeManifestVersionRegex}" match="$1" defaultValue="Not found" override="true" />
<echo message="Version in install/resources/mybb_theme.xml: ${version}" />
</target>
<!-- build process: distribution set operations -->
<target name="chmod" description="Applies file permissions to the target set" depends="copy-clean">
<chmod mode="0777" verbose="false">
<fileset dir="${distSetSourceDirectory}">
<selector refid="writable_directories" />
<type type="dir" />
</fileset>
</chmod>
<chmod mode="0666" verbose="false">
<fileset dir="${distSetSourceDirectory}">
<selector refid="writable_files" />
<type type="file" />
</fileset>
</chmod>
<chmod mode="0644" verbose="false">
<fileset dir="${distSetSourceDirectory}">
<include name="**" />
<not>
<selector refid="writable_files" />
</not>
<type type="file" />
</fileset>
</chmod>
</target>
<target name="patch" description="Applies attached git patches to the target file set" depends="copy-clean">
<if>
<available file="${patchesDirectory}" type="dir" />
<then>
<apply executable="git" dir="${distSetSourceDirectory}">
<arg value="apply" />
<arg value="--ignore-whitespace" />
<arg value="--verbose" />
<fileset dir="${patchesDirectory}">
<include name="**" />
</fileset>
</apply>
</then>
</if>
</target>
<target name="patch-reverse" description="Reverses attached git patches in the target file set" depends="copy-clean">
<apply executable="git" dir="${distSetSourceDirectory}">
<arg value="apply" />
<arg value="--reverse" />
<arg value="--ignore-whitespace" />
<fileset dir="${patchesDirectory}">
<include name="**" />
</fileset>
</apply>
</target>
<target name="normalize-eol" description="Converts line encoding in the target file set" depends="copy-clean">
<fileset dir="${distSetSourceDirectory}" id="varyingEolEncodingFiles">
<selector refid="varying_eol_encoding_files" />
<type type="file" />
</fileset>
<pathconvert pathsep="," property="varyingEolEncodingFiles" refid="varyingEolEncodingFiles" />
<exec passthru="true" command="php php/normalize-eol.php
--varyingEolEncodingFiles '${varyingEolEncodingFiles}'" />
</target>
<!-- build process: distribution set metadata -->
<target name="dist-checksums" description="Prints target file set checksums for different new line encodings" depends="copy-clean">
<delete file="${distChecksumsFile}" quiet="true" />
<fileset dir="${distSetSourceDirectory}" id="varyingEolEncodingFiles">
<selector refid="varying_eol_encoding_files" />
<type type="file" />
</fileset>
<pathconvert pathsep="," property="varyingEolEncodingFilesCsv" refid="varyingEolEncodingFiles" />
<fileset dir="${distSetSourceDirectory}" id="standardFiles">
<not>
<selector refid="varying_eol_encoding_files" />
</not>
<type type="file" />
</fileset>
<pathconvert pathsep="," property="standardFilesCsv" refid="standardFiles" />
<exec passthru="true" command="php php/dist-checksums.php
--standardFilesCsv '${standardFilesCsv}'
--varyingEolEncodingFilesCsv '${varyingEolEncodingFilesCsv}'
--distSetSourceDirectory '${distSetSourceDirectory}'
--distChecksumsFile '${distChecksumsFile}'
--algorithm 'sha512'" />
</target>
<target name="plugin-hooks" description="Generates a list of plugin hooks basing on the target file set" depends="copy-clean">
<delete file="${distPluginHooksFile}" quiet="true" />
<exec passthru="true" command="php php/plugin-hooks.php
--distSetSourceDirectory '${distSetSourceDirectory}'
--targetVersionCode '${targetVersionCode}'
--distPluginHooksFile '${distPluginHooksFile}'" />
</target>
<!-- build process: update set operations -->
<target name="updateset" description="Compares the target and previous file sets to generate the set of updated or new files" depends="copy-clean">
<delete dir="${updateSetDirectory}" quiet="true" />
<fileset dir="${distSetSourceDirectory}" id="distFiles">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
<pathconvert pathsep="," property="distFilesCsv" refid="distFiles" />
<fileset dir="${previousSourceDirectoryInternal}" id="previousFiles">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
<pathconvert pathsep="," property="previousFilesCsv" refid="previousFiles" />
<mkdir dir="${updateSetDirectory}" />
<exec passthru="true" command="php php/updateset.php
--distFilesCsv '${distFilesCsv}'
--previousFilesCsv '${previousFilesCsv}'
--previousSourceDirectory '${previousSourceDirectoryInternal}'
--distSetSourceDirectory '${distSetSourceDirectory}'
--outputDirectory '${updateSetDirectory}'
--distChangedFilesFile '${distChangedFilesFile}'
--distRemovedFilesFile '${distRemovedFilesFile}'" />
<copy todir="${updateSetDirectory}" preservelastmodified="true">
<filelist dir="${distSetSourceDirectory}" listfile="${distChangedFilesFile}" />
</copy>
</target>
<target name="updateset-install-directory" depends="updateset">
<if>
<istrue value="${includeInstallInUpdateSet}" />
<then>
<copy todir="${updateSetDirectory}/${installPackageSubdirectory}" preservelastmodified="true">
<fileset dir="${distSetSourceDirectory}/${installPackageSubdirectory}">
<include name="**" />
<patternset refid="meta_files" />
</fileset>
</copy>
</then>
<else>
<delete dir="${updateSetDirectory}/${installPackageSubdirectory}" />
</else>
</if>
</target>
<!-- build process: update set metadata -->
<target name="changed-templates" description="Generates a list of templates set to the target version" depends="updateset">
<delete file="${distChangedTemplatesFile}" quiet="true" />
<exec passthru="true" command="php php/changed-templates.php
--distSetSourceDirectory '${distSetSourceDirectory}'
--targetVersionCode '${targetVersionCode}'
--distChangedTemplatesFile '${distChangedTemplatesFile}'" />
</target>
<!-- build process: package operations -->
<target name="addendum" description="Copies additional files to the target file set" depends="copy-clean">
<copy todir="${distSetDirectory}" preservelastmodified="true">
<fileset dir="${packageAddendumDirectory}">
<include name="**" />
</fileset>
</copy>
</target>
<target name="package" description="Creates an archive from the target file set" depends="copy-clean">
<delete file="${buildDirectory}/${distSetName}.zip" quiet="true" />
<zip destfile="${buildDirectory}/${distSetName}.zip">
<fileset dir="${distSetDirectory}">
<include name="**" />
</fileset>
</zip>
</target>
<target name="updateset-package" description="Creates an archive from the update package set" depends="updateset">
<delete file="${buildDirectory}/${updateSetName}.zip" quiet="true" />
<zip destfile="${buildDirectory}/${updateSetName}.zip">
<fileset dir="${updateSetDirectory}">
<include name="**" />
</fileset>
</zip>
</target>
<target name="package-determinism" description="Strips non-deterministic information from the package archive" depends="package">
<php function="strtotime" returnProperty="packageDateTimestamp">
<param value="${packageDate}" />
</php>
<exec command="strip-nondeterminism --timestamp ${packageDateTimestamp} ${buildDirectory}/${distSetName}.zip" checkreturn="true" />
</target>
<target name="updateset-package-determinism" description="Strips non-deterministic information from the update set package archive" depends="updateset-package">
<php function="strtotime" returnProperty="packageDateTimestamp">
<param value="${packageDate}" />
</php>
<exec command="strip-nondeterminism --timestamp ${packageDateTimestamp} ${buildDirectory}/${updateSetName}.zip" checkreturn="true" />
</target>
<!-- build process: package metadata -->
<target name="package-checksums" description="Creates checksums of the target file set archive" depends="package">
<exec passthru="true" command="php php/file-checksums.php
--path '${buildDirectory}/${distSetName}.zip'
--algorithms 'md5,sha1,sha256,sha512'" />
</target>
<target name="updateset-package-checksums" description="Creates checksums of the update package set archive" depends="updateset-package">
<exec passthru="true" command="php php/file-checksums.php
--path '${buildDirectory}/${updateSetName}.zip'
--algorithms 'md5,sha1,sha256,sha512'" />
</target>
<target name="version-data" description="Generates a YAML data file for the target version" depends="package,package-checksums">
<delete file="${distVersionDataFile}" quiet="true" />
<exec passthru="true" command="php php/version-data.php
--buildDirectory '${buildDirectory}'
--distChangedFilesFile '${distChangedFilesFile}'
--distRemovedFilesFile '${distRemovedFilesFile}'
--distChangedTemplatesFile '${distChangedTemplatesFile}'
--updateSetDirectory '${updateSetDirectory}'
--languageFilesPackageDirectory '${languageFilesPackageDirectory}'
--distSetName '${distSetName}'
--updateSetName '${updateSetName}'
--targetVersion '${targetVersion}'
--targetVersionCode '${targetVersionCode}'
--distVersionDataFile '${distVersionDataFile}'" />
</target>
<!-- build process: output -->
<target name="output" description="Copies the build packages and metadata to the output directory">
<delete dir="${outputDirectory}" quiet="true" />
<mkdir dir="${outputDirectory}" />
<copy todir="${outputDirectory}" preservelastmodified="true">
<fileset dir="${buildDirectory}">
<include name="*" />
<type type="file" />
</fileset>
</copy>
</target>
</project>