forked from JetBrains/kotlin-web-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_dependencies.xml
156 lines (130 loc) · 7.05 KB
/
update_dependencies.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
154
155
156
<!--
~ Copyright 2000-2012 JetBrains s.r.o.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project name="Update Dependencies" default="download_and_update">
<property name="dependencies.dir" value="dependencies"/>
<property name="unzipped.kotlin.plugin" value="lib/kotlin-plugin"/>
<property name="zipped.kotlin.plugin.pattern" value="kotlin-plugin*.zip"/>
<property name="teamcity" value="https://teamcity.jetbrains.com"/>
<property name="teamcity.plugin.build" value="bt345"/>
<property name="tc.plugin"
value="${teamcity}/guestAuth/repository/download/${teamcity.plugin.build}/bootstrap.tcbuildtag"/>
<target name="download_and_update">
<execute_update/>
<unzip_kotlin/>
<set_kotlin_version/>
</target>
<target name="download_and_update_internal">
<execute_update/>
<unzip_kotlin/>
<set_kotlin_version_internal/>
</target>
<macrodef name="unzip_kotlin">
<sequential>
<delete dir="${unzipped.kotlin.plugin}" failonerror="false"/>
<unzip dest="${unzipped.kotlin.plugin}">
<fileset dir="${dependencies.dir}" includes="${zipped.kotlin.plugin.pattern}"/>
</unzip>
<delete dir="kotlin.web.demo.core/resources/js" failonerror="false"/>
<unzip src="${unzipped.kotlin.plugin}/Kotlin/kotlinc/lib/kotlin-jslib.jar"
dest="kotlin.web.demo.core/resources/js"/>
<!--replace kotlin-compiler.jar to kotlin-compiler-before-shrink.jar-->
<copy file="${dependencies.dir}/kotlin-compiler.jar"
todir="${unzipped.kotlin.plugin}/Kotlin/kotlinc/lib"/>
<unzip src="${unzipped.kotlin.plugin}/Kotlin/kotlinc/lib/kotlin-jslib.jar" dest="${unzipped.kotlin.plugin}/jslib"/>
<copy file="${unzipped.kotlin.plugin}/jslib/kotlin.js"
todir="kotlin.web.demo.server/static"/>
<delete dir="${unzipped.kotlin.plugin}/jslib"/>
<get src="${teamcity}/guestAuth/app/rest/buildTypes/id:${teamcity.plugin.build}/builds/tag:bootstrap/number"
dest="${dependencies.dir}/build.txt"/>
<j2kConverter/>
</sequential>
</macrodef>
<macrodef name="j2kConverter">
<sequential>
<unzip src="${unzipped.kotlin.plugin}/Kotlin/lib/kotlin-plugin.jar" dest="${unzipped.kotlin.plugin}/j2k">
<patternset>
<include name="org/jetbrains/jet/j2k/**/*.class"/>
</patternset>
</unzip>
<loadfile srcfile="${dependencies.dir}/build.txt" property="version"/>
<jar jarfile="${unzipped.kotlin.plugin}/Kotlin/kotlinc/lib/tools/j2k.jar">
<fileset dir="${unzipped.kotlin.plugin}/j2k"/>
<manifest>
<attribute name="Built-By" value="JetBrains"/>
<attribute name="Implementation-Vendor" value="JetBrains"/>
<attribute name="Implementation-Title" value="Java to Kotlin Converter"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Main-Class" value="org.jetbrains.jet.j2k.JavaToKotlinTranslator"/>
</manifest>
</jar>
<delete dir="${unzipped.kotlin.plugin}/j2k"/>
</sequential>
</macrodef>
<macrodef name="set_kotlin_version">
<sequential>
<loadfile srcfile="${dependencies.dir}/build.txt" property="version"/>
<echo message="${version}"/>
<!-- kotlin.version and web.demo.version - from teamcity -->
<replaceregexp file="kotlin.web.demo.core/src/org/jetbrains/webdemo/server/ApplicationSettings.java"
match="KOTLIN_VERSION = "(.*[0-9]).(.*[0-9]).(.*[0-9])""
replace="KOTLIN_VERSION = "${version}""
byline="true"/>
<replaceregexp file="kotlin.web.demo.server/static/components/common.js"
match="KOTLIN_VERSION = "(.*[0-9]).(.*[0-9]).(.*[0-9])""
replace="KOTLIN_VERSION = "${version}""
byline="true"/>
<replaceregexp file="kotlin.web.demo.server/static/components/common.js"
match="WEB_DEMO_VERSION = "(.*[0-9]).(.*[0-9]).(.*[0-9])""
replace="WEB_DEMO_VERSION = "${web.demo.version}""
byline="true"/>
</sequential>
</macrodef>
<macrodef name="execute_update">
<sequential>
<delete dir="${dependencies.dir}" failonerror="false"/>
<mkdir dir="${dependencies.dir}"/>
<get src="${tc.plugin}/kotlin-plugin-{build.number}.zip" dest="${dependencies.dir}/kotlin-plugin.zip"/>
<get src="${tc.plugin}/internal/kotlin-compiler-before-shrink.jar" dest="${dependencies.dir}/kotlin-compiler.jar"/>
</sequential>
</macrodef>
<macrodef name="set_kotlin_version_internal">
<sequential>
<loadfile srcfile="${dependencies.dir}/build.txt" property="version"/>
<echo message="${version}"/>
<replaceregexp file="update_dependencies.xml"
match=" arg2="(.*[0-9]).(.*[0-9]).(.*[0-9])""
replace=" arg2="${version}""
byline="true"/>
</sequential>
</macrodef>
<target name="check_version" depends="check_version_true, check_version_false" if="isLastVersion"/>
<target name="check_version_true" depends="compare_version" if="isLastVersion">
<set_kotlin_version_internal/>
</target>
<target name="check_version_false" depends="compare_version" unless="isLastVersion">
<loadfile srcfile="${dependencies.dir}/build.txt" property="version"/>
<echo message="FALSE - ${version}"/>
<antcall target="download_and_update_internal"/>
</target>
<target name="compare_version">
<get src="${teamcity}/guestAuth/app/rest/buildTypes/id:${teamcity.plugin.build}/builds/tag:bootstrap/number"
dest="${dependencies.dir}/build.txt"/>
<loadfile srcfile="${dependencies.dir}/build.txt" property="version"/>
<condition property="isLastVersion">
<equals arg1="${version}" arg2="0.7.111" />
</condition>
</target>
</project>