|
| 1 | +{% set dir = '${' ~ 'dir}' %} |
| 2 | +{% set buildDir = '${' ~ 'build-directory}' %} |
| 3 | +{% set packageDir = '${' ~ 'package-directory}' %} |
| 4 | +{% set vendor = '${' ~ 'vendor-name}' %} |
| 5 | +{% set extension = '${' ~ 'extension-name}' %} |
| 6 | +{% set buildVersion = '${' ~ 'version}' %} |
| 7 | +{% set packageVersion = '${' ~ 'package-version}' %} |
| 8 | +{% set archiveVersion = '${' ~ 'archive-version}' %} |
| 9 | +{% set destination = '${' ~ 'destination-filename}' %} |
| 10 | +{% set dependencies = '${' ~ 'has-dependencies}' %} |
| 11 | +<?xml version="1.0" encoding="UTF-8"?> |
| 12 | +<project name="Skeleton Extension Builder" description="Builds an extension.zip from a git repository" default="all"> |
| 13 | + <property name="vendor-name" value="{{ EXTENSION.vendor_name }}" /> |
| 14 | + <property name="extension-name" value="{{ EXTENSION.extension_name }}" /> |
| 15 | + <!-- |
| 16 | + Only set this to "true" if you have dependencies in the composer.json, |
| 17 | + otherwise use "false". |
| 18 | + --> |
| 19 | + <property name="has-dependencies" value="false" /> |
| 20 | + |
| 21 | + <target name="clean-package"> |
| 22 | + <!-- |
| 23 | + Remove some unnecessary files/directories |
| 24 | + {{ dir }}/ is the folder of your extension, e.g. ext/acme/demo/ |
| 25 | + --> |
| 26 | + <delete dir="{{ dir }}/tests" /> |
| 27 | + <delete dir="{{ dir }}/travis" /> |
| 28 | + |
| 29 | + <delete file="{{ dir }}/.gitignore" /> |
| 30 | + <delete file="{{ dir }}/.gitattributes" /> |
| 31 | + <delete file="{{ dir }}/.travis.yml" /> |
| 32 | + <delete file="{{ dir }}/build.xml" /> |
| 33 | + <delete file="{{ dir }}/composer.lock" /> |
| 34 | + <delete file="{{ dir }}/composer.phar" /> |
| 35 | + <delete file="{{ dir }}/phpunit.xml.dist" /> |
| 36 | + <delete file="{{ dir }}/README.md" /> |
| 37 | + </target> |
| 38 | + |
| 39 | + <!-- |
| 40 | + TODO: DO NOT EDIT BELOW THIS LINE!!!! |
| 41 | + --> |
| 42 | + |
| 43 | + <property name="version" value="HEAD" override="true" /> |
| 44 | + <property name="build-directory" value="build" override="true" /> |
| 45 | + <property name="package-directory" value="{{ buildDir }}/package/{{ vendor }}/{{ extension }}" /> |
| 46 | + |
| 47 | + <!-- These are the main targets which you will probably want to use --> |
| 48 | + <target name="all" depends="prepare-structure,package" /> |
| 49 | + |
| 50 | + <!-- |
| 51 | + Clean up the build directory |
| 52 | + --> |
| 53 | + <target name="clean"> |
| 54 | + <delete dir="{{ buildDir }}" /> |
| 55 | + </target> |
| 56 | + |
| 57 | + <!-- |
| 58 | + Recreate the necessary folders |
| 59 | + --> |
| 60 | + <target name="prepare-structure" depends="clean"> |
| 61 | + <mkdir dir="{{ buildDir }}" /> |
| 62 | + <mkdir dir="{{ buildDir }}/checkout" /> |
| 63 | + <mkdir dir="{{ buildDir }}/package" /> |
| 64 | + <mkdir dir="{{ buildDir }}/package/{{ vendor }}" /> |
| 65 | + <mkdir dir="{{ buildDir }}/package/{{ vendor }}/{{ extension }}" /> |
| 66 | + <mkdir dir="{{ buildDir }}/upload" /> |
| 67 | + </target> |
| 68 | + |
| 69 | + <!-- |
| 70 | + The real packaging |
| 71 | + --> |
| 72 | + <target name="package"> |
| 73 | + <echo msg="Extracting {{ buildVersion }}" /> |
| 74 | + |
| 75 | + <phingcall target="git-checkout"> |
| 76 | + <property name="archive-version" value="{{ buildVersion }}" /> |
| 77 | + </phingcall> |
| 78 | + |
| 79 | + <if> |
| 80 | + <equals arg1="{{ dependencies }}" arg2="1" /> |
| 81 | + <then> |
| 82 | + <exec dir="{{ packageDir }}" command="php composer.phar install --no-dev" |
| 83 | + checkreturn="true" /> |
| 84 | + </then> |
| 85 | + </if> |
| 86 | + |
| 87 | + <phingcall target="clean-package"> |
| 88 | + <property name="dir" value="{{ packageDir }}" /> |
| 89 | + </phingcall> |
| 90 | + |
| 91 | + <!-- Try setting the package version property from composer.json --> |
| 92 | + <exec dir="{{ packageDir }}" |
| 93 | + command='php -r "\$j = json_decode(file_get_contents(\"composer.json\")); echo (isset(\$j->version) ? \$j->version : \"{{ buildVersion }}\");"' |
| 94 | + checkreturn="true" |
| 95 | + outputProperty='package-version' /> |
| 96 | + |
| 97 | + <phingcall target="wrap-package"> |
| 98 | + <property name="destination-filename" value="{{ buildDir }}/upload/{{ vendor }}_{{ extension }}_{{ packageVersion }}" /> |
| 99 | + </phingcall> |
| 100 | + </target> |
| 101 | + |
| 102 | + <!-- |
| 103 | + Checkout a given version and install/clean the dependencies |
| 104 | + --> |
| 105 | + <target name="git-checkout"> |
| 106 | + <echo msg="Getting archive for {{ archiveVersion }}" /> |
| 107 | + |
| 108 | + <exec command="git archive {{ archiveVersion }} --format zip --output {{ buildDir }}/checkout/{{ archiveVersion }}.zip" |
| 109 | + checkreturn="true" /> |
| 110 | + <unzip file="{{ buildDir }}/checkout/{{ archiveVersion }}.zip" todir="{{ packageDir }}" /> |
| 111 | + </target> |
| 112 | + |
| 113 | + <!-- |
| 114 | + Create the zip and tar ball |
| 115 | + --> |
| 116 | + <target name="wrap-package"> |
| 117 | + <echo msg="Creating archives ({{ vendor }}/{{ extension }} {{ buildVersion }})" /> |
| 118 | + <zip basedir="{{ buildDir }}/package/" destfile="{{ destination }}.zip" /> |
| 119 | + </target> |
| 120 | +</project> |
0 commit comments