forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 26
/
TeamCityBuild.xml
125 lines (105 loc) · 4.96 KB
/
TeamCityBuild.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
<project name="Jet CI Steps" default="none">
<import file="build.xml" optional="false"/>
<property name="build.number" value="snapshot"/>
<property name="jdk16.home" value="${java.home}"/>
<property name="fail.on.plugin.verifier.error" value="true"/>
<property name="artifact.output.path" value="${basedir}/out/artifacts"/>
<property name="plugin.xml" value="idea/src/META-INF/plugin.xml"/>
<property name="plugin.xml.bk" value="${plugin.xml}.bk"/>
<property name="plugin.xml.versioned" value="${plugin.xml}.versioned" />
<property name="compiler.version.java" value="compiler/cli/src/org/jetbrains/jet/cli/common/CompilerVersion.java"/>
<property name="compiler.version.java.bk" value="${compiler.version.java}.bk"/>
<property name="compiler.version.java.versioned" value="${compiler.version.java}.versioned" />
<property name="plugin.verifier" value="${basedir}/dependencies/plugin-verifier.jar"/>
<property name="plugin.zip" value="${artifact.output.path}/kotlin-plugin-${build.number}.zip" />
<macrodef name="echoprop">
<attribute name="prop"/>
<sequential>
<echo>@{prop}=${@{prop}}</echo>
</sequential>
</macrodef>
<echoprop prop="os.name"/>
<echoprop prop="os.version"/>
<echoprop prop="os.arch"/>
<echoprop prop="java.home"/>
<echoprop prop="java.vendor"/>
<echoprop prop="java.version"/>
<echoprop prop="user.name"/>
<echoprop prop="user.home"/>
<echoprop prop="user.dir"/>
<target name="cleanupArtifacts">
<delete dir="${artifact.output.path}" includes="*"/>
</target>
<macrodef name="substituteVersionInFile">
<attribute name="target.file"/>
<attribute name="test.string"/>
<attribute name="target.file.bk" default="@{target.file}.bk"/>
<attribute name="target.file.versioned" default="@{target.file}.versioned"/>
<attribute name="token.key" default="snapshot"/>
<attribute name="version" default="${build.number}"/>
<sequential>
<!-- Create backup. Backup will be restored after build end. This will allow to rebuild project without renew
plugin.xml from repository. -->
<copy file="@{target.file}" tofile="@{target.file}.bk"/>
<!-- Check that version has correct pattern for substitution -->
<copy todir="">
<fileset file="@{target.file.bk}">
<contains text="@{test.string}"/>
</fileset>
<filterchain>
<replacetokens>
<token key="@{token.key}" value="@{version}"/>
</replacetokens>
</filterchain>
<mergemapper to="@{target.file.versioned}"/>
</copy>
<!-- If file doesn't exist - there's a problem with original plugin.xml. Probably there's a bad pattern used for version -->
<copy file="@{target.file.versioned}" tofile="@{target.file}" overwrite="true"/>
<delete file="@{target.file.versioned}" quiet="true"/>
</sequential>
</macrodef>
<target name="writeVersionToTemplateFiles">
<substituteVersionInFile
target.file="${plugin.xml}"
target.file.bk="${plugin.xml.bk}"
target.file.versioned="${plugin.xml.versioned}"
test.string="<version>@snapshot@</version>"/>
<substituteVersionInFile
target.file="${compiler.version.java}"
target.file.bk="${compiler.version.java.bk}"
target.file.versioned="${compiler.version.java.versioned}"
test.string="public static final String VERSION = "@snapshot@";"/>
</target>
<target name="revertTemplateFiles">
<copy file="${plugin.xml.bk}" tofile="${plugin.xml}" overwrite="true"/>
<delete file="${plugin.xml.bk}" quiet="true"/>
<copy file="${compiler.version.java.bk}" tofile="${compiler.version.java}" overwrite="true"/>
<delete file="${compiler.version.java.bk}" quiet="true"/>
</target>
<target name="pre_build" depends="writeVersionToTemplateFiles, cleanupArtifacts, dist, generateInjectors">
</target>
<target name="zipArtifact">
<zip destfile="${plugin.zip}">
<zipfileset prefix="Kotlin" dir="${artifact.output.path}/Kotlin"/>
</zip>
<delete dir="${artifact.output.path}/Kotlin" quiet="true"/>
</target>
<target name="verifyPlugin">
<!--
disabled plugin-verifier for now, waiting
for better plugin dependencies handling in it
-->
<!--
<java fork="true" failonerror="${fail.on.plugin.verifier.error}" jar="${plugin.verifier}">
<arg value="-r" />
<arg value="${jdk16.home}" />
<arg value="${plugin.zip}" />
<arg value="${basedir}/ideaSDK" />
</java>
-->
</target>
<target name="post_build" depends="zipArtifact, revertTemplateFiles, verifyPlugin"/>
<target name="none">
<fail message="Either specify pre_build or post_build"/>
</target>
</project>