forked from phatboyg/Magnum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomize.build
77 lines (67 loc) · 5.12 KB
/
customize.build
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
<?xml version="1.0" encoding="utf-8" ?>
<project name="Customize UppercuT" default="go">
<!-- Project UppercuT - http://projectuppercut.org -->
<!-- DO NOT EDIT THIS FILE - Add custom tasks in BuildTasks.Custom folder with file by the same name - find out more at http://uppercut.pbwiki.com -->
<property name="build.config.settings" value="__NONE__" overwrite="false" />
<include buildfile="${build.config.settings}" if="${file::exists(build.config.settings)}" />
<property name="path.separator" value="${string::trim(path::combine(' ', ' '))}" />
<property name="file.current.no_extension" value="customize" />
<property name="dirs.current" value="${directory::get-parent-directory(project::get-buildfile-path())}" />
<property name="path.to.toplevel" value=".." />
<property name="folder.build_scripts_custom" value="build.custom" overwrite="false" />
<property name="dirs.build_scripts_custom" value="${dirs.current}${path.separator}${path.to.toplevel}${path.separator}${folder.build_scripts_custom}" />
<property name="customize.step.name" value="__REPLACE__" overwrite="false" />
<property name="customize.step.type" value="__REPLACE__" overwrite="false" />
<property name="customize.step.type.lowered" value="${string::to-lower(customize.step.type)}" />
<property name="file.customize.template" value="item.template" />
<property name="file.customized" value="" readonly="false" />
<property name="path.to.custom_file" value="-1" />
<property name="path.to.custom_file" value="" if="${file::exists(customize.step.name)}" />
<target name="go" depends="run_tasks, report_finish_time" />
<target name="run_tasks">
<echo message="Running ${project::get-name()} to create custom tasks." />
<call target="prepare" if="${target::exists('prepare')}" />
<call target="run_normal_tasks" />
</target>
<target name="run_normal_tasks"
depends="error_check, customize"
description="Setting up a customize file for UppercuT." />
<target name="error_check">
<echo message="Error checking - the input for customize.step.name is '${customize.step.name}' and the input for customize.step.type is '${customize.step.type}'." />
<fail message="Please send in the arguments for what step to customize and what type of customization. Call customize.bat /? for usage instructions."
if="${customize.step.name=='__REPLACE__' or customize.step.type =='__REPLACE__'}" />
<fail message="The type of customization can only be pre, post, or replace."
unless="${customize.step.type.lowered =='pre' or customize.step.type.lowered =='post' or customize.step.type.lowered =='replace'}" />
</target>
<target name="customize">
<property name="file.customized" value="${path::get-file-name-without-extension(customize.step.name)}.${customize.step.type.lowered}${path::get-extension(customize.step.name)}" />
<echo message="Creating a customized step called ${file.customized}." />
<call target="resolve_path_to_custom_file" />
<fail message="${file.customized} already exists in ${dirs.build_scripts_custom}. Will not run." if="${file::exists(dirs.build_scripts_custom + path.separator + file.customized)}" />
<call target="create_file_if_not_already_existing" />
<call target="replace_template_values" />
</target>
<target name="resolve_path_to_custom_file">
<property name="path.to.custom_file" value="${path.separator}analyzers" if="${file::exists('analyzers' + path.separator + customize.step.name)}" />
<property name="path.to.custom_file" value="${path.separator}versioners" if="${file::exists('versioners' + path.separator + customize.step.name)}" />
<fail message="${customize.step.name} does not exist in anywhere in the build directory." if="${path.to.custom_file=='-1'}" />
<property name="dirs.build_scripts_custom" value="${dirs.build_scripts_custom}${path.to.custom_file}" />
<echo message="Found ${customize.step.name} in '${dirs.current}${path.separator}${path.to.custom_file}'. This means the custom path is going to be ${dirs.build_scripts_custom}." />
</target>
<target name="create_file_if_not_already_existing">
<copy file="customizers${path.separator}${file.customize.template}" tofile="${dirs.build_scripts_custom}${path.separator}${file.customized}" if="${not file::exists(dirs.build_scripts_custom + path.separator + file.customized)}" />
</target>
<target name="replace_template_values">
<xmlpoke
file="${dirs.build_scripts_custom}${path.separator}${file.customized}"
xpath="/project/@name"
value="CUSTOM ${string::to-upper(customize.step.type)} ${string::to-upper(path::get-file-name-without-extension(customize.step.name))}" />
<xmlpoke
file="${dirs.build_scripts_custom}${path.separator}${file.customized}"
xpath="/project/property[@name = 'path.to.toplevel']/@value"
value="..${path.separator}.." if="${path.to.custom_file !=''}" />
</target>
<target name="report_finish_time">
<echo message="Customize finished at ${datetime::now()}. Please make any customizations you need to now to ${dirs.build_scripts_custom}${path.separator}${file.customized} and don't forget to add it to source control." />
</target>
</project>