-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
135 lines (124 loc) · 5.56 KB
/
build.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="dotty-common" default="init" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- set dotty.home -->
<property environment="env" />
<condition property="user.home"
value="${env.USERPROFILE}"
else="${env.HOME}">
<os family="windows" />
</condition>
<property name="ivy.cache" value="${user.home}/.ivy2/cache" />
<!-- installed: C:\opt\apache-ant-1.10.12\lib\ant-contrib-0.6.jar -->
<fail message="ant-contrib.jar is missing in %ANT_HOME%\lib\">
<condition><not>
<resourcecount count="1">
<fileset dir="${env.ANT_HOME}\lib" includes="ant-contrib*.jar" />
</resourcecount>
</not></condition>
</fail>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<property name="cfr.version" value="0.152" />
<!-- https://mvnrepository.com/artifact/com.pinterest.ktlint/ktlint-cli -->
<property name="ktlint-cli.version" value="1.3.1" />
<!-- https://mvnrepository.com/artifact/info.picocli/picocli -->
<property name="picocli.version" value="4.7.6" />
<target name="init">
<propertyregex
property="kotlin.home" input="${env.KOTLIN_HOME}"
regexp="/cygdrive/([a-z])/(.+)$" replace="\1:/\2"
defaultValue="${env.KOTLIN_HOME}"
/>
<condition property="kotlinc.executable"
value="${kotlin.home}/bin/kotlinc.bat"
else="${kotlin.home}/bin/kotlinc">
<or>
<not><os family="windows" /></not>
<matches string="${env.OS}" pattern="cygwin|mingw" />
</or>
</condition>
<fail message="Kotlin/JVM compiler not found (${kotlinc.executable})">
<condition><not>
<available file="${kotlinc.executable}" />
</not></condition>
</fail>
<echo message="KOTLIN_HOME=${kotlin.home}" />
<path id="kotlin.classpath">
<fileset dir="${kotlin.home}/lib" includes="*.jar" />
</path>
<typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.home}/lib/kotlin-ant.jar"/>
<path id="build.classpath">
<pathelement location="${build.dir}" />
</path>
<!-- installed: C:/opt/apache-ant-1.10.14/lib/ivy-2.5.2.jar -->
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" />
<ivy:resolve file="../ivy.xml" showprogress="false" log="download-only" />
<pathconvert property="cfr.jar">
<fileset dir="${ivy.cache}/org.benf" includes="**/cfr-${cfr.version}.jar" />
</pathconvert>
<pathconvert property="ktlint.jar">
<fileset dir="${ivy.cache}/com.pinterest" includes="**/ktlint-cli-${ktlint-cli.version}.jar" />
</pathconvert>
<pathconvert property="junit.jar">
<fileset dir="${ivy.cache}/junit" includes="**/junit-${junit.version}.jar" />
</pathconvert>
<path id="ktlint.classpath">
<fileset dir="${ivy.cache}/info.picocli" includes="**/jars/picocli-${picocli.version}.jar" />
<path refid="build.classpath" />
</path>
</target>
<macrodef name="cfr" >
<attribute name="srcdir" default="." />
<attribute name="destdir" default="." />
<attribute name="classpathref" default="basedir.ref" />
<sequential>
<!-- local properties -->
<local name="classpath"/>
<local name="n"/>
<local name="quoted"/>
<local name="s"/>
<local name="class.files"/>
<pathconvert property="class.files" pathsep=" ">
<fileset dir="@{srcdir}" includes="**/*.class" />
</pathconvert>
<resourcecount property="n">
<fileset dir="@{srcdir}" includes="**/*.class" />
</resourcecount>
<condition property="s" value="" else="s">
<matches string="${n}" pattern="[0-1]" />
</condition>
<echo message="Decompiling ${n} class file${s} to @{destdir}" level="info" />
<pathconvert property="classpath" refid="@{classpathref}" />
<condition property="quoted" value=""" else="">
<contains string="${classpath}" substring=" " />
</condition>
<java fork="true" jar="${cfr.jar}">
<arg value="--outputdir" />
<arg value="@{destdir}" />
<arg value="--extraclasspath" />
<arg value="${quoted}${classpath}${quoted}" />
<arg line="${class.files}" />
</java>
</sequential>
</macrodef>
<macrodef name="ktlint" >
<attribute name="pattern" default="src/**/*.kt" />
<attribute name="classpathref" default="basedir.ref" />
<sequential>
<!-- local properties -->
<local name="classpath"/>
<local name="quoted"/>
<echo message="Analyzing Kotlin source files" level="info" />
<pathconvert property="classpath" refid="@{classpathref}" />
<condition property="quoted" value=""" else="">
<contains string="${classpath}" substring=" " />
</condition>
<java fork="true" jar="${ktlint.jar}">
<arg value="--color" />
<arg value="--extraclasspath" />
<arg value="${quoted}${classpath}${quoted}" />
<arg line="${quoted}@{pattern}${quoted}" />
</java>
</sequential>
</macrodef>
</project>