-
Notifications
You must be signed in to change notification settings - Fork 45
/
installPluginTemplate.xml
105 lines (71 loc) · 2.99 KB
/
installPluginTemplate.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
<project name="Install TeamCity.PluginTemplate" default="install.plugin" basedir=".">
<property name="plugin.template.archive.url" value="https://github.com/jonnyzzz/TeamCity.PluginTemplate/archive"/>
<target name="entry.point">
<echo message="This scipt will create IntelliJ IDEA project almost ready for developing a TeamCity plugin."/>
<input message="Please enter the plugin name:" addproperty="plugin.name"/>
<input message="Will the plugin have both server and agent parts? " validargs="y,n" addproperty="plugin.serverAndAgentStr"/>
</target>
<target name="check.plugin.name">
<fail message="plugin.name not specified">
<condition>
<not>
<isset property="plugin.name"/>
</not>
</condition>
</fail>
<fail message="plugin.name is empty">
<condition>
<length string="${plugin.name}" trim="true" when="eq" length="0"/>
</condition>
</fail>
<property name="plugin.path" value="${basedir}/${plugin.name}"/>
</target>
<target name="install.plugin" depends="entry.point, check.plugin.name, check.plugin.type, prepare.template">
<replace dir="${plugin.path}" token="PLUGIN_NAME" value="${plugin.name}" summary="true">
<include name="**"/>
</replace>
</target>
<target name="check.plugin.type">
<condition property="plugin.serverAndAgent">
<equals arg1="${plugin.serverAndAgentStr}" arg2="y"/>
</condition>
</target>
<target name="prepare.template" depends="download.serverOnly.template, download.serverAndAgent.template"/>
<target name="download.serverAndAgent.template" if="plugin.serverAndAgent">
<antcall target="download.template">
<param name="template.name" value="serverAndAgent"/>
</antcall>
</target>
<target name="download.serverOnly.template" unless="plugin.serverAndAgent">
<antcall target="download.template">
<param name="template.name" value="serverOnly"/>
</antcall>
</target>
<target name="download.template">
<property name="template.zip" value="${template.name}.zip"/>
<property name="template.url" value="${plugin.template.archive.url}/${template.zip}"/>
<get dest="${basedir}" verbose="true">
<url url="${template.url}"/>
</get>
<delete dir="${plugin.path}"/>
<mkdir dir="${plugin.path}"/>
<unzip dest="${basedir}" src="${basedir}/${template.zip}"/>
<echo message="Deleting template ${template.zip}"/>
<delete>
<fileset dir="${basedir}">
<include name="${template.zip}"/>
</fileset>
</delete>
<property name="template.path" value="${basedir}/TeamCity.PluginTemplate-${template.name}"/>
<move todir="${plugin.path}">
<fileset dir="${template.path}" defaultexcludes="no">
<include name="**/*"/>
</fileset>
<compositemapper>
<mapper type="regexp" from="^(.*)PLUGIN_NAME(.*)$" to="\1${plugin.name}\2"/>
<mapper type="identity"/>
</compositemapper>
</move>
<delete dir="${template.path}"/>
</target>
</project>