forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TeamCityRelay.xml
99 lines (84 loc) · 4.47 KB
/
TeamCityRelay.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
<project name="Change plugins version" default="change-version">
<property name="relay.origin.version" value="1.0.0-beta-2423"/>
<property name="relay.substitute.version" value="1.0.0-beta-2423-IJ-141-3"/>
<property name="relay.plugins.dir" value="artifacts"/>
<property name="relay.unpack.directory" value="relay-dir"/>
<macrodef name="substituteRegexpInFile">
<attribute name="src.file"/>
<attribute name="output.dir"/>
<attribute name="origin.version"/>
<attribute name="substituted.version"/>
<sequential>
<copy todir="@{output.dir}">
<fileset file="@{src.file}"/>
<filterchain>
<replaceregex pattern="@{origin.version}" replace="@{substituted.version}" />
</filterchain>
</copy>
</sequential>
</macrodef>
<macrodef name="substitudeVersionInPlugin">
<attribute name="plugin.path"/>
<attribute name="plugin.jar.name"/>
<attribute name="origin.version"/>
<attribute name="substituted.version"/>
<attribute name="plugin.subdir"/>
<attribute name="output-dir" default="@{substituted.version}"/>
<attribute name="output.plugin.file.name" default="@{plugin.jar.name}-@{substituted.version}.zip"/>
<attribute name="temp.origin.dir" default="${relay.unpack.directory}/@{plugin.jar.name}/plugin-origin"/>
<attribute name="temp.substitute.dir" default="${relay.unpack.directory}/@{plugin.jar.name}/substitute"/>
<sequential>
<delete dir="${relay.unpack.directory}/@{plugin.jar.name}"/>
<mkdir dir="${relay.unpack.directory}/@{plugin.jar.name}"/>
<unzip src="@{plugin.path}" dest="@{temp.origin.dir}">
<patternset>
<include name="**/lib/@{plugin.jar.name}.jar" />
</patternset>
<flattenmapper/>
</unzip>
<unzip src="@{temp.origin.dir}/@{plugin.jar.name}.jar" dest="@{temp.origin.dir}">
<patternset>
<include name="**/META-INF/plugin.xml" />
</patternset>
<flattenmapper/>
</unzip>
<substituteRegexpInFile
src.file="@{temp.origin.dir}/plugin.xml" output.dir="@{temp.substitute.dir}"
origin.version="@{origin.version}" substituted.version="@{substituted.version}"/>
<!-- Copy updated file back into jar -->
<copy file="@{temp.origin.dir}/@{plugin.jar.name}.jar" todir="@{temp.substitute.dir}"/>
<jar destfile="@{temp.substitute.dir}/@{plugin.jar.name}.jar" update="true">
<zipfileset file="@{temp.substitute.dir}/plugin.xml" prefix="META-INF"/>
</jar>
<!-- Pack updated plugin.jar back to zip file -->
<copy file="@{plugin.path}" tofile="@{substituted.version}/@{output.plugin.file.name}"/>
<zip destfile="@{substituted.version}/@{output.plugin.file.name}" update="true">
<zipfileset file="@{temp.substitute.dir}/@{plugin.jar.name}.jar" prefix="@{plugin.subdir}/lib"/>
</zip>
</sequential>
</macrodef>
<target name="change-version" description="Repack plugin with other version">
<delete dir="${relay.unpack.directory}"/>
<delete dir="${relay.substitute.version}"/>
<mkdir dir="${relay.unpack.directory}"/>
<mkdir dir="${relay.substitute.version}"/>
<substitudeVersionInPlugin
plugin.jar.name="kotlin-plugin"
plugin.path="${relay.plugins.dir}/kotlin-plugin-${relay.origin.version}.zip"
origin.version="${relay.origin.version}"
plugin.subdir="Kotlin"
substituted.version="${relay.substitute.version}"/>
<substitudeVersionInPlugin
plugin.jar.name="kotlin-bare-plugin"
plugin.path="${relay.plugins.dir}/kotlin-bare-plugin-${relay.origin.version}.zip"
origin.version="${relay.origin.version}"
plugin.subdir="BareKotlin"
substituted.version="${relay.substitute.version}"/>
<substitudeVersionInPlugin
plugin.jar.name="kotlin-android-extensions"
plugin.path="${relay.plugins.dir}/kotlin-android-extensions-plugin-${relay.origin.version}.zip"
origin.version="${relay.origin.version}"
plugin.subdir="KotlinAndroidExtensions"
substituted.version="${relay.substitute.version}"/>
</target>
</project>