-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
153 lines (136 loc) · 6.59 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Xysfdx-Dataloader" default="start_export">
<property environment="env"/>
<property name="dataloader.jar" location="${user.home}/jar"/>
<property name="default_api_version" value="42.0.0" />
<property name="dataloader_key_file" value="dataloader.key" />
<tstamp>
<format property="timestamp" pattern="yyyyMMdd_HHmm"/>
</tstamp>
<macrodef name="dataloader">
<attribute name="file"/>
<attribute name="object"/>
<attribute name="soql" default="" />
<attribute name="operation" />
<attribute name="sdl" default="" />
<attribute name="csv" default="" />
<attribute name="extid" default="" />
<attribute name="log.folder" default="log/@{operation}" />
<attribute name="log.file" default="@{log.folder}/@{object}_${timestamp}.log" />
<sequential>
<mkdir dir="@{log.folder}"/>
<record name="@{log.file}" append="true" action="start"/>
<echo message=">>>>>>>>>>>>>>>>>>>>>>Start @{operation} @{object}"/>
<echo message="Exporting @{object}"/>
<copy
file="template-process-conf.xml"
tofile="process-conf.xml"
overwrite="true"
failonerror="true"/>
<replace file="process-conf.xml">
<replacefilter token="_object_" value="@{object}"/>
<replacefilter token="_soql_" value="@{soql}"/>
<replacefilter token="_sdl_" value="@{sdl}"/>
<replacefilter token="_csv_" value="@{csv}"/>
<replacefilter token="_externalId_" value="@{extid}"/>
<replacefilter token="_folder_" value="@{object}_${timestamp}"/>
<replacefilter token="_file_" value="@{file}_${timestamp}.csv"/>
</replace>
<java
classname="com.salesforce.dataloader.process.ProcessRunner"
classpath="${dataloader.fullpath}"
failonerror="true">
<sysproperty key="salesforce.config.dir" value="."/>
<arg line="process.name=@{object}@{operation}"/>
</java>
<echo message=">>>>>>>>>>>>>>>>>>>>>>@{operation} @{object} Done!"/>
<echo message="log file : @{log.file}"/>
<record name="@{log.file}" action="stop"/>
</sequential>
</macrodef>
<macrodef name="set-property">
<attribute name="name" />
<attribute name="if-property-isset" />
<attribute name="value" default="${@{if-property-isset}}" />
<sequential>
<condition property="@{name}" value="@{value}">
<and>
<isset property="@{if-property-isset}" />
<not>
<equals arg1="${@{if-property-isset}}" arg2="" />
</not>
</and>
</condition>
</sequential>
</macrodef>
<scriptdef name="get_password" language="javascript">
<attribute name="text" />
<attribute name="password" />
<![CDATA[
var text = attributes.get("text");
var temp = text.split(/\r?\n/);
project.setProperty(attributes.get("password"), temp[temp.length - 1]);
]]>
</scriptdef>
<target name="init">
<set-property name="api_version" if-property-isset="apiversion" />
<property name="api_version" value="${default_api_version}" />
<property name="dataloader.fullpath" location="${dataloader.jar}/dataloader-${api_version}-uber.jar"/>
<mkdir dir="${dataloader.jar}"/>
<get src="http://salesforcexytools.com/mystatic/jar/dataloader-${api_version}-uber.jar" dest="${dataloader.fullpath}" verbose="true" usetimestamp="true"/>
</target>
<target name="encrypt_before_v42" depends="init">
<!-- ant encrypt -Dpassword=your_password -Dapiversion=42.0.0 -->
<sequential>
<java fork="true" classname="com.salesforce.dataloader.security.EncryptionUtil" classpath="${dataloader.fullpath}">
<arg line="-e ${password}"/>
</java>
<antcall target="finish" />
</sequential>
</target>
<target name="finish">
<echo message="Copy the generated encrypted password and set sfdc.password in config.properties."/>
</target>
<target name="encrypt" depends="generate_key">
<!-- ant encrypt -Dpassword=your_password -Dapiversion=47.0.0 -->
<sequential>
<java fork="true" classname="com.salesforce.dataloader.security.EncryptionUtil" classpath="${dataloader.fullpath}">
<arg line="-e ${password} ${dataloader_key_file}"/>
</java>
<antcall target="finish" />
</sequential>
</target>
<target name="check_key_file_exist">
<available file="${dataloader_key_file}" property="dataloader_key_file_exist"/>
</target>
<!-- Generate keyfile with optional keyfile path -->
<target name="generate_key" depends="init, check_key_file_exist" unless="dataloader_key_file_exist">
<sequential>
<java fork="true" classname="com.salesforce.dataloader.security.EncryptionUtil" classpath="${dataloader.fullpath}">
<arg line="-k ${dataloader_key_file}"/>
</java>
</sequential>
</target>
<target name="start_export" depends="init">
<!-- ant start_export -Dsobject_name=User -Dsoql="select id,name from user limit 100" -->
<dataloader file="${sobject_name}" object="${sobject_name}" soql="${soql}" operation="Export" />
</target>
<target name="export_all" depends="init">
<dataloader file="${sobject_name}" object="${sobject_name}" soql="${soql}" operation="ExportAll" />
</target>
<target name="insert" depends="init">
<dataloader file="${sobject_name}" object="${sobject_name}" sdl="${sdl}" csv="${csv}" operation="Insert" />
</target>
<target name="update" depends="init">
<dataloader file="${sobject_name}" object="${sobject_name}" sdl="${sdl}" csv="${csv}" operation="Update" />
</target>
<target name="delete" depends="init">
<dataloader file="${sobject_name}" object="${sobject_name}" sdl="${sdl}" csv="${csv}" operation="Delete" />
</target>
<target name="hard_delete" depends="init">
<dataloader file="${sobject_name}" object="${sobject_name}" sdl="${sdl}" csv="${csv}" operation="HardDelete" />
</target>
<target name="upsert" depends="init">
<dataloader file="${sobject_name}" object="${sobject_name}" sdl="${sdl}" csv="${csv}" extid="${extid}" operation="Upsert" />
</target>
</project>