-
Notifications
You must be signed in to change notification settings - Fork 369
/
build.xml
205 lines (162 loc) · 10.2 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<project name="Cumulus" default="deploy" basedir="." xmlns:sf="antlib:com.salesforce">
<!--
<taskdef uri="antlib:com.salesforce"
resource="com/salesforce/antlib.xml"
classpath="${basedir}/lib/ant-salesforce.jar" />
-->
<include file="${basedir}/lib/ant-salesforce.xml" />
<taskdef
resource="net/sf/antcontrib/antlib.xml"
classpath="${basedir}/lib/ant-contrib-1.0b2.jar" />
<!-- Load up the version.properties file to get desired versions -->
<loadproperties srcFile="${basedir}/version.properties"/>
<!-- Cumulus specific macros -->
<macrodef name="getPackageVersions" description="Gets the version for all installed packages">
<sequential>
<delete dir="${basedir}/installedPackages"/>
<mkdir dir="${basedir}/installedPackages"/>
<sf:bulkRetrieve
username="${sf.username}"
password="${sf.password}"
metadataType="InstalledPackage"
retrieveTarget="${basedir}/installedPackages"/>
<getPackageVersion namespace="npe01" refresh="false" />
<getPackageVersion namespace="npo02" refresh="false" />
<getPackageVersion namespace="npe03" refresh="false" />
<getPackageVersion namespace="npe4" refresh="false" />
<getPackageVersion namespace="npe5" refresh="false" />
<getPackageVersion namespace="npsp" refresh="false" />
<echo>Dependent Package Versions:
-------------------------------
npe01: ${InstalledPackage.npe01.versionNumber} (${version.npe01} required)
npo02: ${InstalledPackage.npo02.versionNumber} (${version.npo02} required)
npe03: ${InstalledPackage.npe03.versionNumber} (${version.npe03} required)
npe4: ${InstalledPackage.npe4.versionNumber} (${version.npe4} required)
npe5: ${InstalledPackage.npe5.versionNumber} (${version.npe5} required)
npsp: ${InstalledPackage.npsp.versionNumber} (${version.npsp} required)
</echo>
<delete dir="${basedir}/installedPackages"/>
</sequential>
</macrodef>
<macrodef name="updateDependentPackages">
<sequential>
<getPackageVersions />
<!-- npsp depends on all other packages. If it is installed and other packages need to be downgraded (uninstalled), uninstall npsp first -->
<if>
<and>
<not><equals arg1="${InstalledPackage.npsp.versionNumber}" arg2="Not Installed" /></not>
<or>
<bool><isgreaterthan arg1="${InstalledPackage.npe01.versionNumber}" arg2="version.npe01" /></bool>
<bool><isgreaterthan arg1="${InstalledPackage.npo02.versionNumber}" arg2="version.npo02" /></bool>
<bool><isgreaterthan arg1="${InstalledPackage.npe03.versionNumber}" arg2="version.npe03" /></bool>
<bool><isgreaterthan arg1="${InstalledPackage.npe4.versionNumber}" arg2="version.npe4" /></bool>
<bool><isgreaterthan arg1="${InstalledPackage.npe5.versionNumber}" arg2="version.npe5" /></bool>
</or>
</and>
<then>
<echo>Uninstalling npsp ${InstalledPackage.npsp.versionNumber} to allow for downgrade</echo>
<uninstallPackage namespace="npsp" username="${sf.username}" password="${sf.password}" />
<!-- Override the cached installed version of npsp so we don't have to fetch versions again -->
<var name="InstalledPackage.npsp.versionNumber" value="Not Installed" />
</then>
</if>
<!-- npo02 depends on npe01 so we have to uninstall npo02 first if npo02 needs downgraded -->
<if>
<and>
<!-- npo02 is installed -->
<not><equals arg1="${InstalledPackage.npo02.versionNumber}" arg2="Not Installed" /></not>
<!-- and npe01 need downgraded -->
<bool><isgreaterthan arg1="${InstalledPackage.npe01.versionNumber}" arg2="${version.npe01}" /></bool>
</and>
<then>
<echo>Uninstalling npo02 ${InstalledPackage.npe01.versionNumber} to allow for npe01 downgrade</echo>
<uninstallPackage namespace="npo02" username="${sf.username}" password="${sf.password}" />
<!-- Override the cached installed version of npo02 so we don't have to fetch versions again -->
<var name="InstalledPackage.npo02.versionNumber" value="Not Installed" />
</then>
</if>
<updatePackageVersion namespace="npe01" version="${version.npe01}" />
<updatePackageVersion namespace="npo02" version="${version.npo02}" />
<updatePackageVersion namespace="npe03" version="${version.npe03}" />
<updatePackageVersion namespace="npe4" version="${version.npe4}" />
<updatePackageVersion namespace="npe5" version="${version.npe5}" />
<updatePackageVersion namespace="npsp" version="${version.npsp}" />
</sequential>
</macrodef>
<!-- Cumulus Primary Build Targets -->
<!-- deploy: Run a full deployment including running all tests. Does not attempt to clean target org or ensure dependent package versions are correct -->
<target name="deploy">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="src" runAllTests="true" maxPoll="200" />
</target>
<!-- deployWithoutTests: Run a full deployment but don't run all tests. This is useful if you already know tests will pass from previous runs and just want to deploy faster -->
<target name="deployWithoutTest">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="src" runAllTests="false" maxPoll="200" />
</target>
<!-- deployCI: Does a full build including uninstalling previously deployed unpackaged code, updating managed package versions, and then deploying Cumulus with all tests -->
<!-- !!!WARNING!!!: DO NOT run this against a real production org as it will delete everything. It is designed to clear the target org to ensure a clean build test. -->
<target name="deployCI">
<!-- First, uninstall all unpackaged code from the target org. We have to do this first so we can uninstall and reinstall any managed packages not at the right version -->
<antcall target="uninstallCumulus" />
<!-- Update any managed packages which are not at the right version -->
<antcall target="updateDependentPackages" />
<!-- Finally, do a deploy with all tests -->
<antcall target="deploy" />
</target>
<!-- Deploys the latest managed beta (UAT) release to an org -->
<!-- !!!WARNING!!!: DO NOT run this against a real production org as it will delete everything. It is designed to clear the target org to ensure a clean build test. -->
<target name="deployManagedUAT">
<!-- In case the unpackaged code was deployed previously, clean the unpackaged metadata from the target org -->
<antcall target="uninstallCumulus" />
<!-- Get the latest beta release tag name -->
<get src="http://mrbelvedere.salesforcefoundation.org/mrbelvedere/repo/SalesforceFoundation/Cumulus/version/beta/tag" dest="${basedir}/managed_uat_tag" />
<loadfile property="managed_uat_tag" srcfile="${basedir}/managed_uat_tag" />
<delete file="${basedir}/managed_uat_tag" />
<!-- Fetch the version.properties file for the release from GitHub -->
<get src="https://raw.github.com/SalesforceFoundation/Cumulus/${managed_uat_tag}/version.properties" dest="${basedir}/managed/version.properties.uat" />
<!-- Since we want to use the versions required by the tag rather than the currently checked out code, unset all version properties and load the version.properties.uat file -->
<var name="version.npe01" unset="true" />
<var name="version.npo02" unset="true" />
<var name="version.npe03" unset="true" />
<var name="version.npe4" unset="true" />
<var name="version.npe5" unset="true" />
<loadproperties srcFile="${basedir}/version.properties.uat"/>
<delete file="${basedir}/version.properties.uat" />
<!-- Get the latest beta release version number -->
<get src="http://mrbelvedere.salesforcefoundation.org/mrbelvedere/repo/SalesforceFoundation/Cumulus/version/beta" dest="${basedir}/version_uat" />
<loadfile property="version.npsp.uat" srcfile="${basedir}/version_uat" />
<var name="version.npsp" value="${version.npsp.uat}" />
<delete file="${basedir}/version_uat" />
<getPackageVersions />
<!-- If npsp managed package is installed and version is not current, uninstall the package -->
<if>
<and>
<not><equals arg1="${InstalledPackage.npsp.versionNumber}" arg2="Not Installed" /></not>
<not><equals arg1="${InstalledPackage.npsp.versionNumber}" arg2="${version.npsp.uat}" /></not>
</and>
<then>
<echo>Uninstalling npsp ${InstalledPackage.npsp.versionNumber}</echo>
<uninstallPackage namespace="npsp" username="${sf.username}" password="${sf.password}" />
</then>
</if>
<antcall target="updateDependentPackages" />
<antcall target="runAllTests" />
</target>
<!-- Cumulus Utility Build Targets -->
<!-- uninstallCumulus: Removes all non-standard unpackaged metadata from the org for the metadata types used in Cumulus -->
<target name="uninstallCumulus">
<retrieveUnpackaged dir="uninstallsrc" />
<buildDestructiveChanges srcdir="uninstallsrc" dir="uninstall" />
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="uninstall/standard" runAllTests="false" maxPoll="200" />
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="uninstall/unpackaged" runAllTests="false" purgeOnDelete="true" maxPoll="200" />
</target>
<!-- updateDependendentPackages: Ensures all dependent packages are the correct version -->
<target name="updateDependentPackages">
<updateDependentPackages />
</target>
<target name="retrieveUnpackaged">
<retrieveUnpackaged dir="unpackaged" />
</target>
<target name="runAllTests">
<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="lib/empty" runAllTests="true" maxPoll="200" />
</target>
</project>